@@ -35,6 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
35
35
import static org .mockito .Mockito .when ;
36
36
37
37
import java .io .IOException ;
38
+ import java .io .Reader ;
38
39
import java .io .StringReader ;
39
40
import java .io .StringWriter ;
40
41
import java .math .BigDecimal ;
@@ -55,6 +56,7 @@ of this software and associated documentation files (the "Software"), to deal
55
56
import org .json .JSONException ;
56
57
import org .json .JSONObject ;
57
58
import org .json .JSONPointerException ;
59
+ import org .json .JSONTokener ;
58
60
import org .json .XML ;
59
61
import org .json .junit .data .BrokenToString ;
60
62
import org .json .junit .data .ExceptionalBean ;
@@ -3079,6 +3081,23 @@ public void testWierdListBean() {
3079
3081
assertNotNull (jo .get ("ALL" ));
3080
3082
}
3081
3083
3084
+ /**
3085
+ * Sample test case from https://github.com/stleary/JSON-java/issues/531
3086
+ * which verifies that no regression in double/BigDecimal support is present.
3087
+ */
3088
+ public void testObjectToBigDecimal () {
3089
+ double value = 1412078745.01074 ;
3090
+ Reader reader = new StringReader ("[{\" value\" : " + value + "}]" );
3091
+ JSONTokener tokener = new JSONTokener (reader );
3092
+ JSONArray array = new JSONArray (tokener );
3093
+ JSONObject jsonObject = array .getJSONObject (0 );
3094
+
3095
+ BigDecimal current = jsonObject .getBigDecimal ("value" );
3096
+ BigDecimal wantedValue = BigDecimal .valueOf (value );
3097
+
3098
+ assertEquals (current , wantedValue );
3099
+ }
3100
+
3082
3101
/**
3083
3102
* Tests the exception portions of populateMap.
3084
3103
*/
0 commit comments