diff --git a/src/MsgPack.jl b/src/MsgPack.jl index 7257c19..85b88b0 100644 --- a/src/MsgPack.jl +++ b/src/MsgPack.jl @@ -277,7 +277,7 @@ pack(s, v::Vector{Uint8}) = begin end # Simple arrays -pack(s, v::Vector) = begin +pack(s, v::Union(Vector, Tuple)) = begin n = length(v) if n < 2^4 write(s, ARR_F | uint8(n)) diff --git a/test/runtests.jl b/test/runtests.jl index 9de84d6..85c862b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -78,6 +78,12 @@ b = [] @test ck_pack(Any[true, Uint8[0xff, 0xde, 0x11], [1, 2, 3]], [0x93, 0xc3, 0xc4, 0x03, 0xff, 0xde, 0x11, 0x93, 0x01, 0x02, 0x03]) +# tuple +@test pack(Any[(1, [true, false], Uint8[0xff, 0xde])]) == + [0x91, 0x93, 0x01, 0x92, 0xc3, 0xc2, 0xc4, 0x02, 0xff, 0xde] +@test pack(("hi", (float32(2), 0xff))) == + [0x92, 0xa2, 0x68, 0x69, 0x92, 0xca, 0x40, 0x00, 0x00, 0x00, 0xcc, 0xff] + # fixmap @test ck_pack({1=>2, "hi"=>"mom"}, [0x82,0xa2,0x68,0x69,0xa3,0x6d,0x6f,0x6d,0x01,0x02])