aboutsummaryrefslogtreecommitdiff
path: root/test/ch/epfl
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-05-10 17:10:31 +0200
committerPacien TRAN-GIRARD2016-05-10 17:10:31 +0200
commit766114c05bcd0b0388988aaf606e046857e6946a (patch)
tree91ccdb1b82664c8e6d4cb5469f18da2ef08fe5e9 /test/ch/epfl
parente85032012f1d5ded1b6a49a88d345cc60a6ac88b (diff)
downloadxblast-766114c05bcd0b0388988aaf606e046857e6946a.tar.gz
Add lists and maps functions
Diffstat (limited to 'test/ch/epfl')
-rw-r--r--test/ch/epfl/xblast/ListsTest.java47
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
3import org.junit.Test; 3import org.junit.Test;
4 4
5import java.util.ArrayList; 5import java.util.*;
6import java.util.Arrays;
7import java.util.LinkedList;
8import java.util.List;
9import java.util.stream.Collectors; 6import java.util.stream.Collectors;
10import java.util.stream.IntStream; 7import 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}