mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
chore: initial unit tests
This commit is contained in:
parent
93f4b34890
commit
30a70c8886
@ -134,6 +134,14 @@ public class JSONPointerTest {
|
||||
public void quotationHandling() {
|
||||
assertEquals(6, query("/k\"l"));
|
||||
}
|
||||
|
||||
/**
|
||||
* KD Added
|
||||
* */
|
||||
@Test
|
||||
public void quotationEscaping() {
|
||||
assertEquals(document.get("k\"l"), query("/k\\\"l"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whitespaceKey() {
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user