@CollectionSize.Require(absent = ZERO) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemove_occurrences_present() { assertEquals( "multiset.remove(present, 2) didn't return the old count", 1, getMultiset().remove(e0(), 2)); assertFalse( "multiset contains present after multiset.remove(present, 2)", getMultiset().contains(e0())); assertEquals(0, getMultiset().count(e0())); }
@CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemove_occurrences_negative() { try { getMultiset().remove(e0(), -1); fail("multiset.remove(E, -1) didn't throw an exception"); } catch (IllegalArgumentException required) { } }
@CollectionFeature.Require(absent = SUPPORTS_REMOVE) public void testRemoveUnsupported() { try { getMultiset().remove(e0(), 2); fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemove_some_occurrences_present() { initThreeCopies(); assertEquals( "multiset.remove(present, 2) didn't return the old count", 3, getMultiset().remove(e0(), 2)); assertTrue( "multiset contains present after multiset.remove(present, 2)", getMultiset().contains(e0())); assertEquals(1, getMultiset().count(e0())); }
@CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveNegative() { try { getMultiset().remove(e0(), -1); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } expectUnchanged(); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveAllIgnoresCount() { initThreeCopies(); assertTrue(getMultiset().removeAll(Collections.singleton(e0()))); assertEmpty(getMultiset()); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRetainAllIgnoresCount() { initThreeCopies(); List<E> contents = Helpers.copyToList(getMultiset()); assertFalse(getMultiset().retainAll(Collections.singleton(e0()))); expectContents(contents); }
@CollectionSize.Require(absent = ZERO) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemove_occurrences_present() { assertEquals( "multiset.remove(present, 2) didn't return the old count", 1, getMultiset().remove(e0(), 2)); assertFalse( "multiset contains present after multiset.remove(present, 2)", getMultiset().contains(e0())); assertEquals(0, getMultiset().count(e0())); }
@CollectionFeature.Require(absent = SUPPORTS_REMOVE) public void testRemoveUnsupported() { try { getMultiset().remove(e0(), 2); fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } }
@CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemove_occurrences_negative() { try { getMultiset().remove(e0(), -1); fail("multiset.remove(E, -1) didn't throw an exception"); } catch (IllegalArgumentException required) { } }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemove_some_occurrences_present() { initThreeCopies(); assertEquals( "multiset.remove(present, 2) didn't return the old count", 3, getMultiset().remove(e0(), 2)); assertTrue( "multiset contains present after multiset.remove(present, 2)", getMultiset().contains(e0())); assertEquals(1, getMultiset().count(e0())); }
@CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveNegative() { try { getMultiset().remove(e0(), -1); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } expectUnchanged(); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveAllIgnoresCount() { initThreeCopies(); assertTrue(getMultiset().removeAll(Collections.singleton(e0()))); assertEmpty(getMultiset()); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRetainAllIgnoresCount() { initThreeCopies(); List<E> contents = Helpers.copyToList(getMultiset()); assertFalse(getMultiset().retainAll(Collections.singleton(e0()))); expectContents(contents); }