diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000..9139e611 --- /dev/null +++ b/test/README.md @@ -0,0 +1,51 @@ +MessagePack cross-language test cases +===================================== + +## cases + +Valid serialized data are stored in "cases.mpac" and "cases_compact.mpac". +These files describe same objects. And "cases.json" describes an array of the described objects. + +Thus you can verify your implementations as comparing the objects. + + +## crosslang + +The *crosslang* tool reads serialized data from stdin and writes re-serialize data to stdout. + +There are C++ and Ruby implementation of crosslang tool. You can verify your implementation +as comparing that implementations. + +### C++ version + + $ cd ../cpp && ./configure && make && make install + or + $ port install msgpack # MacPorts + + $ g++ -Wall -lmsgpack crosslang.cc + + Usage: ./crosslang [in-file] [out-file] + + This tool is for testing of MessagePack implementation. + This does following behavior: + + 1. Reads objects serialized by MessagePack from <in-file> (default: stdin) + 2. Re-serializes the objects using C++ implementation of MessagePack (Note that C++ implementation is considered valid) + 3. Writes the re-serialized objects into <out-file> (default: stdout) + +### Ruby version + + $ gem install msgpack + or + $ port install rb_msgpack # MacPorts + + $ ruby crosslang.rb + Usage: crosslang.rb [in-file] [out-file] + + This tool is for testing of MessagePack implementation. + This does following behavior: + + 1. Reads objects serialized by MessagePack from <in-file> (default: stdin) + 2. Re-serializes the objects using Ruby implementation of MessagePack (Note that Ruby implementation is considered valid) + 3. Writes the re-serialized objects into <out-file> (default: stdout) + diff --git a/test/cases.json b/test/cases.json new file mode 100644 index 00000000..fd390d48 --- /dev/null +++ b/test/cases.json @@ -0,0 +1 @@ +[false,true,null,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,127,127,255,65535,4294967295,-32,-32,-128,-32768,-2147483648,0.0,-0.0,1.0,-1.0,"a","a","a","","","",[0],[0],[0],[],[],[],{},{},{},{"a":97},{"a":97},{"a":97},[[]],[["a"]]] \ No newline at end of file diff --git a/test/cases_gen.rb b/test/cases_gen.rb index 7efbfe7e..b349f4e2 100644 --- a/test/cases_gen.rb +++ b/test/cases_gen.rb @@ -3,6 +3,7 @@ # require 'rubygems' rescue nil require 'msgpack' +require 'json' source = <<EOF c2 # false @@ -65,6 +66,7 @@ bytes = source.strip.split(/\s+/).map {|x| x.to_i(16) }.pack('C*') objs = [] compact_bytes = "" + pac = MessagePack::Unpacker.new pac.feed(bytes) pac.each {|obj| @@ -73,6 +75,8 @@ pac.each {|obj| compact_bytes << obj.to_msgpack } +json = objs.to_json + # self check cpac = MessagePack::Unpacker.new cpac.feed(compact_bytes) @@ -88,4 +92,5 @@ cpac.each {|cobj| File.open("cases.mpac","w") {|f| f.write(bytes) } File.open("cases_compact.mpac","w") {|f| f.write(compact_bytes) } +File.open("cases.json","w") {|f| f.write(json) }