Skip to content

Commit ba6c408

Browse files
author
John J. Aylward
committed
fixes stleary#531
Add test result to confirm that stleary#531 is working in latest version.
1 parent 9de9743 commit ba6c408

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/java/org/json/junit/JSONObjectTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
3535
import static org.mockito.Mockito.when;
3636

3737
import java.io.IOException;
38+
import java.io.Reader;
3839
import java.io.StringReader;
3940
import java.io.StringWriter;
4041
import java.math.BigDecimal;
@@ -55,6 +56,7 @@ of this software and associated documentation files (the "Software"), to deal
5556
import org.json.JSONException;
5657
import org.json.JSONObject;
5758
import org.json.JSONPointerException;
59+
import org.json.JSONTokener;
5860
import org.json.XML;
5961
import org.json.junit.data.BrokenToString;
6062
import org.json.junit.data.ExceptionalBean;
@@ -3079,6 +3081,19 @@ public void testWierdListBean() {
30793081
assertNotNull(jo.get("ALL"));
30803082
}
30813083

3084+
public void testObjectToBigDecimal() {
3085+
double value = 1412078745.01074;
3086+
Reader reader = new StringReader("[{\"value\": " + value + "}]");
3087+
JSONTokener tokener = new JSONTokener(reader);
3088+
JSONArray array = new JSONArray(tokener);
3089+
JSONObject jsonObject = array.getJSONObject(0);
3090+
3091+
BigDecimal current = jsonObject.getBigDecimal("value");
3092+
BigDecimal wantedValue = BigDecimal.valueOf(value);
3093+
3094+
assertEquals(current, wantedValue);
3095+
}
3096+
30823097
/**
30833098
* Tests the exception portions of populateMap.
30843099
*/

0 commit comments

Comments
 (0)