@@ -1276,7 +1276,7 @@ public void jsonObjectIncrement() {
12761276 * JSONObject constructor won't handle these types correctly, but
12771277 * adding them via put works.
12781278 */
1279- jsonObject .put ("keyFloat" , new Float ( 1.1 ) );
1279+ jsonObject .put ("keyFloat" , 1.1f );
12801280 jsonObject .put ("keyBigInt" , new BigInteger ("123456789123456789123456789123456780" ));
12811281 jsonObject .put ("keyBigDec" , new BigDecimal ("123456789123456789123456789123456780.1" ));
12821282 jsonObject .increment ("keyFloat" );
@@ -1316,7 +1316,7 @@ public void jsonObjectIncrement() {
13161316 * missing bits would not fit into the 32 bit float, i.e. the
13171317 * information needed simply is not there!
13181318 */
1319- assertTrue ( "expected 3.0999999046325684" , Double . valueOf (3.0999999046325684 ). equals ( jsonObject .query ("/keyFloat" ) ));
1319+ assertEquals ( Float . valueOf (3.1f ), jsonObject .query ("/keyFloat" ));
13201320
13211321 /**
13221322 * float f = 3.1f; double df = (double) f; double d = 3.1d;
@@ -1364,7 +1364,7 @@ public void jsonObjectIncrement() {
13641364 // 3. A float+float operation will be performed and results into a float primitive.
13651365 // 4. There is no method that matches the signature put( String key, float value), java-compiler will choose the method
13661366 // put( String key, double value) and does an implicit type-cast(!) by appending zero-bits to the mantissa
1367- assertTrue ( "JSONObject increment converts Float to Double" , jo .get ( "bug" ) instanceof Double );
1367+ assertTrue ( "JSONObject increment converts Float to Double" , jo .get ( "bug" ) instanceof Float );
13681368 // correct implementation (with change of behavior) would be:
13691369 // this.put(key, new Float((Float) value + 1));
13701370 // Probably it would be better to deprecate the method and remove some day, while convenient processing the "payload" is not
0 commit comments