java: adds cross-language test case

This commit is contained in:
frsyuki
2010-08-18 22:51:23 +09:00
parent 5658ca5b90
commit fdfabc9f88
5 changed files with 48 additions and 0 deletions

View File

@@ -308,6 +308,7 @@ public class UnpackerImpl {
break _push;
}
cs = ACS_RAW_VALUE;
break _fixed_trail_again;
case ACS_RAW_VALUE: {
byte[] raw = new byte[trail];
System.arraycopy(src, n, raw, 0, trail);

View File

@@ -0,0 +1,46 @@
package org.msgpack;
import java.io.*;
import java.util.*;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestCases {
public void feedFile(Unpacker pac, String path) throws Exception {
FileInputStream input = new FileInputStream(path);
byte[] buffer = new byte[32*1024];
while(true) {
int count = input.read(buffer);
if(count < 0) {
break;
}
pac.feed(buffer, 0, count);
}
}
@Test
public void testCases() throws Exception {
System.out.println( new File(".").getAbsoluteFile().getParent() );
Unpacker pac = new Unpacker();
Unpacker pac_compact = new Unpacker();
feedFile(pac, "src/test/resources/cases.mpac");
feedFile(pac_compact, "src/test/resources/cases_compact.mpac");
UnpackResult result = new UnpackResult();
while(pac.next(result)) {
UnpackResult result_compact = new UnpackResult();
assertTrue( pac_compact.next(result_compact) );
System.out.println("obj: "+result_compact.getData());
if(!result.getData().equals(result_compact.getData())) {
System.out.println("compact: "+result_compact.getData().asString());
System.out.println("data : "+result.getData().asString());
}
assertTrue( result.getData().equals(result_compact.getData()) );
}
}
};

View File

@@ -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"]]]

Binary file not shown.

Binary file not shown.