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(); jsonStringer.object().endObject();
try { try {
jsonStringer.array(); jsonStringer.array();
assertTrue("Expected an exception", false);
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expected an exception message", assertTrue("Expected an exception message",
"Misplaced array.". "Misplaced array.".
@ -77,6 +78,7 @@ public class JSONStringerTest {
jsonStringer.object(); jsonStringer.object();
try { try {
jsonStringer.endArray(); jsonStringer.endArray();
assertTrue("Expected an exception", false);
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expected an exception message", assertTrue("Expected an exception message",
"Misplaced endArray.". "Misplaced endArray.".
@ -94,6 +96,7 @@ public class JSONStringerTest {
jsonStringer.array(); jsonStringer.array();
try { try {
jsonStringer.endObject(); jsonStringer.endObject();
assertTrue("Expected an exception", false);
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expected an exception message", assertTrue("Expected an exception message",
"Misplaced endObject.". "Misplaced endObject.".
@ -111,6 +114,7 @@ public class JSONStringerTest {
jsonStringer.object().endObject(); jsonStringer.object().endObject();
try { try {
jsonStringer.object(); jsonStringer.object();
assertTrue("Expected an exception", false);
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expected an exception message", assertTrue("Expected an exception message",
"Misplaced object.". "Misplaced object.".