From 15c388b819ebfebb83851950893413041288970f Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Mon, 12 Dec 2016 18:47:55 +0000 Subject: Basic serialization for upb_msg and Lua. Doesn't yet include strings, submessages, maps, or repeated fields. --- tests/bindings/lua/test_upb.pb.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/bindings/lua/test_upb.pb.lua b/tests/bindings/lua/test_upb.pb.lua index 6f0eda9..106dc55 100644 --- a/tests/bindings/lua/test_upb.pb.lua +++ b/tests/bindings/lua/test_upb.pb.lua @@ -43,7 +43,19 @@ function test_parse_primitive() .. "\128\128\128\128\128\002\032\128\128\128\128\128\128\128\001\041\000" .. "\000\000\000\000\000\248\063\053\000\000\096\064\056\001" local decoder = pb.MakeStringToMessageDecoder(TestMessage) - msg = decoder(binary_pb) + local encoder = pb.MakeMessageToStringEncoder(TestMessage) + collectgarbage() -- ensure encoder/decoder GC-anchor what they need. + local msg = decoder(binary_pb) + assert_equal(536870912, msg.i32) + assert_equal(1073741824, msg.u32) + assert_equal(1125899906842624, msg.i64) + assert_equal(562949953421312, msg.u64) + assert_equal(1.5, msg.dbl) + assert_equal(3.5, msg.flt) + assert_equal(true, msg.bool) + + local encoded = encoder(msg) + local msg2 = decoder(encoded) assert_equal(536870912, msg.i32) assert_equal(1073741824, msg.u32) assert_equal(1125899906842624, msg.i64) -- cgit v1.2.3