more test caces

This commit is contained in:
frsyuki 2009-03-04 01:36:56 +09:00
parent c612a177cc
commit 840388720e

View File

@ -113,6 +113,80 @@ class MessagePackTestFormat < Test::Unit::TestCase
#check_array 5, (1<<32)-1 # memory error
end
it "nil" do
match nil, "\xc0"
end
it "false" do
match false, "\xc2"
end
it "true" do
match true, "\xc3"
end
it "0" do
match 0, "\x00"
end
it "127" do
match 127, "\x7f"
end
it "128" do
match 128, "\xcc\x80"
end
it "256" do
match 256, "\xcd\x01\x00"
end
it "-1" do
match -1, "\xff"
end
it "-33" do
match -33, "\xd0\xdf"
end
it "-129" do
match -129, "\xd1\xff\x7f"
end
it "{1=>1}" do
match ({1=>1}), "\x81\x01\x01"
end
it "1.0" do
match 1.0, "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00"
end
it "[]" do
match [], "\x90"
end
it "[0, 1, ..., 14]" do
match (0..14).to_a, "\x9f\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e"
end
it "[0, 1, ..., 15]" do
match (0..15).to_a, "\xdc\x00\x10\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
end
it "{}" do
match ({}), "\x80"
end
it "{0=>0, 1=>1, ..., 14=>14}" do
a = (0..14).to_a;
match Hash[*a.zip(a).flatten], "\x8f\x05\x05\x0b\x0b\x00\x00\x06\x06\x0c\x0c\x01\x01\x07\x07\x0d\x0d\x02\x02\x08\x08\x0e\x0e\x03\x03\x09\x09\x04\x04\x0a\x0a"
end
it "{0=>0, 1=>1, ..., 15=>15}" do
a = (0..15).to_a;
match Hash[*a.zip(a).flatten], "\xde\x00\x10\x05\x05\x0b\x0b\x00\x00\x06\x06\x0c\x0c\x01\x01\x07\x07\x0d\x0d\x02\x02\x08\x08\x0e\x0e\x03\x03\x09\x09\x0f\x0f\x04\x04\x0a\x0a"
end
# it "fixmap" do
# check_map 1, 0
# check_map 1, (1<<4)-1
@ -143,8 +217,8 @@ class MessagePackTestFormat < Test::Unit::TestCase
check num+overhead, Array.new(num)
end
def check_map(overhead, num)
# FIXME
def match(obj, buf)
assert_equal(obj.to_msgpack, buf)
end
end