diff options
Diffstat (limited to 'test/ch/epfl/xblast/ListsTest.java')
-rw-r--r-- | test/ch/epfl/xblast/ListsTest.java | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java index b18b05e..e62eede 100644 --- a/test/ch/epfl/xblast/ListsTest.java +++ b/test/ch/epfl/xblast/ListsTest.java | |||
@@ -2,10 +2,7 @@ package ch.epfl.xblast; | |||
2 | 2 | ||
3 | import org.junit.Test; | 3 | import org.junit.Test; |
4 | 4 | ||
5 | import java.util.ArrayList; | 5 | import java.util.*; |
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedList; | ||
8 | import java.util.List; | ||
9 | import java.util.stream.Collectors; | 6 | import java.util.stream.Collectors; |
10 | import java.util.stream.IntStream; | 7 | import java.util.stream.IntStream; |
11 | 8 | ||
@@ -63,4 +60,46 @@ public class ListsTest { | |||
63 | assertEquals(expected, Lists.permutations(sampleList)); | 60 | assertEquals(expected, Lists.permutations(sampleList)); |
64 | } | 61 | } |
65 | 62 | ||
63 | @Test | ||
64 | public void areListsMapped() { | ||
65 | final List<Character> keyList = Arrays.asList('a', 'b'); | ||
66 | final List<Integer> valueList = Arrays.asList(0, 1); | ||
67 | |||
68 | final Map<Character, Integer> expectedMap = new HashMap<>(); | ||
69 | expectedMap.put('a', 0); | ||
70 | expectedMap.put('b', 1); | ||
71 | |||
72 | assertEquals(expectedMap, Lists.linearMap(keyList, valueList)); | ||
73 | } | ||
74 | |||
75 | @Test | ||
76 | public void areMapsTraversed() { | ||
77 | final Map<Character, Integer> m1 = new HashMap<>(); | ||
78 | m1.put('a', 0); | ||
79 | m1.put('b', 1); | ||
80 | |||
81 | final Map<Integer, String> m2 = new HashMap<>(); | ||
82 | m2.put(0, "Apple"); | ||
83 | m2.put(1, "Banana"); | ||
84 | |||
85 | final Map<Character, String> expectedMap = new HashMap<>(); | ||
86 | expectedMap.put('a', "Apple"); | ||
87 | expectedMap.put('b', "Banana"); | ||
88 | |||
89 | assertEquals(expectedMap, Lists.traverseMaps(m1, m2)); | ||
90 | } | ||
91 | |||
92 | @Test | ||
93 | public void isMapInverted() { | ||
94 | final Map<Character, Integer> sampleMap = new HashMap<>(); | ||
95 | sampleMap.put('a', 0); | ||
96 | sampleMap.put('b', 1); | ||
97 | |||
98 | final Map<Integer, Character> expectedMap = new HashMap<>(); | ||
99 | expectedMap.put(0, 'a'); | ||
100 | expectedMap.put(1, 'b'); | ||
101 | |||
102 | assertEquals(expectedMap, Lists.invertMap(sampleMap)); | ||
103 | } | ||
104 | |||
66 | } | 105 | } |