diff options
author | Pacien TRAN-GIRARD | 2016-03-15 11:51:31 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-03-15 11:51:31 +0100 |
commit | 741cb9da501b8c6e9e5fa006e5c2c9df0b4616f8 (patch) | |
tree | 836bab665ee81039a4c1938c814f1153acdf1b6e /test/ch | |
parent | 06296e66cd53bc68198c3bfeace17f85707cc2f4 (diff) | |
download | xblast-741cb9da501b8c6e9e5fa006e5c2c9df0b4616f8.tar.gz |
Add List permutation function and its test
Diffstat (limited to 'test/ch')
-rw-r--r-- | test/ch/epfl/xblast/ListsTest.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java index b898399..b18b05e 100644 --- a/test/ch/epfl/xblast/ListsTest.java +++ b/test/ch/epfl/xblast/ListsTest.java | |||
@@ -4,6 +4,7 @@ import org.junit.Test; | |||
4 | 4 | ||
5 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
6 | import java.util.Arrays; | 6 | import java.util.Arrays; |
7 | import java.util.LinkedList; | ||
7 | import java.util.List; | 8 | import java.util.List; |
8 | import java.util.stream.Collectors; | 9 | import java.util.stream.Collectors; |
9 | import java.util.stream.IntStream; | 10 | import java.util.stream.IntStream; |
@@ -48,4 +49,18 @@ public class ListsTest { | |||
48 | assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i)); | 49 | assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i)); |
49 | } | 50 | } |
50 | 51 | ||
52 | @Test | ||
53 | public void isListPermuted() { | ||
54 | List<Integer> sampleList = Arrays.asList(1, 2, 3); | ||
55 | List<List<Integer>> expected = new LinkedList<>(); | ||
56 | expected.add(Arrays.asList(1, 2, 3)); | ||
57 | expected.add(Arrays.asList(2, 1, 3)); | ||
58 | expected.add(Arrays.asList(2, 3, 1)); | ||
59 | expected.add(Arrays.asList(1, 3, 2)); | ||
60 | expected.add(Arrays.asList(3, 1, 2)); | ||
61 | expected.add(Arrays.asList(3, 2, 1)); | ||
62 | |||
63 | assertEquals(expected, Lists.permutations(sampleList)); | ||
64 | } | ||
65 | |||
51 | } | 66 | } |