forked from msgpack/msgpack-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSet.java
More file actions
451 lines (401 loc) · 12.6 KB
/
TestSet.java
File metadata and controls
451 lines (401 loc) · 12.6 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
package org.msgpack;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.junit.Ignore;
@Ignore
public class TestSet {
public void testBoolean() throws Exception {
testBoolean(false);
testBoolean(true);
}
public void testBoolean(boolean v) throws Exception {
}
public void testBooleanArray() throws Exception {
testBooleanArray(null);
testBooleanArray(new boolean[0]);
testBooleanArray(new boolean[] { true });
testBooleanArray(new boolean[] { false });
testBooleanArray(new boolean[] { true, false });
Random rand = new Random();
boolean[] v = new boolean[100];
for (int i = 0; i < v.length; ++i) {
v[i] = rand.nextBoolean();
}
testBooleanArray(v);
}
public void testBooleanArray(boolean[] v) throws Exception {
}
public void testByte() throws Exception {
testShort((byte) 0);
testShort((byte) -1);
testShort((byte) 1);
testByte(Byte.MIN_VALUE);
testByte(Byte.MAX_VALUE);
byte[] bytes = new byte[1000];
Random rand = new Random();
rand.nextBytes(bytes);
for (int i = 0; i < bytes.length; ++i) {
testByte(bytes[i]);
}
}
public void testByte(byte v) throws Exception {
}
public void testByteArray() throws Exception {
testByteArray(null);
Random rand = new Random(System.currentTimeMillis());
byte[] b0 = new byte[0];
testByteArray(b0);
byte[] b1 = new byte[10];
rand.nextBytes(b1);
testByteArray(b1);
byte[] b2 = new byte[1024];
rand.nextBytes(b2);
testByteArray(b2);
}
public void testByteArray(byte[] v) throws Exception {
}
public void testShort() throws Exception {
testShort((short) 0);
testShort((short) -1);
testShort((short) 1);
testShort(Short.MIN_VALUE);
testShort(Short.MAX_VALUE);
Random rand = new Random();
byte[] bytes = new byte[2000];
rand.nextBytes(bytes);
for (int i = 0; i < bytes.length; i = i + 2) {
testShort((short) ((bytes[i] << 8) | (bytes[i + 1] & 0xff)));
}
}
public void testShort(short v) throws Exception {
}
public void testShortArray() throws Exception {
testShortArray(null);
testShortArray(new short[0]);
testShortArray(new short[] { 0 });
testShortArray(new short[] { -1 });
testShortArray(new short[] { 1 });
testShortArray(new short[] { 0, -1, 1 });
testShortArray(new short[] { Short.MIN_VALUE });
testShortArray(new short[] { Short.MAX_VALUE });
testShortArray(new short[] { Short.MIN_VALUE, Short.MAX_VALUE });
Random rand = new Random();
byte[] bytes = new byte[2];
short[] v = new short[100];
for (int i = 0; i < v.length; ++i) {
rand.nextBytes(bytes);
v[i] = (short) ((bytes[0] << 8) | (bytes[1] & 0xff));
}
testShortArray(v);
}
public void testShortArray(short[] v) throws Exception {
}
public void testInteger() throws Exception {
testInteger(0);
testInteger(-1);
testInteger(1);
testInteger(Integer.MIN_VALUE);
testInteger(Integer.MAX_VALUE);
Random rand = new Random();
for (int i = 0; i < 1000; i++) {
testInteger(rand.nextInt());
}
}
public void testInteger(int v) throws Exception {
}
public void testIntegerArray() throws Exception {
testIntegerArray(null);
testIntegerArray(new int[0]);
testIntegerArray(new int[] { 0 });
testIntegerArray(new int[] { -1 });
testIntegerArray(new int[] { 1 });
testIntegerArray(new int[] { 0, -1, 1 });
testIntegerArray(new int[] { Integer.MIN_VALUE });
testIntegerArray(new int[] { Integer.MAX_VALUE });
testIntegerArray(new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE });
Random rand = new Random();
int[] v = new int[100];
for (int i = 0; i < v.length; ++i) {
v[i] = rand.nextInt();
}
testIntegerArray(v);
}
public void testIntegerArray(int[] v) throws Exception {
}
public void testLong() throws Exception {
testLong(0);
testLong(-1);
testLong(1);
testLong(Long.MIN_VALUE);
testLong(Long.MAX_VALUE);
Random rand = new Random();
for (int i = 0; i < 1000; i++) {
testLong(rand.nextLong());
}
}
public void testLong(long v) throws Exception {
}
public void testLongArray() throws Exception {
testLongArray(null);
testLongArray(new long[0]);
testLongArray(new long[] { 0 });
testLongArray(new long[] { -1 });
testLongArray(new long[] { 1 });
testLongArray(new long[] { 0, -1, 1 });
testLongArray(new long[] { Long.MIN_VALUE });
testLongArray(new long[] { Long.MAX_VALUE });
testLongArray(new long[] { Long.MIN_VALUE, Long.MAX_VALUE });
Random rand = new Random();
long[] v = new long[100];
for (int i = 0; i < v.length; ++i) {
v[i] = rand.nextLong();
}
testLongArray(v);
}
public void testLongArray(long[] v) throws Exception {
}
public void testFloat() throws Exception {
testFloat((float) 0.0);
testFloat((float) -0.0);
testFloat((float) 1.0);
testFloat((float) -1.0);
testFloat(Float.MAX_VALUE);
testFloat(Float.MIN_VALUE);
testFloat(Float.NaN);
testFloat(Float.NEGATIVE_INFINITY);
testFloat(Float.POSITIVE_INFINITY);
Random rand = new Random();
for (int i = 0; i < 1000; i++) {
testFloat(rand.nextFloat());
}
}
public void testFloat(float v) throws Exception {
}
public void testFloatArray() throws Exception {
testFloatArray(null);
testFloatArray(new float[0]);
testFloatArray(new float[] { (float) 0.0 });
testFloatArray(new float[] { (float) -0.0 });
testFloatArray(new float[] { (float) -1.0 });
testFloatArray(new float[] { (float) 1.0 });
testFloatArray(new float[] { (float) 0.0, (float) -0.0, (float) -1.0, (float) 1.0 });
testFloatArray(new float[] { Float.MAX_VALUE });
testFloatArray(new float[] { Float.MIN_VALUE });
testFloatArray(new float[] { Float.NaN });
testFloatArray(new float[] { Float.NEGATIVE_INFINITY });
testFloatArray(new float[] { Float.POSITIVE_INFINITY });
testFloatArray(new float[] { Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY });
Random rand = new Random();
float[] v = new float[100];
for (int i = 0; i < v.length; ++i) {
v[i] = rand.nextFloat();
}
testFloatArray(v);
}
public void testFloatArray(float[] v) throws Exception {
}
public void testDouble() throws Exception {
testDouble((double) 0.0);
testDouble((double) -0.0);
testDouble((double) 1.0);
testDouble((double) -1.0);
testDouble(Double.MAX_VALUE);
testDouble(Double.MIN_VALUE);
testDouble(Double.NaN);
testDouble(Double.NEGATIVE_INFINITY);
testDouble(Double.POSITIVE_INFINITY);
Random rand = new Random();
for (int i = 0; i < 1000; i++) {
testDouble(rand.nextDouble());
}
}
public void testDouble(double v) throws Exception {
}
public void testDoubleArray() throws Exception {
testDoubleArray(null);
testDoubleArray(new double[0]);
testDoubleArray(new double[] { (double) 0.0 });
testDoubleArray(new double[] { (double) -0.0 });
testDoubleArray(new double[] { (double) -1.0 });
testDoubleArray(new double[] { (double) 1.0 });
testDoubleArray(new double[] { (double) 0.0, (double) -0.0, (double) -1.0, (double) 1.0 });
testDoubleArray(new double[] { Double.MAX_VALUE });
testDoubleArray(new double[] { Double.MIN_VALUE });
testDoubleArray(new double[] { Double.NaN });
testDoubleArray(new double[] { Double.NEGATIVE_INFINITY });
testDoubleArray(new double[] { Double.POSITIVE_INFINITY });
testDoubleArray(new double[] { Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY });
Random rand = new Random();
double[] v = new double[100];
for (int i = 0; i < v.length; ++i) {
v[i] = rand.nextDouble();
}
testDoubleArray(v);
}
public void testDoubleArray(double[] v) throws Exception {
}
public void testNil() throws Exception {
}
public void testString() throws Exception {
testString(null);
testString("");
testString("a");
testString("ab");
testString("abc");
StringBuilder sb;
int len;
// small size string
{
for (int i = 0; i < 100; i++) {
sb = new StringBuilder();
len = (int) Math.random() % 31 + 1;
for (int j = 0; j < len; j++) {
sb.append('a' + ((int) Math.random()) & 26);
}
testString(sb.toString());
}
}
// medium size string
{
for (int i = 0; i < 100; i++) {
sb = new StringBuilder();
len = (int) Math.random() % 100 + (1 << 15);
for (int j = 0; j < len; j++) {
sb.append('a' + ((int) Math.random()) & 26);
}
testString(sb.toString());
}
}
// large size string
{
for (int i = 0; i < 10; i++) {
sb = new StringBuilder();
len = (int) Math.random() % 100 + (1 << 31);
for (int j = 0; j < len; j++) {
sb.append('a' + ((int) Math.random()) & 26);
}
testString(sb.toString());
}
}
}
public void testString(String v) throws Exception {
}
public void testByteBuffer() throws Exception {
testByteBuffer(null);
Random rand = new Random(System.currentTimeMillis());
byte[] b0 = new byte[0];
testByteBuffer(ByteBuffer.wrap(b0));
byte[] b1 = new byte[10];
rand.nextBytes(b1);
testByteBuffer(ByteBuffer.wrap(b1));
byte[] b2 = new byte[1024];
rand.nextBytes(b2);
testByteBuffer(ByteBuffer.wrap(b2));
}
public void testByteBuffer(ByteBuffer v) throws Exception {
}
public void testList() throws Exception {
testList(null, Integer.class);
List<Integer> list0 = new ArrayList<Integer>();
testList(list0, Integer.class);
List<Integer> list1 = new ArrayList<Integer>();
Random rand1 = new Random();
for (int i = 0; i < 10; ++i) {
list1.add(rand1.nextInt());
}
testList(list1, Integer.class);
List<String> list2 = new ArrayList<String>();
Random rand2 = new Random();
for (int i = 0; i < 100; ++i) {
list2.add("xx" + rand2.nextInt());
}
testList(list2, String.class);
List<String> list3 = new ArrayList<String>();
Random rand3 = new Random();
for (int i = 0; i < 1000; ++i) {
list3.add("xx" + rand3.nextInt());
}
testList(list3, String.class);
}
public <E> void testList(List<E> v, Class<E> elementClass) throws Exception {
}
public void testMap() throws Exception {
testMap(null, Integer.class, Integer.class);
Map<Integer, Integer> map0 = new HashMap<Integer, Integer>();
testMap(map0, Integer.class, Integer.class);
Map<Integer, Integer> map1 = new HashMap<Integer, Integer>();
Random rand1 = new Random();
for (int i = 0; i < 10; ++i) {
map1.put(rand1.nextInt(), rand1.nextInt());
}
testMap(map1, Integer.class, Integer.class);
Map<String, Integer> map2 = new HashMap<String, Integer>();
Random rand2 = new Random();
for (int i = 0; i < 100; ++i) {
map2.put("xx" + rand2.nextInt(), rand2.nextInt());
}
testMap(map2, String.class, Integer.class);
Map<String, Integer> map3 = new HashMap<String, Integer>();
Random rand3= new Random();
for (int i = 0; i < 1000; ++i) {
map3.put("xx" + rand3.nextInt(), rand3.nextInt());
}
testMap(map3, String.class, Integer.class);
}
public <K, V> void testMap(Map<K, V> v, Class<K> keyElementClass, Class<V> valueElementClass) throws Exception {
}
public void testBigInteger() throws Exception {
testBigInteger(null);
testBigInteger(BigInteger.valueOf(0));
testBigInteger(BigInteger.valueOf(-1));
testBigInteger(BigInteger.valueOf(1));
testBigInteger(BigInteger.valueOf(Integer.MIN_VALUE));
testBigInteger(BigInteger.valueOf(Integer.MAX_VALUE));
testBigInteger(BigInteger.valueOf(Long.MIN_VALUE));
testBigInteger(BigInteger.valueOf(Long.MAX_VALUE));
BigInteger max = BigInteger.valueOf(Long.MAX_VALUE).setBit(63);
testBigInteger(max);
Random rand = new Random();
for (int i = 0; i < 1000; i++) {
testBigInteger(max.subtract(BigInteger.valueOf(Math.abs(rand.nextLong()))));
}
}
public void testBigInteger(BigInteger v) throws Exception {
}
public void testBigDecimal() throws Exception {
testBigDecimal(null);
testBigDecimal(BigDecimal.valueOf(0));
testBigDecimal(BigDecimal.valueOf(-1));
testBigDecimal(BigDecimal.valueOf(1));
testBigDecimal(BigDecimal.valueOf(Integer.MIN_VALUE));
testBigDecimal(BigDecimal.valueOf(Integer.MAX_VALUE));
testBigDecimal(BigDecimal.valueOf(Long.MIN_VALUE));
testBigDecimal(BigDecimal.valueOf(Long.MAX_VALUE));
}
public void testBigDecimal(BigDecimal v) throws Exception {
}
public void testDate() throws Exception {
testDate(null);
Date d0 = new Date();
testDate(d0);
}
public void testDate(Date v) throws Exception {
}
public void testCharacter() throws Exception {
testCharacter(null);
testCharacter('a');
testCharacter('あ');
testCharacter((char) 1);
testCharacter(Character.MIN_VALUE);
testCharacter(Character.MAX_VALUE);
}
public void testCharacter(Character v) throws Exception {
}
}