Skip to content

Commit

Permalink
Merge pull request #10 from nhynes/packtuple
Browse files Browse the repository at this point in the history
Pack Tuples as Arrays
  • Loading branch information
kmsquire committed Jun 16, 2015
2 parents f818753 + 36fd612 commit b1c2fe6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MsgPack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit b1c2fe6

Please sign in to comment.