66import org .junit .jupiter .api .function .Executable ;
77import org .junit .jupiter .params .ParameterizedTest ;
88import 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 ;
1110
1211public class SpreadSortTest extends SortingAlgorithmTest {
1312
@@ -20,16 +19,13 @@ SortAlgorithm getSortAlgorithm() {
2019 return new SpreadSort ();
2120 }
2221
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 ));
2925 }
3026
3127 @ ParameterizedTest
32- @ ArgumentsSource ( ConstructorArgumentsProvider . class )
28+ @ MethodSource ( "wrongConstructorInputs" )
3329 void testConstructor (int insertionSortThreshold , int initialBucketCapacity , int minBuckets , Class <Exception > expectedException ) {
3430 Executable executable = () -> new SpreadSort (insertionSortThreshold , initialBucketCapacity , minBuckets );
3531 assertThrows (expectedException , executable );
0 commit comments