Skip to content

Commit

Permalink
Fail when exceptions are not thrown as expected
Browse files Browse the repository at this point in the history
The idiom was started in the first few methods, but not continued further down where JSONException was expected. False success may have resulted.
  • Loading branch information
run2000 authored Jul 24, 2016
1 parent efe33a1 commit e57881f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/test/java/org/json/junit/JSONStringerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void missplacedArrayException() {
jsonStringer.object().endObject();
try {
jsonStringer.array();
assertTrue("Expected an exception", false);
} catch (JSONException e) {
assertTrue("Expected an exception message",
"Misplaced array.".
Expand All @@ -77,6 +78,7 @@ public void missplacedEndArrayException() {
jsonStringer.object();
try {
jsonStringer.endArray();
assertTrue("Expected an exception", false);
} catch (JSONException e) {
assertTrue("Expected an exception message",
"Misplaced endArray.".
Expand All @@ -94,6 +96,7 @@ public void missplacedEndObjectException() {
jsonStringer.array();
try {
jsonStringer.endObject();
assertTrue("Expected an exception", false);
} catch (JSONException e) {
assertTrue("Expected an exception message",
"Misplaced endObject.".
Expand All @@ -111,6 +114,7 @@ public void missplacedObjectException() {
jsonStringer.object().endObject();
try {
jsonStringer.object();
assertTrue("Expected an exception", false);
} catch (JSONException e) {
assertTrue("Expected an exception message",
"Misplaced object.".
Expand Down

0 comments on commit e57881f

Please sign in to comment.