@Test public void removeKey() { MutableObjectBooleanMap<String> map0 = this.newWithKeysValues("0", true, "1", false); map0.removeKey("1"); Assert.assertEquals(this.newWithKeysValues("0", true), map0); map0.removeKey("0"); Assert.assertEquals(ObjectBooleanHashMap.newMap(), map0); MutableObjectBooleanMap<String> map1 = this.newWithKeysValues("0", false, "1", true); map1.removeKey("0"); Assert.assertEquals(this.newWithKeysValues("1", true), map1); map1.removeKey("1"); Assert.assertEquals(ObjectBooleanHashMap.newMap(), map1); this.map.removeKey("5"); Assert.assertEquals(this.newWithKeysValues("0", true, "1", true, "2", false), this.map); this.map.removeKey("0"); Assert.assertEquals(this.newWithKeysValues("1", true, "2", false), this.map); this.map.removeKey("1"); Assert.assertEquals(this.newWithKeysValues("2", false), this.map); this.map.removeKey("2"); Assert.assertEquals(ObjectBooleanHashMap.newMap(), this.map); this.map.removeKey("0"); this.map.removeKey("1"); this.map.removeKey("2"); Assert.assertEquals(ObjectBooleanHashMap.newMap(), this.map); Verify.assertEmpty(this.map); this.map.put(null, true); Assert.assertTrue(this.map.get(null)); this.map.removeKey(null); Assert.assertFalse(this.map.get(null)); }
@Override public void size() { super.size(); MutableObjectBooleanMap<Integer> hashMap1 = this.newWithKeysValues(1, true, 0, false); Verify.assertSize(2, hashMap1); hashMap1.removeKey(1); Verify.assertSize(1, hashMap1); hashMap1.removeKey(0); Verify.assertSize(0, hashMap1); }
@Test public void putDuplicateWithRemovedSlot() { String collision1 = generateCollisions().getFirst(); String collision2 = generateCollisions().get(1); String collision3 = generateCollisions().get(2); String collision4 = generateCollisions().get(3); MutableObjectBooleanMap<String> hashMap = this.getEmptyMap(); hashMap.put(collision1, true); hashMap.put(collision2, false); hashMap.put(collision3, true); Assert.assertFalse(hashMap.get(collision2)); hashMap.removeKey(collision2); hashMap.put(collision4, false); Assert.assertEquals( this.newWithKeysValues(collision1, true, collision3, true, collision4, false), hashMap); MutableObjectBooleanMap<String> hashMap1 = this.getEmptyMap(); hashMap1.put(collision1, false); hashMap1.put(collision2, false); hashMap1.put(collision3, true); Assert.assertFalse(hashMap1.get(collision1)); hashMap1.removeKey(collision1); hashMap1.put(collision4, true); Assert.assertEquals( this.newWithKeysValues(collision2, false, collision3, true, collision4, true), hashMap1); MutableObjectBooleanMap<String> hashMap2 = this.getEmptyMap(); hashMap2.put(collision1, true); hashMap2.put(collision2, true); hashMap2.put(collision3, false); Assert.assertFalse(hashMap2.get(collision3)); hashMap2.removeKey(collision3); hashMap2.put(collision4, false); Assert.assertEquals( this.newWithKeysValues(collision1, true, collision2, true, collision4, false), hashMap2); MutableObjectBooleanMap<String> hashMap3 = this.getEmptyMap(); hashMap3.put(collision1, true); hashMap3.put(collision2, true); hashMap3.put(collision3, false); Assert.assertTrue(hashMap3.get(collision2)); Assert.assertFalse(hashMap3.get(collision3)); hashMap3.removeKey(collision2); hashMap3.removeKey(collision3); hashMap3.put(collision4, false); Assert.assertEquals(this.newWithKeysValues(collision1, true, collision4, false), hashMap3); MutableObjectBooleanMap<String> hashMap4 = this.getEmptyMap(); hashMap4.put(null, false); Assert.assertEquals(this.newWithKeysValues(null, false), hashMap4); hashMap4.put(null, true); Assert.assertEquals(this.newWithKeysValues(null, true), hashMap4); }
@Test public void size() { Verify.assertSize(0, this.getEmptyMap()); Verify.assertSize(1, this.getEmptyMap().withKeyValue(0, false)); Verify.assertSize(1, this.getEmptyMap().withKeyValue(1, true)); Verify.assertSize(1, this.getEmptyMap().withKeyValue(null, false)); MutableObjectBooleanMap<Integer> hashMap1 = this.newWithKeysValues(1, true, 0, false); Verify.assertSize(2, hashMap1); hashMap1.removeKey(1); Verify.assertSize(1, hashMap1); hashMap1.removeKey(0); Verify.assertSize(0, hashMap1); Verify.assertSize(2, this.newWithKeysValues(1, false, 5, false)); Verify.assertSize(2, this.newWithKeysValues(0, true, 5, true)); }
@Override public void contains() { super.contains(); MutableObjectBooleanMap<String> map1 = this.classUnderTest(); map1.clear(); map1.put("5", true); Assert.assertTrue(map1.contains(true)); map1.put(null, false); Assert.assertTrue(map1.contains(false)); map1.removeKey("5"); Assert.assertFalse(map1.contains(true)); Assert.assertTrue(map1.contains(false)); map1.removeKey(null); Assert.assertFalse(map1.contains(false)); }
@Override public void containsKey() { super.containsKey(); MutableObjectBooleanMap<String> map1 = this.classUnderTest(); map1.removeKey("0"); Assert.assertFalse(map1.containsKey("0")); Assert.assertFalse(map1.get("0")); map1.removeKey("0"); Assert.assertFalse(map1.containsKey("0")); Assert.assertFalse(map1.get("0")); map1.removeKey("1"); Assert.assertFalse(map1.containsKey("1")); Assert.assertFalse(map1.get("1")); map1.removeKey("2"); Assert.assertFalse(map1.containsKey("2")); Assert.assertFalse(map1.get("2")); map1.removeKey("3"); Assert.assertFalse(map1.containsKey("3")); Assert.assertFalse(map1.get("3")); map1.put(null, true); Assert.assertTrue(map1.containsKey(null)); map1.removeKey(null); Assert.assertFalse(map1.containsKey(null)); }
@Override public void containsAllIterable() { super.containsAllIterable(); MutableObjectBooleanMap<String> map1 = this.classUnderTest(); map1.clear(); map1.put("5", true); Assert.assertTrue(map1.containsAll(BooleanArrayList.newListWith(true))); Assert.assertFalse(map1.containsAll(BooleanArrayList.newListWith(true, false))); Assert.assertFalse(map1.containsAll(BooleanArrayList.newListWith(false, false))); map1.put(null, false); Assert.assertTrue(map1.containsAll(BooleanArrayList.newListWith(false))); Assert.assertTrue(map1.containsAll(BooleanArrayList.newListWith(true, false))); map1.removeKey("5"); Assert.assertFalse(map1.containsAll(BooleanArrayList.newListWith(true))); Assert.assertFalse(map1.containsAll(BooleanArrayList.newListWith(true, false))); Assert.assertTrue(map1.containsAll(BooleanArrayList.newListWith(false, false))); map1.removeKey(null); Assert.assertFalse(map1.containsAll(BooleanArrayList.newListWith(false, true))); }
@Override public void getIfAbsent() { super.getIfAbsent(); MutableObjectBooleanMap<String> map1 = this.classUnderTest(); map1.removeKey("0"); Assert.assertTrue(map1.getIfAbsent("0", true)); Assert.assertFalse(map1.getIfAbsent("0", false)); map1.put("0", false); Assert.assertFalse(map1.getIfAbsent("0", true)); map1.put("5", true); Assert.assertTrue(map1.getIfAbsent("5", false)); map1.put(null, false); Assert.assertFalse(map1.getIfAbsent(null, true)); }
@Override public void getOrThrow() { super.getOrThrow(); MutableObjectBooleanMap<String> map1 = this.classUnderTest(); map1.removeKey("0"); Verify.assertThrows( IllegalStateException.class, () -> { map1.getOrThrow("0"); }); map1.put("0", false); Assert.assertFalse(map1.getOrThrow("0")); map1.put("5", true); Assert.assertTrue(map1.getOrThrow("5")); map1.put(null, false); Assert.assertFalse(map1.getOrThrow(null)); }