-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolutionTest.java
More file actions
37 lines (32 loc) · 1.24 KB
/
SolutionTest.java
File metadata and controls
37 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package group_anagrams;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
class SolutionTest {
private static Stream<Object[]> provideGroupAnagramsTestCases() {
return Stream.of(
new Object[]{List.of("eat", "tea", "ate", "bat", "tan", "nat"),
new ArrayList<>(List.of(
List.of("eat", "tea", "ate"),
List.of("bat"),
List.of("tan", "nat")
))},
new Object[]{List.of("a"),
new ArrayList<>(List.of(
List.of("a")
))},
new Object[]{List.of(""),
new ArrayList<>(List.of(
List.of("")
))}
);
}
@ParameterizedTest
@MethodSource("provideGroupAnagramsTestCases")
void groupAnagrams(List<String> input, List<List<String>> expected) {
Assertions.assertEquals(expected, Solution.groupAnagrams(input));
}
}