Mercurial > hg > Members > sugi > MessagePack-java
comparison src/test/java/org/msgpack/TestSet.java @ 0:cb825acd883a
first commit
author | sugi |
---|---|
date | Sat, 18 Oct 2014 15:06:15 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cb825acd883a |
---|---|
1 package org.msgpack; | |
2 | |
3 import java.math.BigDecimal; | |
4 import java.math.BigInteger; | |
5 import java.nio.ByteBuffer; | |
6 import java.util.ArrayList; | |
7 import java.util.Date; | |
8 import java.util.HashMap; | |
9 import java.util.List; | |
10 import java.util.Map; | |
11 import java.util.Random; | |
12 | |
13 import org.junit.Ignore; | |
14 | |
15 | |
16 @Ignore | |
17 public class TestSet { | |
18 | |
19 public void testBoolean() throws Exception { | |
20 testBoolean(false); | |
21 testBoolean(true); | |
22 } | |
23 | |
24 public void testBoolean(boolean v) throws Exception { | |
25 } | |
26 | |
27 public void testBooleanArray() throws Exception { | |
28 testBooleanArray(null); | |
29 testBooleanArray(new boolean[0]); | |
30 testBooleanArray(new boolean[] { true }); | |
31 testBooleanArray(new boolean[] { false }); | |
32 testBooleanArray(new boolean[] { true, false }); | |
33 Random rand = new Random(); | |
34 boolean[] v = new boolean[100]; | |
35 for (int i = 0; i < v.length; ++i) { | |
36 v[i] = rand.nextBoolean(); | |
37 } | |
38 testBooleanArray(v); | |
39 } | |
40 | |
41 public void testBooleanArray(boolean[] v) throws Exception { | |
42 } | |
43 | |
44 public void testByte() throws Exception { | |
45 testByte((byte) 0); | |
46 testByte((byte) -1); | |
47 testByte((byte) 1); | |
48 testByte(Byte.MIN_VALUE); | |
49 testByte(Byte.MAX_VALUE); | |
50 byte[] bytes = new byte[1000]; | |
51 Random rand = new Random(); | |
52 rand.nextBytes(bytes); | |
53 for (int i = 0; i < bytes.length; ++i) { | |
54 testByte(bytes[i]); | |
55 } | |
56 } | |
57 | |
58 public void testByte(byte v) throws Exception { | |
59 } | |
60 | |
61 public void testByteArray() throws Exception { | |
62 testByteArray(null); | |
63 Random rand = new Random(System.currentTimeMillis()); | |
64 byte[] b0 = new byte[0]; | |
65 testByteArray(b0); | |
66 byte[] b1 = new byte[10]; | |
67 rand.nextBytes(b1); | |
68 testByteArray(b1); | |
69 byte[] b2 = new byte[1024]; | |
70 rand.nextBytes(b2); | |
71 testByteArray(b2); | |
72 } | |
73 | |
74 public void testByteArray(byte[] v) throws Exception { | |
75 } | |
76 | |
77 public void testShort() throws Exception { | |
78 testShort((short) 0); | |
79 testShort((short) -1); | |
80 testShort((short) 1); | |
81 testShort(Short.MIN_VALUE); | |
82 testShort(Short.MAX_VALUE); | |
83 Random rand = new Random(); | |
84 byte[] bytes = new byte[2000]; | |
85 rand.nextBytes(bytes); | |
86 for (int i = 0; i < bytes.length; i = i + 2) { | |
87 testShort((short) ((bytes[i] << 8) | (bytes[i + 1] & 0xff))); | |
88 } | |
89 } | |
90 | |
91 public void testShort(short v) throws Exception { | |
92 } | |
93 | |
94 public void testShortArray() throws Exception { | |
95 testShortArray(null); | |
96 testShortArray(new short[0]); | |
97 testShortArray(new short[] { 0 }); | |
98 testShortArray(new short[] { -1 }); | |
99 testShortArray(new short[] { 1 }); | |
100 testShortArray(new short[] { 0, -1, 1 }); | |
101 testShortArray(new short[] { Short.MIN_VALUE }); | |
102 testShortArray(new short[] { Short.MAX_VALUE }); | |
103 testShortArray(new short[] { Short.MIN_VALUE, Short.MAX_VALUE }); | |
104 Random rand = new Random(); | |
105 byte[] bytes = new byte[2]; | |
106 short[] v = new short[100]; | |
107 for (int i = 0; i < v.length; ++i) { | |
108 rand.nextBytes(bytes); | |
109 v[i] = (short) ((bytes[0] << 8) | (bytes[1] & 0xff)); | |
110 } | |
111 testShortArray(v); | |
112 } | |
113 | |
114 public void testShortArray(short[] v) throws Exception { | |
115 } | |
116 | |
117 public void testInteger() throws Exception { | |
118 testInteger(0); | |
119 testInteger(-1); | |
120 testInteger(1); | |
121 testInteger(Integer.MIN_VALUE); | |
122 testInteger(Integer.MAX_VALUE); | |
123 Random rand = new Random(); | |
124 for (int i = 0; i < 1000; i++) { | |
125 testInteger(rand.nextInt()); | |
126 } | |
127 } | |
128 | |
129 public void testInteger(int v) throws Exception { | |
130 } | |
131 | |
132 public void testIntegerArray() throws Exception { | |
133 testIntegerArray(null); | |
134 testIntegerArray(new int[0]); | |
135 testIntegerArray(new int[] { 0 }); | |
136 testIntegerArray(new int[] { -1 }); | |
137 testIntegerArray(new int[] { 1 }); | |
138 testIntegerArray(new int[] { 0, -1, 1 }); | |
139 testIntegerArray(new int[] { Integer.MIN_VALUE }); | |
140 testIntegerArray(new int[] { Integer.MAX_VALUE }); | |
141 testIntegerArray(new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE }); | |
142 Random rand = new Random(); | |
143 int[] v = new int[100]; | |
144 for (int i = 0; i < v.length; ++i) { | |
145 v[i] = rand.nextInt(); | |
146 } | |
147 testIntegerArray(v); | |
148 } | |
149 | |
150 public void testIntegerArray(int[] v) throws Exception { | |
151 } | |
152 | |
153 public void testLong() throws Exception { | |
154 testLong(0); | |
155 testLong(-1); | |
156 testLong(1); | |
157 testLong(Long.MIN_VALUE); | |
158 testLong(Long.MAX_VALUE); | |
159 Random rand = new Random(); | |
160 for (int i = 0; i < 1000; i++) { | |
161 testLong(rand.nextLong()); | |
162 } | |
163 } | |
164 | |
165 public void testLong(long v) throws Exception { | |
166 } | |
167 | |
168 public void testLongArray() throws Exception { | |
169 testLongArray(null); | |
170 testLongArray(new long[0]); | |
171 testLongArray(new long[] { 0 }); | |
172 testLongArray(new long[] { -1 }); | |
173 testLongArray(new long[] { 1 }); | |
174 testLongArray(new long[] { 0, -1, 1 }); | |
175 testLongArray(new long[] { Long.MIN_VALUE }); | |
176 testLongArray(new long[] { Long.MAX_VALUE }); | |
177 testLongArray(new long[] { Long.MIN_VALUE, Long.MAX_VALUE }); | |
178 Random rand = new Random(); | |
179 long[] v = new long[100]; | |
180 for (int i = 0; i < v.length; ++i) { | |
181 v[i] = rand.nextLong(); | |
182 } | |
183 testLongArray(v); | |
184 } | |
185 | |
186 public void testLongArray(long[] v) throws Exception { | |
187 } | |
188 | |
189 public void testFloat() throws Exception { | |
190 testFloat((float) 0.0); | |
191 testFloat((float) -0.0); | |
192 testFloat((float) 1.0); | |
193 testFloat((float) -1.0); | |
194 testFloat(Float.MAX_VALUE); | |
195 testFloat(Float.MIN_VALUE); | |
196 testFloat(Float.NaN); | |
197 testFloat(Float.NEGATIVE_INFINITY); | |
198 testFloat(Float.POSITIVE_INFINITY); | |
199 Random rand = new Random(); | |
200 for (int i = 0; i < 1000; i++) { | |
201 testFloat(rand.nextFloat()); | |
202 } | |
203 } | |
204 | |
205 public void testFloat(float v) throws Exception { | |
206 } | |
207 | |
208 public void testFloatArray() throws Exception { | |
209 testFloatArray(null); | |
210 testFloatArray(new float[0]); | |
211 testFloatArray(new float[] { (float) 0.0 }); | |
212 testFloatArray(new float[] { (float) -0.0 }); | |
213 testFloatArray(new float[] { (float) -1.0 }); | |
214 testFloatArray(new float[] { (float) 1.0 }); | |
215 testFloatArray(new float[] { (float) 0.0, (float) -0.0, (float) -1.0, (float) 1.0 }); | |
216 testFloatArray(new float[] { Float.MAX_VALUE }); | |
217 testFloatArray(new float[] { Float.MIN_VALUE }); | |
218 testFloatArray(new float[] { Float.NaN }); | |
219 testFloatArray(new float[] { Float.NEGATIVE_INFINITY }); | |
220 testFloatArray(new float[] { Float.POSITIVE_INFINITY }); | |
221 testFloatArray(new float[] { Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }); | |
222 Random rand = new Random(); | |
223 float[] v = new float[100]; | |
224 for (int i = 0; i < v.length; ++i) { | |
225 v[i] = rand.nextFloat(); | |
226 } | |
227 testFloatArray(v); | |
228 } | |
229 | |
230 public void testFloatArray(float[] v) throws Exception { | |
231 } | |
232 | |
233 public void testDouble() throws Exception { | |
234 testDouble((double) 0.0); | |
235 testDouble((double) -0.0); | |
236 testDouble((double) 1.0); | |
237 testDouble((double) -1.0); | |
238 testDouble(Double.MAX_VALUE); | |
239 testDouble(Double.MIN_VALUE); | |
240 testDouble(Double.NaN); | |
241 testDouble(Double.NEGATIVE_INFINITY); | |
242 testDouble(Double.POSITIVE_INFINITY); | |
243 Random rand = new Random(); | |
244 for (int i = 0; i < 1000; i++) { | |
245 testDouble(rand.nextDouble()); | |
246 } | |
247 } | |
248 | |
249 public void testDouble(double v) throws Exception { | |
250 } | |
251 | |
252 public void testDoubleArray() throws Exception { | |
253 testDoubleArray(null); | |
254 testDoubleArray(new double[0]); | |
255 testDoubleArray(new double[] { (double) 0.0 }); | |
256 testDoubleArray(new double[] { (double) -0.0 }); | |
257 testDoubleArray(new double[] { (double) -1.0 }); | |
258 testDoubleArray(new double[] { (double) 1.0 }); | |
259 testDoubleArray(new double[] { (double) 0.0, (double) -0.0, (double) -1.0, (double) 1.0 }); | |
260 testDoubleArray(new double[] { Double.MAX_VALUE }); | |
261 testDoubleArray(new double[] { Double.MIN_VALUE }); | |
262 testDoubleArray(new double[] { Double.NaN }); | |
263 testDoubleArray(new double[] { Double.NEGATIVE_INFINITY }); | |
264 testDoubleArray(new double[] { Double.POSITIVE_INFINITY }); | |
265 testDoubleArray(new double[] { Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY }); | |
266 Random rand = new Random(); | |
267 double[] v = new double[100]; | |
268 for (int i = 0; i < v.length; ++i) { | |
269 v[i] = rand.nextDouble(); | |
270 } | |
271 testDoubleArray(v); | |
272 } | |
273 | |
274 public void testDoubleArray(double[] v) throws Exception { | |
275 } | |
276 | |
277 public void testNil() throws Exception { | |
278 } | |
279 | |
280 public void testString() throws Exception { | |
281 testString(null); | |
282 testString(""); | |
283 testString("a"); | |
284 testString("ab"); | |
285 testString("abc"); | |
286 StringBuilder sb; | |
287 int len; | |
288 // small size string | |
289 { | |
290 for (int i = 0; i < 100; i++) { | |
291 sb = new StringBuilder(); | |
292 len = (int) Math.random() % 31 + 1; | |
293 for (int j = 0; j < len; j++) { | |
294 sb.append('a' + ((int) Math.random()) & 26); | |
295 } | |
296 testString(sb.toString()); | |
297 } | |
298 } | |
299 // medium size string | |
300 { | |
301 for (int i = 0; i < 100; i++) { | |
302 sb = new StringBuilder(); | |
303 len = (int) Math.random() % 100 + (1 << 15); | |
304 for (int j = 0; j < len; j++) { | |
305 sb.append('a' + ((int) Math.random()) & 26); | |
306 } | |
307 testString(sb.toString()); | |
308 } | |
309 } | |
310 // large size string | |
311 { | |
312 for (int i = 0; i < 10; i++) { | |
313 sb = new StringBuilder(); | |
314 len = (int) Math.random() % 100 + (1 << 31); | |
315 for (int j = 0; j < len; j++) { | |
316 sb.append('a' + ((int) Math.random()) & 26); | |
317 } | |
318 testString(sb.toString()); | |
319 } | |
320 } | |
321 } | |
322 | |
323 public void testString(String v) throws Exception { | |
324 } | |
325 | |
326 public void testByteBuffer() throws Exception { | |
327 testByteBuffer(null); | |
328 Random rand = new Random(System.currentTimeMillis()); | |
329 byte[] b0 = new byte[0]; | |
330 testByteBuffer(ByteBuffer.wrap(b0)); | |
331 byte[] b1 = new byte[10]; | |
332 rand.nextBytes(b1); | |
333 testByteBuffer(ByteBuffer.wrap(b1)); | |
334 byte[] b2 = new byte[1024]; | |
335 rand.nextBytes(b2); | |
336 testByteBuffer(ByteBuffer.wrap(b2)); | |
337 } | |
338 | |
339 public void testByteBuffer(ByteBuffer v) throws Exception { | |
340 } | |
341 | |
342 public void testList() throws Exception { | |
343 testList(null, Integer.class); | |
344 List<Integer> list0 = new ArrayList<Integer>(); | |
345 testList(list0, Integer.class); | |
346 List<Integer> list1 = new ArrayList<Integer>(); | |
347 Random rand1 = new Random(); | |
348 for (int i = 0; i < 10; ++i) { | |
349 list1.add(rand1.nextInt()); | |
350 } | |
351 testList(list1, Integer.class); | |
352 List<String> list2 = new ArrayList<String>(); | |
353 Random rand2 = new Random(); | |
354 for (int i = 0; i < 100; ++i) { | |
355 list2.add("xx" + rand2.nextInt()); | |
356 } | |
357 testList(list2, String.class); | |
358 List<String> list3 = new ArrayList<String>(); | |
359 Random rand3 = new Random(); | |
360 for (int i = 0; i < 1000; ++i) { | |
361 list3.add("xx" + rand3.nextInt()); | |
362 } | |
363 testList(list3, String.class); | |
364 } | |
365 | |
366 public <E> void testList(List<E> v, Class<E> elementClass) throws Exception { | |
367 } | |
368 | |
369 public void testMap() throws Exception { | |
370 testMap(null, Integer.class, Integer.class); | |
371 Map<Integer, Integer> map0 = new HashMap<Integer, Integer>(); | |
372 testMap(map0, Integer.class, Integer.class); | |
373 Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(); | |
374 Random rand1 = new Random(); | |
375 for (int i = 0; i < 10; ++i) { | |
376 map1.put(rand1.nextInt(), rand1.nextInt()); | |
377 } | |
378 testMap(map1, Integer.class, Integer.class); | |
379 Map<String, Integer> map2 = new HashMap<String, Integer>(); | |
380 Random rand2 = new Random(); | |
381 for (int i = 0; i < 100; ++i) { | |
382 map2.put("xx" + rand2.nextInt(), rand2.nextInt()); | |
383 } | |
384 testMap(map2, String.class, Integer.class); | |
385 Map<String, Integer> map3 = new HashMap<String, Integer>(); | |
386 Random rand3= new Random(); | |
387 for (int i = 0; i < 1000; ++i) { | |
388 map3.put("xx" + rand3.nextInt(), rand3.nextInt()); | |
389 } | |
390 testMap(map3, String.class, Integer.class); | |
391 } | |
392 | |
393 public <K, V> void testMap(Map<K, V> v, Class<K> keyElementClass, Class<V> valueElementClass) throws Exception { | |
394 } | |
395 | |
396 public void testBigInteger() throws Exception { | |
397 testBigInteger(null); | |
398 testBigInteger(BigInteger.valueOf(0)); | |
399 testBigInteger(BigInteger.valueOf(-1)); | |
400 testBigInteger(BigInteger.valueOf(1)); | |
401 testBigInteger(BigInteger.valueOf(128l)); | |
402 testBigInteger(BigInteger.valueOf(512l)); | |
403 testBigInteger(BigInteger.valueOf(Integer.MIN_VALUE)); | |
404 testBigInteger(BigInteger.valueOf(Integer.MAX_VALUE)); | |
405 testBigInteger(BigInteger.valueOf(Long.MIN_VALUE)); | |
406 testBigInteger(BigInteger.valueOf(Long.MAX_VALUE)); | |
407 BigInteger max = BigInteger.valueOf(Long.MAX_VALUE).setBit(63); | |
408 testBigInteger(max); | |
409 Random rand = new Random(); | |
410 for (int i = 0; i < 1000; i++) { | |
411 testBigInteger(max.subtract(BigInteger.valueOf(Math.abs(rand.nextLong())))); | |
412 } | |
413 } | |
414 | |
415 public void testBigInteger(BigInteger v) throws Exception { | |
416 } | |
417 | |
418 public void testBigDecimal() throws Exception { | |
419 testBigDecimal(null); | |
420 testBigDecimal(BigDecimal.valueOf(0)); | |
421 testBigDecimal(BigDecimal.valueOf(-1)); | |
422 testBigDecimal(BigDecimal.valueOf(1)); | |
423 testBigDecimal(BigDecimal.valueOf(Integer.MIN_VALUE)); | |
424 testBigDecimal(BigDecimal.valueOf(Integer.MAX_VALUE)); | |
425 testBigDecimal(BigDecimal.valueOf(Long.MIN_VALUE)); | |
426 testBigDecimal(BigDecimal.valueOf(Long.MAX_VALUE)); | |
427 } | |
428 | |
429 public void testBigDecimal(BigDecimal v) throws Exception { | |
430 } | |
431 | |
432 public void testDate() throws Exception { | |
433 testDate(null); | |
434 Date d0 = new Date(); | |
435 testDate(d0); | |
436 } | |
437 | |
438 public void testDate(Date v) throws Exception { | |
439 } | |
440 | |
441 public void testCharacter() throws Exception { | |
442 testCharacter(null); | |
443 testCharacter('a'); | |
444 testCharacter('あ'); | |
445 testCharacter((char) 1); | |
446 testCharacter(Character.MIN_VALUE); | |
447 testCharacter(Character.MAX_VALUE); | |
448 } | |
449 | |
450 public void testCharacter(Character v) throws Exception { | |
451 } | |
452 | |
453 } |