forked from msgpack/msgpack-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestSimpleConvertUnconvert.java
More file actions
38 lines (29 loc) · 983 Bytes
/
TestSimpleConvertUnconvert.java
File metadata and controls
38 lines (29 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.msgpack;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertArrayEquals;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.msgpack.MessagePack;
import org.msgpack.value.Value;
import org.msgpack.unpacker.Converter;
import org.msgpack.packer.Unconverter;
import org.junit.Test;
public class TestSimpleConvertUnconvert {
@Test
public void testSimpleConvert() throws IOException {
MessagePack msgpack = new MessagePack();
byte[] raw = msgpack.write(new int[] {1,2,3});
Value v = msgpack.read(raw);
int[] array = msgpack.convert(v, new int[3]);
assertArrayEquals(new int[] {1,2,3}, array);
Value v2 = msgpack.unconvert(array);
assertEquals(v, v2);
}
}