Skip to content

Commit 6bdd7d9

Browse files
committed
tests: express as ParameterizedTest
1 parent 4ee75ab commit 6bdd7d9

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
package com.thealgorithms.strings;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
3+
import java.util.stream.Stream;
4+
import org.junit.jupiter.api.Assertions;
55
import org.junit.jupiter.api.Test;
6+
import org.junit.jupiter.params.ParameterizedTest;
7+
import org.junit.jupiter.params.provider.Arguments;
8+
import org.junit.jupiter.params.provider.MethodSource;
69

710
public class ReverseWordsInStringTest {
8-
9-
@Test
10-
public void testCorrectReverseWordsInTheString() {
11-
assertEquals("blue is Sky", ReverseWordsInString.reverseWordsInString("Sky is blue"));
12-
}
13-
14-
@Test
15-
public void testCorrectReverseWordsInTheStringWithWhiteSpace() {
16-
assertEquals("blue is Sky", ReverseWordsInString.reverseWordsInString("Sky \n is \n \n blue"));
11+
@ParameterizedTest
12+
@MethodSource("inputStream")
13+
void numberTests(String expected, String input) {
14+
Assertions.assertEquals(expected, ReverseWordsInString.reverseWordsInString(input));
1715
}
1816

19-
@Test
20-
public void testReverseWordsInStringForEmpty() {
21-
assertEquals("", ReverseWordsInString.reverseWordsInString(""));
17+
private static Stream<Arguments> inputStream() {
18+
return Stream.of(Arguments.of("blue is Sky", "Sky is blue"), Arguments.of("blue is Sky", "Sky \n is \t \n blue "), Arguments.of("", ""), Arguments.of("", " "), Arguments.of("", "\t"));
2219
}
2320
}

0 commit comments

Comments
 (0)