public void verifyAll() { if (empty) { super.verifyAll(); } }
public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); } }
public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); } }
public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); }
/** * Tests Map.isEmpty() */ @Test public void testMapIsEmpty() { resetEmpty(); assertEquals("Map.isEmpty() should return true with an empty map", true, map.isEmpty()); verifyAll(); resetFull(); assertEquals("Map.isEmpty() should return false with a non-empty map", false, map.isEmpty()); verifyAll(); }
/** * Tests Map.toString(). Since the format of the string returned by the * toString() method is not defined in the Map interface, there is no * common way to test the results of the toString() method. Thereforce, * it is encouraged that Map implementations override this test with one * that checks the format matches any format defined in its API. This * default implementation just verifies that the toString() method does * not return null. */ @Test public void testMapToString() { resetEmpty(); assertTrue("Empty map toString() should not return null", map.toString() != null); verifyAll(); resetFull(); assertTrue("Empty map toString() should not return null", map.toString() != null); verifyAll(); }
/** * Tests Map.equals(Object) */ @Test public void testMapEquals() { resetEmpty(); assertTrue("Empty maps unequal.", map.equals(confirmed)); verifyAll(); resetFull(); assertTrue("Full maps unequal.", map.equals(confirmed)); verifyAll(); resetFull(); // modify the HashMap created from the full map and make sure this // change results in map.equals() to return false. Iterator iter = confirmed.keySet().iterator(); iter.next(); iter.remove(); assertTrue("Different maps equal.", !map.equals(confirmed)); resetFull(); assertTrue("equals(null) returned true.", !map.equals(null)); assertTrue("equals(new Object()) returned true.", !map.equals(new Object())); verifyAll(); }
/** * Tests Map.containsKey(Object) by verifying it returns false for all * sample keys on a map created using an empty map and returns true for * all sample keys returned on a full map. */ @Test public void testMapContainsKey() { Object[] keys = getSampleKeys(); resetEmpty(); for (Object key : keys) { assertTrue("Map must not contain key when map is empty", !map.containsKey(key)); } verifyAll(); resetFull(); for (Object key : keys) { assertTrue("Map must contain key for a mapping in the map. Missing: " + key, map.containsKey(key)); } verifyAll(); }
/** * Tests Map.containsValue(Object) by verifying it returns false for all * sample values on an empty map and returns true for all sample values on * a full map. */ @Test public void testMapContainsValue() { Object[] values = getSampleValues(); resetEmpty(); for (Object value : values) { assertTrue("Empty map must not contain value", !map.containsValue(value)); } verifyAll(); resetFull(); for (Object value : values) { assertTrue("Map must contain value for a mapping in the map.", map.containsValue(value)); } verifyAll(); }
/** * Tests {@link Map#clear()}. If the map {@link #isRemoveSupported()} * can add and remove elements}, then {@link Map#size()} and * {@link Map#isEmpty()} are used to ensure that map has no elements after * a call to clear. If the map does not support adding and removing * elements, this method checks to ensure clear throws an * UnsupportedOperationException. */ @Test public void testMapClear() { if (!isRemoveSupported()) { try { resetFull(); map.clear(); fail("Expected UnsupportedOperationException on clear"); } catch (UnsupportedOperationException ex) { } return; } resetEmpty(); map.clear(); confirmed.clear(); verifyAll(); resetFull(); map.clear(); confirmed.clear(); verifyAll(); }
/** * Tests Map.get(Object) */ @Test public void testMapGet() { resetEmpty(); Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); for (Object key : keys) { assertTrue("Empty map.get() should return null.", map.get(key) == null); } verifyAll(); resetFull(); for (int i = 0; i < keys.length; i++) { assertEquals("Full map.get() should return value from mapping.", values[i], map.get(keys[i])); } }
Object o = map.put(keys[i], values[i]); confirmed.put(keys[i], values[i]); verifyAll(); assertTrue("First map.put should return null", o == null); assertTrue("Map should contain key after put", Object o = map.put(keys[i], newValues[i]); confirmed.put(keys[i], newValues[i]); verifyAll(); assertEquals("Map.put should return previous value when changed", values[i], o); Object o = map.put(key, newValues[i]); Object value = confirmed.put(key, newValues[i]); verifyAll(); assertEquals("Map.put should return previous value when changed", value, o);
public void verifyAll() { if (empty) { super.verifyAll(); } }
public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); } }
public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); } }
/** * Tests Map.isEmpty() */ @Test public void testMapIsEmpty() { resetEmpty(); assertEquals("Map.isEmpty() should return true with an empty map", true, map.isEmpty()); verifyAll(); resetFull(); assertEquals("Map.isEmpty() should return false with a non-empty map", false, map.isEmpty()); verifyAll(); }