-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathAllConstructTest.java
40 lines (33 loc) · 1.45 KB
/
AllConstructTest.java
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
38
39
40
package com.thealgorithms.dynamicprogramming;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class AllConstructTest {
@Test
public void testAllConstructBasic() {
List<List<String>> expected = singletonList(Arrays.asList("he", "l", "l", "o"));
List<List<String>> result = AllConstruct.allConstruct("hello", Arrays.asList("he", "l", "o"));
assertEquals(expected, result);
}
@Test
public void testAllConstructMultipleWays() {
List<List<String>> expected = Arrays.asList(Arrays.asList("purp", "le"), Arrays.asList("p", "ur", "p", "le"));
List<List<String>> result = AllConstruct.allConstruct("purple", Arrays.asList("purp", "p", "ur", "le", "purpl"));
assertEquals(expected, result);
}
@Test
public void testAllConstructNoWays() {
List<List<String>> expected = emptyList();
List<List<String>> result = AllConstruct.allConstruct("abcdef", Arrays.asList("gh", "ijk"));
assertEquals(expected, result);
}
@Test
public void testAllConstructEmptyTarget() {
List<List<String>> expected = singletonList(emptyList());
List<List<String>> result = AllConstruct.allConstruct("", Arrays.asList("a", "b", "c"));
assertEquals(expected, result);
}
}