From 2784c614d4bd6ee8c5810417c3de39d39ddda8da Mon Sep 17 00:00:00 2001 From: stleary Date: Fri, 10 Apr 2015 08:21:09 -0500 Subject: [PATCH] ip --- JSONObjectTest.java | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/JSONObjectTest.java b/JSONObjectTest.java index aa434ea..a46dc8b 100644 --- a/JSONObjectTest.java +++ b/JSONObjectTest.java @@ -182,7 +182,6 @@ public class JSONObjectTest { "\"trueStrKey\":\"true\","+ "\"falseStrKey\":\"false\","+ "\"stringKey\":\"hello world!\","+ - "\"complexStringKey\":\"h\be\tllo w\u1234orld!\","+ "\"intKey\":42,"+ "\"intStrKey\":\"43\","+ "\"longKey\":1234567890123456789,"+ @@ -233,4 +232,42 @@ public class JSONObjectTest { Util.compareActualVsExpectedStringArrays(names, expectedNames); } + @Test + public void objectNames() { + MyBean myBean = new MyBean(); + String [] expectedNames = {"intKey", "doubleKey", "stringKey", + "complexStringKey", "trueKey", "falseKey"}; + String [] names = JSONObject.getNames(myBean); + Util.compareActualVsExpectedStringArrays(names, expectedNames); + } + + @Test + public void jsonObjectIncrement() { + String str = + "{"+ + "\"keyLong\":1L,"+ + "\"keyDouble\":1.1,"+ + "\"keyFloat\":1.1F,"+ + "}"; + String expectedStr = + "{"+ + "\"keyInt\":3,"+ + "\"keyLong\":3,"+ + "\"keyDouble\":3.1,"+ + "\"keyFloat\":3.1"+ + "}"; + JSONObject jsonObject = new JSONObject(str); + jsonObject.increment("keyInt"); + jsonObject.increment("keyInt"); + jsonObject.increment("keyLong"); + jsonObject.increment("keyDouble"); + jsonObject.increment("keyFloat"); + jsonObject.increment("keyInt"); + jsonObject.increment("keyLong"); + jsonObject.increment("keyDouble"); + jsonObject.increment("keyFloat"); + JSONObject expectedJsonObject = new JSONObject(expectedStr); + Util.compareActualVsExpectedJsonObjects(jsonObject, expectedJsonObject); + } + }