Skip to content

Commit

Permalink
Add test for issue #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinq0123 committed Aug 22, 2017
1 parent 76c18ba commit e9bf62d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ function M.test_many_fields()
assert(n3 == "n1" or n3 == "n2" or n3 == "n3")
assert(10 == msg2.cmd)
assert(msg2.common_msg)
end -- test_encode_decode()
end -- test_many_fields()

function M.test_packed()
local msg = { samples = {1,2,3} }
local s = pb.encode("test.TestMsg", msg)
local msg2 = pb.decode("test.TestMsg", s)
assert(#msg2.samples == 3)
end -- test.packed()
end -- test_packed()

function M.test_map()
local msgs = {}
Expand Down Expand Up @@ -184,6 +184,17 @@ function M.test_decode_return_nil()
assert(nil == pb.decode("test.TestMsg", "IllegalData"))
end -- test_decode_return_nil()

-- Failed test: issue #6
function M.test_coroutine()
local co = coroutine.wrap(function()
M.test_encode_decode()
coroutine.yield()
M.test_encode_decode()
end)
co()
co()
end -- test_coroutine()

function M.test_all()
M.test_rpc()
M.test_encode_decode()
Expand All @@ -206,6 +217,7 @@ function M.test_all()
M.test_oneof_both()
M.test_oneof_default_value()
M.test_decode_return_nil()
-- Failed: M.test_coroutine()
print("Test OK!")
end -- test_all

Expand Down

0 comments on commit e9bf62d

Please sign in to comment.