@@ -35,6 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
3535import static org .mockito .Mockito .when ;
3636
3737import java .io .IOException ;
38+ import java .io .Reader ;
3839import java .io .StringReader ;
3940import java .io .StringWriter ;
4041import java .math .BigDecimal ;
@@ -55,6 +56,7 @@ of this software and associated documentation files (the "Software"), to deal
5556import org .json .JSONException ;
5657import org .json .JSONObject ;
5758import org .json .JSONPointerException ;
59+ import org .json .JSONTokener ;
5860import org .json .XML ;
5961import org .json .junit .data .BrokenToString ;
6062import 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