forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermutationTest.java
More file actions
30 lines (24 loc) · 889 Bytes
/
PermutationTest.java
File metadata and controls
30 lines (24 loc) · 889 Bytes
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
package com.thealgorithms.backtracking;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class PermutationTest {
@Test
void testNoElement() {
List<Integer[]> result = Permutation.permutation(new Integer[] {});
assertEquals(result.get(0).length, 0);
}
@Test
void testSingleElement() {
List<Integer[]> result = Permutation.permutation(new Integer[] {1});
assertEquals(result.get(0)[0], 1);
}
@Test
void testMultipleElements() {
List<Integer[]> result = Permutation.permutation(new Integer[] {1, 2});
assertTrue(Arrays.equals(result.get(0), new Integer[] {1, 2}));
assertTrue(Arrays.equals(result.get(1), new Integer[] {2, 1}));
}
}