forked from msgpack/msgpack-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestBufferPackStreamUnpack.java
More file actions
174 lines (148 loc) · 4.71 KB
/
TestBufferPackStreamUnpack.java
File metadata and controls
174 lines (148 loc) · 4.71 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package org.msgpack;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import org.junit.Test;
import org.msgpack.packer.BufferPacker;
import org.msgpack.unpacker.StreamUnpacker;
public class TestBufferPackStreamUnpack extends TestSet {
@Test @Override
public void testBoolean() throws Exception {
super.testBoolean();
}
@Override
public void testBoolean(boolean v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeBoolean(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
boolean ret = unpacker.readBoolean();
assertEquals(v, ret);
}
@Test @Override
public void testByte() throws Exception {
super.testByte();
}
@Override
public void testByte(byte v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeByte(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
byte ret = unpacker.readByte();
assertEquals(v, ret);
}
@Test @Override
public void testShort() throws Exception {
super.testShort();
}
@Override
public void testShort(short v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeShort(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
short ret = unpacker.readShort();
assertEquals(v, ret);
}
@Test @Override
public void testInteger() throws Exception {
super.testInteger();
}
@Override
public void testInteger(int v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeInt(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
int ret = unpacker.readInt();
assertEquals(v, ret);
}
@Test @Override
public void testLong() throws Exception {
super.testLong();
}
@Override
public void testLong(long v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeLong(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
long ret = unpacker.readLong();
assertEquals(v, ret);
}
@Test @Override
public void testFloat() throws Exception {
super.testFloat();
}
@Override
public void testFloat(float v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeFloat(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
float ret = unpacker.readFloat();
assertEquals(v, ret, 10e-10);
}
@Test @Override
public void testDouble() throws Exception {
super.testDouble();
}
@Override
public void testDouble(double v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeDouble(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
double ret = unpacker.readDouble();
assertEquals(v, ret, 10e-10);
}
@Test @Override
public void testNil() throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeNil();
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
unpacker.readNil();
}
@Test @Override
public void testBigInteger() throws Exception {
super.testBigInteger();
}
@Override
public void testBigInteger(BigInteger v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeBigInteger(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
BigInteger ret = unpacker.readBigInteger();
assertEquals(v, ret);
}
@Test @Override
public void testString() throws Exception {
super.testString();
}
@Override
public void testString(String v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeString(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
String ret = unpacker.readString();
assertEquals(v, ret);
}
@Test @Override
public void testByteArray() throws Exception {
super.testByteArray();
}
@Override
public void testByteArray(byte[] v) throws Exception {
BufferPacker packer = new BufferPacker();
packer.writeByteArray(v);
byte[] bytes = packer.toByteArray();
StreamUnpacker unpacker = new StreamUnpacker(new ByteArrayInputStream(bytes));
byte[] ret = unpacker.readByteArray();
assertArrayEquals(v, ret);
}
}