MCPcopy Create free account
hub / github.com/ReadyTalk/avian / testIterators

Method testIterators

test/EnumSetTest.java:66–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64 }
65
66 private static void testIterators() {
67 EnumSet<SmallEnum> set = EnumSet.allOf(SmallEnum.class);
68 Iterator<SmallEnum> iterator = set.iterator();
69 boolean exceptionCaught = false;
70 try {
71 iterator.remove();
72 } catch (IllegalStateException e) {
73 exceptionCaught = true;
74 }
75 if (!exceptionCaught) {
76 throw new RuntimeException("Calling remove() before next() should throw IllegalStateException");
77 }
78
79 while (iterator.hasNext()) {
80 iterator.next();
81 iterator.remove();
82 }
83 assertSize(0, set);
84
85 exceptionCaught = false;
86 try {
87 iterator.next();
88 } catch (NoSuchElementException e) {
89 exceptionCaught = true;
90 }
91 if (!exceptionCaught) {
92 throw new RuntimeException("Calling next() when hasNext() == false should throw NoSuchElementException");
93 }
94 }
95
96 private static void assertElementInSet(Enum<?> element, EnumSet<?> set) {
97 if (!set.contains(element)) {

Callers 1

mainMethod · 0.95

Calls 6

allOfMethod · 0.95
assertSizeMethod · 0.95
iteratorMethod · 0.65
removeMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected