1
1
/*******************************************************************************
2
- * Copyright (c) 2000, 2016 Red Hat, Inc. and others.
2
+ * Copyright (c) 2000, 2025 Red Hat, Inc. and others.
3
3
*
4
4
* This program and the accompanying materials
5
5
* are made available under the terms of the Eclipse Public License 2.0
15
15
package org .eclipse .swt .tests .junit ;
16
16
17
17
import static org .junit .Assert .assertEquals ;
18
- import static org .junit .Assert .fail ;
18
+ import static org .junit .Assert .assertThrows ;
19
19
20
20
import org .eclipse .swt .SWT ;
21
21
import org .eclipse .swt .widgets .Spinner ;
@@ -37,23 +37,13 @@ public void setUp() {
37
37
@ Override
38
38
@ Test
39
39
public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI () {
40
- try {
41
- spinner = new Spinner (null , 0 );
42
- fail ("No exception thrown for parent == null" );
43
- }
44
- catch (IllegalArgumentException e ) {
45
- }
46
- int [] cases = {0 , SWT .READ_ONLY , SWT .WRAP };
40
+ assertThrows ("No exception thrown for parent == null" , IllegalArgumentException .class ,
41
+ () -> new Spinner (null , 0 ));
42
+ int [] cases = { 0 , SWT .READ_ONLY , SWT .WRAP };
47
43
for (int style : cases )
48
44
spinner = new Spinner (shell , style );
49
45
}
50
46
51
- @ Override
52
- @ Test
53
- public void test_computeSizeIIZ () {
54
- // super class test is sufficient
55
- }
56
-
57
47
@ Test
58
48
public void test_getIncrement () {
59
49
int [] cases = {5 ,100 ,1000 ,1 };
@@ -72,13 +62,9 @@ public void test_getDigits() {
72
62
spinner .setDigits (digits );
73
63
assertEquals (digits , spinner .getDigits ());
74
64
}
75
- try {
76
- spinner .setDigits (-1 );
77
- fail ("setDigits should have failed with illegal Argument" );
78
- }
79
- catch (IllegalArgumentException e ){
80
- assertEquals (cases [cases .length -1 ], spinner .getDigits ());
81
- }
65
+ assertThrows ("setDigits should have failed with illegal Argument" , IllegalArgumentException .class ,
66
+ () -> spinner .setDigits (-1 ));
67
+ assertEquals (cases [cases .length -1 ], spinner .getDigits ());
82
68
}
83
69
84
70
@ Test
@@ -132,11 +118,8 @@ public void test_getTextLimit() {
132
118
spinner .setTextLimit (value );
133
119
assertEquals (value , spinner .getTextLimit ());
134
120
}
135
- try {
136
- spinner .setTextLimit (0 );
137
- fail ("setTextLimit should have caused an expection with value 0" );
138
- } catch (Exception e ) {
139
- }
121
+ assertThrows ("setTextLimit should have caused an expection with value 0" , IllegalArgumentException .class ,
122
+ () -> spinner .setTextLimit (0 ));
140
123
}
141
124
142
125
@ Test
0 commit comments