mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-06 10:45:23 +08:00
chore: initial unit tests
This commit is contained in:
@@ -135,6 +135,14 @@ public class JSONPointerTest {
|
||||
assertEquals(6, query("/k\"l"));
|
||||
}
|
||||
|
||||
/**
|
||||
* KD Added
|
||||
* */
|
||||
@Test
|
||||
public void quotationEscaping() {
|
||||
assertEquals(document.get("k\"l"), query("/k\\\"l"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whitespaceKey() {
|
||||
assertEquals(7, query("/ "));
|
||||
@@ -389,4 +397,33 @@ public class JSONPointerTest {
|
||||
obj = jsonArray.optQuery(new JSONPointer("/a/b/c"));
|
||||
assertTrue("Expected null", obj == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* KD added
|
||||
* Coverage for JSONObject query(JSONPointer)
|
||||
*/
|
||||
@Test
|
||||
public void queryFromJSONObjectUsingPointer2() {
|
||||
String str = "{"+
|
||||
"\"string\\\\\\\\Key\":\"hello world!\","+
|
||||
"}"+
|
||||
"}";
|
||||
JSONObject jsonObject = new JSONObject(str);
|
||||
Object obj = jsonObject.optQuery(new JSONPointer("/string\\\\\\\\Key"));
|
||||
assertTrue("Expected 'hello world!'", "hello world!".equals(obj));
|
||||
}
|
||||
/**
|
||||
* KD added - understanding behavior
|
||||
* Coverage for JSONObject query(JSONPointer)
|
||||
*/
|
||||
@Test
|
||||
public void queryFromJSONObjectUsingPointer0() {
|
||||
String str = "{"+
|
||||
"\"string\\\\Key\":\"hello world!\","+
|
||||
"}"+
|
||||
"}";
|
||||
JSONObject jsonObject = new JSONObject(str);
|
||||
Object obj = jsonObject.optQuery(new JSONPointer("/string\\Key"));
|
||||
assertTrue("Expected 'hello world!'", "hello world!".equals(obj));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user