File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
src/test/java/org/msgpack/unpacker Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .msgpack .unpacker ;
2+
3+ import org .junit .Before ;
4+ import org .junit .Test ;
5+ import org .msgpack .MessagePack ;
6+
7+ import java .io .ByteArrayInputStream ;
8+ import java .io .ByteArrayOutputStream ;
9+ import java .io .IOException ;
10+
11+ import static org .junit .Assert .*;
12+
13+ public class TestMessagePackUnpacker {
14+ private MessagePack msgpack ;
15+
16+ @ Before
17+ public void setup () {
18+ msgpack = new MessagePack ();
19+ }
20+
21+ @ Test
22+ public void testStr8 () throws IOException {
23+ // Deserialize a data that another platform serialized a string "xxx...xxx" (length: 128).
24+ ByteArrayOutputStream out = new ByteArrayOutputStream ();
25+ // 0xD9: str8, 0x80: length: 128
26+ out .write (new byte [] {(byte ) 0xD9 , (byte ) 0x80 });
27+ for (int i = 0 ; i < 128 ; i ++) {
28+ // 0x78: 'x'
29+ out .write (0x78 );
30+ }
31+ Unpacker unpacker = msgpack .createUnpacker (new ByteArrayInputStream (out .toByteArray ()));
32+ String string = unpacker .readString ();
33+ assertEquals (128 , string .length ());
34+ for (int i = 0 ; i < 128 ; i ++) {
35+ assertEquals ('x' , string .charAt (i ));
36+ }
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments