mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
ip
This commit is contained in:
parent
bef37079dc
commit
2784c614d4
1 changed files with 38 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue