6
6
import org .junit .jupiter .api .function .Executable ;
7
7
import org .junit .jupiter .params .ParameterizedTest ;
8
8
import org .junit .jupiter .params .provider .Arguments ;
9
- import org .junit .jupiter .params .provider .ArgumentsProvider ;
10
- import org .junit .jupiter .params .provider .ArgumentsSource ;
9
+ import org .junit .jupiter .params .provider .MethodSource ;
11
10
12
11
public class SpreadSortTest extends SortingAlgorithmTest {
13
12
@@ -20,16 +19,13 @@ SortAlgorithm getSortAlgorithm() {
20
19
return new SpreadSort ();
21
20
}
22
21
23
- static class ConstructorArgumentsProvider implements ArgumentsProvider {
24
- @ Override
25
- public Stream <? extends Arguments > provideArguments (org .junit .jupiter .api .extension .ExtensionContext context ) {
26
- return Stream .of (Arguments .of (0 , 16 , 2 , IllegalArgumentException .class ), Arguments .of (16 , 0 , 2 , IllegalArgumentException .class ), Arguments .of (16 , 16 , 0 , IllegalArgumentException .class ), Arguments .of (1001 , 16 , 2 , IllegalArgumentException .class ),
27
- Arguments .of (16 , 1001 , 2 , IllegalArgumentException .class ), Arguments .of (16 , 16 , 101 , IllegalArgumentException .class ));
28
- }
22
+ private static Stream <Arguments > wrongConstructorInputs () {
23
+ return Stream .of (Arguments .of (0 , 16 , 2 , IllegalArgumentException .class ), Arguments .of (16 , 0 , 2 , IllegalArgumentException .class ), Arguments .of (16 , 16 , 0 , IllegalArgumentException .class ), Arguments .of (1001 , 16 , 2 , IllegalArgumentException .class ),
24
+ Arguments .of (16 , 1001 , 2 , IllegalArgumentException .class ), Arguments .of (16 , 16 , 101 , IllegalArgumentException .class ));
29
25
}
30
26
31
27
@ ParameterizedTest
32
- @ ArgumentsSource ( ConstructorArgumentsProvider . class )
28
+ @ MethodSource ( "wrongConstructorInputs" )
33
29
void testConstructor (int insertionSortThreshold , int initialBucketCapacity , int minBuckets , Class <Exception > expectedException ) {
34
30
Executable executable = () -> new SpreadSort (insertionSortThreshold , initialBucketCapacity , minBuckets );
35
31
assertThrows (expectedException , executable );
0 commit comments