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
|
package bjc.funcdata;
import static org.junit.Assert.*;
import org.junit.*;
@SuppressWarnings("javadoc")
public class TestMapCreation {
@Test
public void mapOfNothingCreatesEmptyMap() {
IMap<String, String> map = IMap.of();
assertEquals("Map is empty", 0, map.size());
}
@Test(expected = IllegalArgumentException.class)
public void mapOfMismatchedCountErrors() {
@SuppressWarnings("unused")
IMap<String, String> map = IMap.of("thing1");
}
@Test(expected = ClassCastException.class)
public void mapOfMismatchedTypeErrors() {
IMap<String, String> map = IMap.of(1, 1.0);
map.forEach((key, val) -> {
// An exception will be thrown here
});
}
@Test
public void mapOfCreatesWithGivenContents() {
IMap<String, String> map = IMap.of("a", "A", "b", "B");
assertTrue("Constructed map contains key 'a'", map.containsKey("a"));
assertEquals("Constructed map has key 'a' mapped to value 'A'", "A", map.get("a"));
}
}
|