mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Fix tabs, add valueToString() test to JSONObjectTest
This commit is contained in:
parent
6406c7a379
commit
38cbc31624
2 changed files with 202 additions and 183 deletions
|
@ -1471,6 +1471,25 @@ public class JSONObjectTest {
|
|||
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
|
||||
* the object being wrapped, other times not. The purpose of wrap() is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue