Skip to content

Commit 2784c61

Browse files
committed
ip
1 parent bef3707 commit 2784c61

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

JSONObjectTest.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ public void jsonObjectValues() {
182182
"\"trueStrKey\":\"true\","+
183183
"\"falseStrKey\":\"false\","+
184184
"\"stringKey\":\"hello world!\","+
185-
"\"complexStringKey\":\"h\be\tllo w\u1234orld!\","+
186185
"\"intKey\":42,"+
187186
"\"intStrKey\":\"43\","+
188187
"\"longKey\":1234567890123456789,"+
@@ -233,4 +232,42 @@ public void jsonObjectNames() {
233232
Util.compareActualVsExpectedStringArrays(names, expectedNames);
234233
}
235234

235+
@Test
236+
public void objectNames() {
237+
MyBean myBean = new MyBean();
238+
String [] expectedNames = {"intKey", "doubleKey", "stringKey",
239+
"complexStringKey", "trueKey", "falseKey"};
240+
String [] names = JSONObject.getNames(myBean);
241+
Util.compareActualVsExpectedStringArrays(names, expectedNames);
242+
}
243+
244+
@Test
245+
public void jsonObjectIncrement() {
246+
String str =
247+
"{"+
248+
"\"keyLong\":1L,"+
249+
"\"keyDouble\":1.1,"+
250+
"\"keyFloat\":1.1F,"+
251+
"}";
252+
String expectedStr =
253+
"{"+
254+
"\"keyInt\":3,"+
255+
"\"keyLong\":3,"+
256+
"\"keyDouble\":3.1,"+
257+
"\"keyFloat\":3.1"+
258+
"}";
259+
JSONObject jsonObject = new JSONObject(str);
260+
jsonObject.increment("keyInt");
261+
jsonObject.increment("keyInt");
262+
jsonObject.increment("keyLong");
263+
jsonObject.increment("keyDouble");
264+
jsonObject.increment("keyFloat");
265+
jsonObject.increment("keyInt");
266+
jsonObject.increment("keyLong");
267+
jsonObject.increment("keyDouble");
268+
jsonObject.increment("keyFloat");
269+
JSONObject expectedJsonObject = new JSONObject(expectedStr);
270+
Util.compareActualVsExpectedJsonObjects(jsonObject, expectedJsonObject);
271+
}
272+
236273
}

0 commit comments

Comments
 (0)