1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07: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:
run2000 2016-07-25 09:44:43 +10:00 committed by GitHub
parent efe33a1e37
commit e57881f8fa

View file

@ -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.".