1
1
package com .thealgorithms .backtracking ;
2
2
3
- import org .junit .jupiter .api .Test ;
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+ import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
4
5
5
6
import java .util .ArrayList ;
6
7
import java .util .List ;
7
- import static org .junit .jupiter .api .Assertions .assertEquals ;
8
- import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
8
+ import org .junit .jupiter .api .Test ;
9
9
10
10
public class SubsequenceTest {
11
11
@@ -18,43 +18,22 @@ void testNoElement() {
18
18
19
19
@ Test
20
20
void testLengthOfTwo () {
21
- List <List <Integer >> expected = List .of (
22
- List .of (),
23
- List .of (2 ),
24
- List .of (1 ),
25
- List .of (1 , 2 )
26
- );
21
+ List <List <Integer >> expected = List .of (List .of (), List .of (2 ), List .of (1 ), List .of (1 , 2 ));
27
22
List <List <Object >> actual = Subsequence .generateAllSubsequences (List .of (1 , 2 ));
28
23
assertIterableEquals (expected , actual );
29
24
}
30
25
31
26
@ Test
32
27
void testLengthOfThree () {
33
- List <List <String >> expected = List .of (
34
- List .of (),
35
- List .of ("C" ),
36
- List .of ("B" ),
37
- List .of ("B" , "C" ),
38
- List .of ("A" ),
39
- List .of ("A" , "C" ),
40
- List .of ("A" , "B" ),
41
- List .of ("A" , "B" , "C" )
28
+ List <List <String >> expected = List .of (List .of (), List .of ("C" ), List .of ("B" ), List .of ("B" , "C" ), List .of ("A" ), List .of ("A" , "C" ), List .of ("A" , "B" ), List .of ("A" , "B" , "C" )
42
29
);
43
30
List <List <Object >> actual = Subsequence .generateAllSubsequences (List .of ("A" , "B" , "C" ));
44
31
assertIterableEquals (expected , actual );
45
32
}
46
33
47
34
@ Test
48
35
void testLengthOfThreeInteger () {
49
- List <List <Integer >> expected = List .of (
50
- List .of (),
51
- List .of (3 ),
52
- List .of (2 ),
53
- List .of (2 , 3 ),
54
- List .of (1 ),
55
- List .of (1 , 3 ),
56
- List .of (1 , 2 ),
57
- List .of (1 , 2 , 3 )
36
+ List <List <Integer >> expected = List .of (List .of (), List .of (3 ), List .of (2 ), List .of (2 , 3 ), List .of (1 ), List .of (1 , 3 ), List .of (1 , 2 ), List .of (1 , 2 , 3 )
58
37
);
59
38
List <List <Object >> actual = Subsequence .generateAllSubsequences (List .of (1 , 2 , 3 ));
60
39
assertIterableEquals (expected , actual );
0 commit comments