use of org.eclipse.collections.impl.IntegerWithCast in project eclipse-collections by eclipse.
the class AbstractUnifiedSetTestCase method retainAllFromKeySet_null_collision.
@Test
public void retainAllFromKeySet_null_collision() {
IntegerWithCast key = new IntegerWithCast(0);
MutableSet<IntegerWithCast> mutableSet = this.newWith(null, key);
Assert.assertFalse(mutableSet.retainAll(FastList.newListWith(key, null)));
Assert.assertEquals(this.newWith(null, key), mutableSet);
}
use of org.eclipse.collections.impl.IntegerWithCast in project eclipse-collections by eclipse.
the class AbstractMutableBiMapTestCase method nullCollisionWithCastInEquals.
@Override
@Test
public void nullCollisionWithCastInEquals() {
MutableBiMap<IntegerWithCast, String> mutableMap = this.newMap();
mutableMap.put(new IntegerWithCast(0), "Test 2");
mutableMap.forcePut(new IntegerWithCast(0), "Test 3");
mutableMap.put(null, "Test 1");
Assert.assertEquals(this.newMapWithKeysValues(new IntegerWithCast(0), "Test 3", null, "Test 1"), mutableMap);
Assert.assertEquals("Test 3", mutableMap.get(new IntegerWithCast(0)));
Assert.assertEquals("Test 1", mutableMap.get(null));
}
use of org.eclipse.collections.impl.IntegerWithCast in project eclipse-collections by eclipse.
the class MutableMapIterableTestCase method retainAllFromKeySet_null_collision.
@Test
public void retainAllFromKeySet_null_collision() {
if (this.newMap() instanceof ConcurrentMap || this.newMap() instanceof SortedMap) {
return;
}
IntegerWithCast key = new IntegerWithCast(0);
MutableMapIterable<IntegerWithCast, String> mutableMapIterable = this.newMapWithKeysValues(null, "Test 1", key, "Test 2");
Assert.assertFalse(mutableMapIterable.keySet().retainAll(FastList.newListWith(key, null)));
Assert.assertEquals(this.newMapWithKeysValues(null, "Test 1", key, "Test 2"), mutableMapIterable);
}
use of org.eclipse.collections.impl.IntegerWithCast in project eclipse-collections by eclipse.
the class AbstractMutableSetTestCase method removeIf.
@Override
@Test
public void removeIf() {
super.removeIf();
MutableSet<IntegerWithCast> set = this.newWith();
MutableList<IntegerWithCast> collisions = COLLISIONS.collect(IntegerWithCast::new);
set.addAll(collisions);
collisions.reverseForEach(each -> {
Assert.assertFalse(set.remove(null));
Assert.assertTrue(set.remove(each));
Assert.assertFalse(set.remove(each));
Assert.assertFalse(set.remove(null));
Assert.assertFalse(set.remove(new IntegerWithCast(COLLISION_10)));
});
Assert.assertEquals(UnifiedSet.<IntegerWithCast>newSet(), set);
collisions.forEach(Procedures.cast(each -> {
MutableSet<IntegerWithCast> set2 = this.newWith();
set2.addAll(collisions);
Assert.assertFalse(set2.remove(null));
Assert.assertTrue(set2.remove(each));
Assert.assertFalse(set2.remove(each));
Assert.assertFalse(set2.remove(null));
Assert.assertFalse(set2.remove(new IntegerWithCast(COLLISION_10)));
}));
// remove the second-to-last item in a fully populated single chain to cause the last item to move
MutableSet<Integer> set3 = this.newWith(COLLISION_1, COLLISION_2, COLLISION_3, COLLISION_4);
Assert.assertTrue(set3.remove(COLLISION_3));
Assert.assertEquals(UnifiedSet.newSetWith(COLLISION_1, COLLISION_2, COLLISION_4), set3);
Assert.assertTrue(set3.remove(COLLISION_2));
Assert.assertEquals(UnifiedSet.newSetWith(COLLISION_1, COLLISION_4), set3);
// search a chain for a non-existent element
MutableSet<Integer> chain = this.newWith(COLLISION_1, COLLISION_2, COLLISION_3, COLLISION_4);
Assert.assertFalse(chain.remove(COLLISION_5));
// search a deep chain for a non-existent element
MutableSet<Integer> deepChain = this.newWith(COLLISION_1, COLLISION_2, COLLISION_3, COLLISION_4, COLLISION_5, COLLISION_6, COLLISION_7);
Assert.assertFalse(deepChain.remove(COLLISION_8));
// search for a non-existent element
MutableSet<Integer> empty = this.newWith();
Assert.assertFalse(empty.remove(COLLISION_1));
}
use of org.eclipse.collections.impl.IntegerWithCast in project eclipse-collections by eclipse.
the class AbstractUnifiedSetTestCase method addOnObjectWithCastInEquals.
@Test
public void addOnObjectWithCastInEquals() {
if (this.newWith() instanceof SortedSet) {
return;
}
MutableSet<IntegerWithCast> mutableSet = this.newWith(new IntegerWithCast(0));
Assert.assertFalse(mutableSet.add(new IntegerWithCast(0)));
Assert.assertTrue(mutableSet.add(null));
Assert.assertFalse(mutableSet.add(null));
}
Aggregations