mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 16:00:51 -07:00
unittests for stlear/JSON-Java#233
This commit is contained in:
parent
adb3118d31
commit
a1893ebc02
2 changed files with 53 additions and 4 deletions
|
@ -1,15 +1,24 @@
|
|||
package org.json.junit;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONPointerException;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.jayway.jsonpath.*;
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -686,4 +695,19 @@ public class JSONArrayTest {
|
|||
new Long(-1).equals(Long.parseLong((String) it.next())));
|
||||
assertTrue("should be at end of array", !it.hasNext());
|
||||
}
|
||||
|
||||
@Test(expected = JSONPointerException.class)
|
||||
public void queryWithNoResult() {
|
||||
new JSONArray().query("/a/b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void optQueryWithNoResult() {
|
||||
assertNull(new JSONArray().optQuery("/a/b"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void optQueryWithSyntaxError() {
|
||||
new JSONArray().optQuery("invalid");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue