summaryrefslogtreecommitdiff
path: root/tests/bindings
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-12-12 18:47:55 +0000
committerJosh Haberman <jhaberman@gmail.com>2016-12-12 18:52:20 +0000
commit15c388b819ebfebb83851950893413041288970f (patch)
tree2c266da71bda82fdcc641f4af9bf0e406396f49f /tests/bindings
parent076a82ee7edf35fb5f2a3430535e21a6dbd4cd6d (diff)
Basic serialization for upb_msg and Lua.
Doesn't yet include strings, submessages, maps, or repeated fields.
Diffstat (limited to 'tests/bindings')
-rw-r--r--tests/bindings/lua/test_upb.pb.lua14
1 files changed, 13 insertions, 1 deletions
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)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback