mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
Fail when exceptions are not thrown as expected
The idiom was started in the first few methods, but not continued further down where JSONException was expected. False success may have resulted.
This commit is contained in:
parent
efe33a1e37
commit
e57881f8fa
@ -60,6 +60,7 @@ public class JSONStringerTest {
|
||||
jsonStringer.object().endObject();
|
||||
try {
|
||||
jsonStringer.array();
|
||||
assertTrue("Expected an exception", false);
|
||||
} catch (JSONException e) {
|
||||
assertTrue("Expected an exception message",
|
||||
"Misplaced array.".
|
||||
@ -77,6 +78,7 @@ public class JSONStringerTest {
|
||||
jsonStringer.object();
|
||||
try {
|
||||
jsonStringer.endArray();
|
||||
assertTrue("Expected an exception", false);
|
||||
} catch (JSONException e) {
|
||||
assertTrue("Expected an exception message",
|
||||
"Misplaced endArray.".
|
||||
@ -94,6 +96,7 @@ public class JSONStringerTest {
|
||||
jsonStringer.array();
|
||||
try {
|
||||
jsonStringer.endObject();
|
||||
assertTrue("Expected an exception", false);
|
||||
} catch (JSONException e) {
|
||||
assertTrue("Expected an exception message",
|
||||
"Misplaced endObject.".
|
||||
@ -111,6 +114,7 @@ public class JSONStringerTest {
|
||||
jsonStringer.object().endObject();
|
||||
try {
|
||||
jsonStringer.object();
|
||||
assertTrue("Expected an exception", false);
|
||||
} catch (JSONException e) {
|
||||
assertTrue("Expected an exception message",
|
||||
"Misplaced object.".
|
||||
|
Loading…
x
Reference in New Issue
Block a user