forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBug_7.java
More file actions
executable file
·55 lines (44 loc) · 1.84 KB
/
Copy pathBug_7.java
File metadata and controls
executable file
·55 lines (44 loc) · 1.84 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
package com.alibaba.json.bvt.bug;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
import java.util.concurrent.atomic.AtomicLongArray;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
public class Bug_7 extends TestCase {
public void test_floatArray() throws Exception {
float[] a = new float[] { 1, 2 };
String text = JSON.toJSONString(a);
JSON json = (JSON) JSON.parse(text);
Assert.assertEquals("[1.0,2.0]", json.toJSONString());
}
public void test_doubleArray() throws Exception {
double[] a = new double[] { 1, 2 };
String text = JSON.toJSONString(a);
JSON json = (JSON) JSON.parse(text);
Assert.assertEquals("[1.0,2.0]", json.toJSONString());
}
public void test_bigintegerArray() throws Exception {
BigInteger[] a = new BigInteger[] { new BigInteger("214748364812"), new BigInteger("2147483648123") };
String text = JSON.toJSONString(a);
Assert.assertEquals("[214748364812,2147483648123]", text);
JSON json = (JSON) JSON.parse(text);
Assert.assertEquals("[214748364812,2147483648123]", json.toJSONString());
}
public void test_AtomicIntegerArray() throws Exception {
AtomicIntegerArray array = new AtomicIntegerArray(3);
array.set(0, 1);
array.set(1, 2);
array.set(2, 3);
String text = JSON.toJSONString(array);
Assert.assertEquals("[1,2,3]", text);
}
public void test_AtomicLongArray() throws Exception {
AtomicLongArray array = new AtomicLongArray(3);
array.set(0, 1);
array.set(1, 2);
array.set(2, 3);
String text = JSON.toJSONString(array);
Assert.assertEquals("[1,2,3]", text);
}
}