Skip to content

Commit 5de3d70

Browse files
committed
Try-catch blocks in OrderStatistic* test suites not nested
1 parent bd20257 commit 5de3d70

File tree

2 files changed

+78
-64
lines changed

2 files changed

+78
-64
lines changed

src/org/sosy_lab/common/collect/OrderStatisticMapTestSuite.java

+42-35
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,20 @@ public void testSubmapView_outOfBounds_add() {
177177
putEntry(subMap, ELEMS.get(0));
178178
fail();
179179
} catch (IllegalArgumentException expected) {
180-
try {
181-
putEntry(subMap, ELEMS.get(3));
182-
fail();
183-
} catch (IllegalArgumentException expected2) {
184-
try {
185-
// the first 3 elements are in the range of the sublist, but the last isn't
186-
subMap.putAll(toAdd);
187-
fail();
188-
} catch (IllegalArgumentException expected3) {
189-
// expected outcome
190-
}
191-
}
180+
// expected outcome
181+
}
182+
try {
183+
putEntry(subMap, ELEMS.get(3));
184+
fail();
185+
} catch (IllegalArgumentException expected) {
186+
// expected outcome
187+
}
188+
try {
189+
// the first 3 elements are in the range of the sublist, but the last isn't
190+
subMap.putAll(toAdd);
191+
fail();
192+
} catch (IllegalArgumentException expected) {
193+
// expected outcome
192194
}
193195
}
194196

@@ -326,12 +328,13 @@ public void testGetEntryByRank_outOfBounds() {
326328
map.getEntryByRank(-1);
327329
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
328330
} catch (IndexOutOfBoundsException expected) {
329-
try {
330-
map.getEntryByRank(ELEMS.size());
331-
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
332-
} catch (IndexOutOfBoundsException expected2) {
333-
// expected outcome
334-
}
331+
// expected outcome
332+
}
333+
try {
334+
map.getEntryByRank(ELEMS.size());
335+
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
336+
} catch (IndexOutOfBoundsException expected) {
337+
// expected outcome
335338
}
336339
}
337340

@@ -413,12 +416,13 @@ public void testGetKeyByRank_outOfBounds() {
413416
map.getKeyByRank(-1);
414417
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
415418
} catch (IndexOutOfBoundsException expected) {
416-
try {
417-
map.getKeyByRank(ELEMS.size());
418-
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
419-
} catch (IndexOutOfBoundsException expected2) {
420-
// expected outcome
421-
}
419+
// expected outcome
420+
}
421+
try {
422+
map.getKeyByRank(ELEMS.size());
423+
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
424+
} catch (IndexOutOfBoundsException expected) {
425+
// expected outcome
422426
}
423427
}
424428

@@ -518,17 +522,20 @@ public void testRemoveByRank_invalid() {
518522
map.removeByRank(-1);
519523
fail();
520524
} catch (IndexOutOfBoundsException expected) {
521-
try {
522-
map.removeByRank(map.size());
523-
fail();
524-
} catch (IndexOutOfBoundsException expected2) {
525-
try {
526-
emptyMap.removeByRank(0);
527-
fail();
528-
} catch (IndexOutOfBoundsException expected3) {
529-
// expected outcome
530-
}
531-
}
525+
// expected outcome
526+
}
527+
try {
528+
map.removeByRank(map.size());
529+
fail();
530+
} catch (IndexOutOfBoundsException expected) {
531+
// expected outcome
532+
}
533+
try {
534+
emptyMap.removeByRank(0);
535+
fail();
536+
} catch (IndexOutOfBoundsException expected) {
537+
// expected outcome
538+
532539
}
533540
}
534541

src/org/sosy_lab/common/collect/OrderStatisticSetTestSuite.java

+36-29
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,22 @@ public void testSubsetView_outOfBounds_add() {
122122
subSet.add(ELEMS[0]);
123123
fail();
124124
} catch (IllegalArgumentException expected) {
125-
try {
126-
subSet.add(ELEMS[3]);
127-
fail();
128-
} catch (IllegalArgumentException expected2) {
129-
try {
130-
// the first 3 elements are in the range of the sublist, but the last isn't
131-
subSet.addAll(toAdd);
132-
fail();
133-
} catch (IllegalArgumentException expected3) {
134-
// expected outcome
135-
}
136-
}
125+
// expected outcome
126+
}
127+
128+
try {
129+
subSet.add(ELEMS[3]);
130+
fail();
131+
} catch (IllegalArgumentException expected) {
132+
// expected outcome
133+
}
134+
135+
try {
136+
// the first 3 elements are in the range of the sublist, but the last isn't
137+
subSet.addAll(toAdd);
138+
fail();
139+
} catch (IllegalArgumentException expected) {
140+
// expected outcome
137141
}
138142
}
139143

@@ -240,12 +244,13 @@ public void testGetByRank_outOfBounds() {
240244
set.getByRank(-1);
241245
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
242246
} catch (IndexOutOfBoundsException expected) {
243-
try {
244-
set.getByRank(ELEMS.length);
245-
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
246-
} catch (IndexOutOfBoundsException expected2) {
247-
// this is expected
248-
}
247+
// expected outcome
248+
}
249+
try {
250+
set.getByRank(ELEMS.length);
251+
fail("Expected " + IndexOutOfBoundsException.class.getSimpleName());
252+
} catch (IndexOutOfBoundsException expected) {
253+
// expected outcome
249254
}
250255
}
251256

@@ -335,17 +340,19 @@ public void testRemoveByRank_invalid() {
335340
set.removeByRank(-1);
336341
fail();
337342
} catch (IndexOutOfBoundsException expected) {
338-
try {
339-
set.removeByRank(set.size());
340-
fail();
341-
} catch (IndexOutOfBoundsException expected2) {
342-
try {
343-
emptySet.removeByRank(0);
344-
fail();
345-
} catch (IndexOutOfBoundsException expected3) {
346-
// expected outcome
347-
}
348-
}
343+
// expected outcome
344+
}
345+
try {
346+
set.removeByRank(set.size());
347+
fail();
348+
} catch (IndexOutOfBoundsException expected) {
349+
// expected outcome
350+
}
351+
try {
352+
emptySet.removeByRank(0);
353+
fail();
354+
} catch (IndexOutOfBoundsException expected) {
355+
// expected outcome
349356
}
350357
}
351358

0 commit comments

Comments
 (0)