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