Changeset 15870 in josm for trunk/test/unit
- Timestamp:
- 2020-02-16T23:43:01+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/MultiMapTest.java
r15723 r15870 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertNull; 5 7 import static org.junit.Assert.assertTrue; 6 8 7 9 import java.util.Arrays; 10 import java.util.Collections; 8 11 import java.util.HashSet; 12 import java.util.Map; 13 import java.util.Set; 9 14 10 15 import org.junit.Test; … … 40 45 assertEquals(new HashSet<>(Arrays.asList("foo", "alpha")), map.keySet()); 41 46 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo")); 47 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.getValues("foo")); 42 48 assertEquals(new HashSet<>(), map.get("alpha")); 43 assertEquals(null, map.get("beta")); 49 assertEquals(Collections.emptySet(), map.getValues("alpha")); 50 assertNull(map.get("beta")); 51 assertEquals(Collections.emptySet(), map.getValues("beta")); 44 52 assertEquals(new HashSet<>(), map.getValues("alpha")); 45 53 assertEquals(new HashSet<>(), map.getValues("beta")); 46 54 map.put("foo", "baz2"); 47 55 map.put("foo", "baz"); 56 assertTrue(map.containsKey("foo")); 57 assertTrue(map.contains("foo", "bar")); 48 58 assertEquals(new HashSet<>(Arrays.asList("bar", "baz", "baz2")), map.get("foo")); 49 map.remove("foo", "baz"); 59 assertFalse(map.contains("foo", "xxx")); 60 assertFalse(map.remove("foo", "xxx")); 61 assertTrue(map.remove("foo", "baz")); 50 62 assertEquals(new HashSet<>(Arrays.asList("bar", "baz2")), map.get("foo")); 51 map.remove("foo"); 52 assertEquals(null, map.get("foo")); 63 assertEquals(new HashSet<>(Arrays.asList("bar", "baz2")), map.remove("foo")); 64 assertFalse(map.containsKey("foo")); 65 assertNull(map.get("foo")); 53 66 assertEquals("(alpha->[])", map.toString()); 54 map.remove("alpha");67 assertEquals(Collections.emptySet(), map.remove("alpha")); 55 68 assertTrue(map.isEmpty()); 56 map.remove("omega", null);69 assertFalse(map.remove("omega", null)); 57 70 assertTrue(map.isEmpty()); 58 71 map.clear(); … … 60 73 map.putAll("foo", Arrays.asList("bar", "baz")); 61 74 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo")); 75 assertFalse(map.isEmpty()); 76 map.clear(); 77 assertTrue(map.isEmpty()); 78 assertEquals(0, new MultiMap<String, String>(null).size()); 79 final Map<String, Set<String>> asMap = Collections.singletonMap("foo", Collections.singleton("bar")); 80 assertEquals(asMap, new MultiMap<>(asMap).toMap()); 81 assertEquals("[foo=[bar]]", new MultiMap<>(asMap).entrySet().toString()); 82 assertEquals("[foo]", new MultiMap<>(asMap).keySet().toString()); 83 assertEquals("[[bar]]", new MultiMap<>(asMap).values().toString()); 62 84 } 63 85 }
Note:
See TracChangeset
for help on using the changeset viewer.