Skip to content

Commit 582b0ab

Browse files
Copilotlaeubi
andcommitted
Simplify assertThrows usage following pattern from PR #2579
Co-authored-by: laeubi <[email protected]>
1 parent 643d21f commit 582b0ab

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_BidiSegmentListener.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,13 @@ private void testListener(final int[] segments, boolean exceptionExpected) {
5959
};
6060

6161
listenerCalled = false;
62+
text.addBidiSegmentListener(listener);
6263
if (exceptionExpected) {
63-
assertThrows(IllegalArgumentException.class, () -> {
64-
text.addBidiSegmentListener(listener);
65-
try {
66-
text.getLocationAtOffset(0);
67-
} finally {
68-
text.removeBidiSegmentListener(listener);
69-
}
70-
}, " expected exception not thrown");
64+
assertThrows(IllegalArgumentException.class, () -> text.getLocationAtOffset(0), " expected exception not thrown");
7165
} else {
72-
text.addBidiSegmentListener(listener);
73-
try {
74-
text.getLocationAtOffset(0);
75-
} finally {
76-
text.removeBidiSegmentListener(listener);
77-
}
66+
text.getLocationAtOffset(0);
7867
}
68+
text.removeBidiSegmentListener(listener);
7969
if (SwtTestUtil.isBidi()) {
8070
assertTrue(listenerCalled, " listener not called");
8171
} else {

0 commit comments

Comments
 (0)