forked from msgpack/msgpack-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestStreamPackBufferUnpack.java
More file actions
196 lines (170 loc) · 5.25 KB
/
TestStreamPackBufferUnpack.java
File metadata and controls
196 lines (170 loc) · 5.25 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
package org.msgpack;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
import org.junit.Test;
import org.msgpack.packer.StreamPacker;
import org.msgpack.unpacker.BufferUnpacker;
public class TestStreamPackBufferUnpack extends TestSet {
@Test @Override
public void testBoolean() throws Exception {
super.testBoolean();
}
@Override
public void testBoolean(boolean v) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeBoolean(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeByte(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeShort(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeInt(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeLong(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeFloat(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeDouble(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(bytes);
double ret = unpacker.readDouble();
assertEquals(v, ret, 10e-10);
}
@Test @Override
public void testNil() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeNil();
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(bytes);
unpacker.readNil();
}
@Test @Override
public void testBigInteger() throws Exception {
super.testBigInteger();
}
@Override
public void testBigInteger(BigInteger v) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeBigInteger(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeString(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(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 {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamPacker packer = new StreamPacker(out);
packer.writeByteArray(v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = new BufferUnpacker();
unpacker.wrap(bytes);
byte[] ret = unpacker.readByteArray();
assertArrayEquals(v, ret);
}
}