- Timestamp:
- 2016-02-02T19:32:16+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/MultiMapTest.java
r9669 r9712 2 2 package org.openstreetmap.josm.tools; 3 3 4 import org.junit.Test; 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertTrue; 6 7 import java.util.Arrays; 8 import java.util.HashSet; 5 9 6 10 import nl.jqno.equalsverifier.EqualsVerifier; 11 import org.junit.Test; 7 12 8 13 /** … … 18 23 EqualsVerifier.forClass(MultiMap.class).usingGetClass().verify(); 19 24 } 25 26 /** 27 * Various test of {@link MultiMap}. 28 */ 29 @Test 30 public void testMultiMap() { 31 final MultiMap<String, String> map = new MultiMap<>(); 32 assertTrue(map.isEmpty()); 33 map.put("foo", "bar"); 34 map.put("foo", "baz"); 35 map.putVoid("alpha"); 36 assertEquals(2, map.size()); 37 assertEquals(new HashSet<>(Arrays.asList("foo", "alpha")), map.keySet()); 38 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo")); 39 assertEquals(new HashSet<>(), map.get("alpha")); 40 assertEquals(null, map.get("beta")); 41 assertEquals(new HashSet<>(), map.getValues("alpha")); 42 assertEquals(new HashSet<>(), map.getValues("beta")); 43 assertEquals("(foo->{bar,baz},alpha->{})", map.toString()); 44 assertEquals("[[bar, baz], []]", map.values().toString()); 45 map.put("foo", "baz2"); 46 map.put("foo", "baz"); 47 assertEquals(new HashSet<>(Arrays.asList("bar", "baz", "baz2")), map.get("foo")); 48 map.remove("foo", "baz"); 49 assertEquals(new HashSet<>(Arrays.asList("bar", "baz2")), map.get("foo")); 50 map.remove("foo"); 51 assertEquals(null, map.get("foo")); 52 assertEquals("(alpha->{})", map.toString()); 53 map.remove("alpha"); 54 assertTrue(map.isEmpty()); 55 map.remove("omega", null); 56 assertTrue(map.isEmpty()); 57 map.clear(); 58 assertTrue(map.isEmpty()); 59 map.putAll("foo", Arrays.asList("bar", "baz")); 60 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo")); 61 } 20 62 }
Note:
See TracChangeset
for help on using the changeset viewer.