-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Expand file tree
/
Copy pathPermutations.java
More file actions
33 lines (26 loc) · 906 Bytes
/
Permutations.java
File metadata and controls
33 lines (26 loc) · 906 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
31
32
33
package com.thealgorithms.recursion;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.List;
import org.junit.jupiter.api.Test;
class PermutationsTest {
@Test
void testIntegerPermutations() {
int[] nums = {1, 2};
List<List<Integer>> result = Permutations.permutations(nums);
assertEquals(2, result.size());
}
@Test
void testIntegerPermutationsNull() {
assertThrows(NullPointerException.class, () -> Permutations.permutations((int[]) null));
}
@Test
void testStringPermutations() {
List<String> result = Permutations.permutations("ab");
assertEquals(2, result.size());
}
@Test
void testStringPermutationsNull() {
assertThrows(NullPointerException.class, () -> Permutations.permutations((String) null));
}
}