Skip to content

Commit 1f4e836

Browse files
committed
few more enum support tests
1 parent 8ac8c34 commit 1f4e836

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

EnumTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ public void enumAPI() {
268268
actualEnum = jsonObject.optEnum(MyEnumField.class, "strKey", null);
269269
assertTrue("opt null", actualEnum == null);
270270

271+
// opt with default an index that does not exist
272+
actualEnum = jsonObject.optEnum(MyEnumField.class, "noKey", null);
273+
assertTrue("opt null", actualEnum == null);
274+
271275
/**
272276
* Exercise the proposed enum API methods on JSONArray
273277
*/
@@ -309,5 +313,10 @@ public void enumAPI() {
309313
// opt with default the wrong value
310314
actualEnum = jsonArray.optEnum(MyEnumField.class, 0, null);
311315
assertTrue("opt null", actualEnum == null);
316+
317+
// opt with default an index that does not exist
318+
actualEnum = jsonArray.optEnum(MyEnumField.class, 3, null);
319+
assertTrue("opt null", actualEnum == null);
320+
312321
}
313322
}

0 commit comments

Comments
 (0)