mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 16:00:51 -07:00
Merge pull request #30 from stleary/confirmValueToStringFix
Fix tabs, add valueToString() test to JSONObjectTest
This commit is contained in:
commit
c578216844
2 changed files with 202 additions and 183 deletions
|
@ -1471,6 +1471,25 @@ public class JSONObjectTest {
|
||||||
jsonArray.toString().equals(JSONObject.valueToString(array)));
|
jsonArray.toString().equals(JSONObject.valueToString(array)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm that https://github.com/douglascrockford/JSON-java/issues/167 is fixed.
|
||||||
|
* The following code was throwing a ClassCastException in the
|
||||||
|
* JSONObject(Map<String, Object>) constructor
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void valueToStringConfirmException() {
|
||||||
|
String expectedStr = "{\"1\":\"myValue\"}";
|
||||||
|
Map<Integer, String> myMap = new HashMap<Integer, String>();
|
||||||
|
myMap.put(1, "myValue");
|
||||||
|
// this is the test, it should not throw an exception
|
||||||
|
String str = JSONObject.valueToString(myMap);
|
||||||
|
// confirm result, just in case
|
||||||
|
JSONObject jsonObject = new JSONObject(str);
|
||||||
|
JSONObject expectedJsonObject = new JSONObject(expectedStr);
|
||||||
|
Util.compareActualVsExpectedJsonObjects(jsonObject,
|
||||||
|
expectedJsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exercise the JSONObject wrap() method. Sometimes wrap() will change
|
* Exercise the JSONObject wrap() method. Sometimes wrap() will change
|
||||||
* the object being wrapped, other times not. The purpose of wrap() is
|
* the object being wrapped, other times not. The purpose of wrap() is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue