-
Notifications
You must be signed in to change notification settings - Fork 449
/
Copy pathPermuteElementsTest.java
47 lines (34 loc) · 1 KB
/
PermuteElementsTest.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
41
42
43
44
45
46
47
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class PermuteElementsTest {
List<Integer> expected;
List<Integer> perm;
List<Integer> a;
@Test
public void applyPermutation1() {
expected = Arrays.asList(2, 1);
perm = Arrays.asList(1, 0);
a = Arrays.asList(1, 2);
test(expected, perm, a);
}
@Test
public void applyPermutation2() {
expected = Arrays.asList(1);
perm = Arrays.asList(0);
a = Arrays.asList(1);
test(expected, perm, a);
}
@Test
public void applyPermutation3() {
expected = Arrays.asList(100, 150, 50, 200);
perm = Arrays.asList(2, 0, 1, 3);
a = Arrays.asList(50, 100, 150, 200);
test(expected, perm, a);
}
private void test(List<Integer> expected, List<Integer> perm, List<Integer> a) {
PermuteElements.applyPermutation(perm, a);
assertEquals(expected, a);
}
}