mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-21 15:51:44 +02:00
java: adds cross-language test case
This commit is contained in:
@@ -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);
|
||||
|
46
java/src/test/java/org/msgpack/TestCases.java
Normal file
46
java/src/test/java/org/msgpack/TestCases.java
Normal 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()) );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
1
java/src/test/resources/cases.json
Normal file
1
java/src/test/resources/cases.json
Normal 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"]]]
|
BIN
java/src/test/resources/cases.mpac
Normal file
BIN
java/src/test/resources/cases.mpac
Normal file
Binary file not shown.
BIN
java/src/test/resources/cases_compact.mpac
Normal file
BIN
java/src/test/resources/cases_compact.mpac
Normal file
Binary file not shown.
Reference in New Issue
Block a user