Code example for SortedMultiset

Methods: removeelementSettailMultiset

0
      fail("Expected IllegalArgumentException"); 
    } catch (IllegalArgumentException expected) {}
  } 
 
  void expectRemoveZero(SortedMultiset<E> multiset, Entry<E> entry) {
    assertEquals(0, multiset.remove(entry.getElement(), entry.getCount()));
    assertFalse(multiset.remove(entry.getElement()));
    assertFalse(multiset.elementSet().remove(entry.getElement()));
  } 
 
  void expectSetCountFailure(SortedMultiset<E> multiset, Entry<E> entry) {
    try { 
      multiset.setCount(entry.getElement(), multiset.count(entry.getElement()));
    } catch (IllegalArgumentException acceptable) {}
    try { 
      multiset.setCount(entry.getElement(), multiset.count(entry.getElement()) + 1);
      fail("Expected IllegalArgumentException"); 
    } catch (IllegalArgumentException expected) {}
  } 
 
  @CollectionSize.Require(ONE) 
  @CollectionFeature.Require(SUPPORTS_ADD) 
  public void testAddOutOfTailBoundsOne() { 
    expectAddFailure(sortedMultiset.tailMultiset(a.getElement(), OPEN), a);
  } 
 
  @CollectionSize.Require(SEVERAL) 
  @CollectionFeature.Require(SUPPORTS_ADD) 
  public void testAddOutOfTailBoundsSeveral() { 
    expectAddFailure(sortedMultiset.tailMultiset(a.getElement(), OPEN), a);
    expectAddFailure(sortedMultiset.tailMultiset(b.getElement(), CLOSED), a);
    expectAddFailure(sortedMultiset.tailMultiset(b.getElement(), OPEN), a);
    expectAddFailure(sortedMultiset.tailMultiset(b.getElement(), OPEN), b);
    expectAddFailure(sortedMultiset.tailMultiset(c.getElement(), CLOSED), a);
    expectAddFailure(sortedMultiset.tailMultiset(c.getElement(), CLOSED), b);
    expectAddFailure(sortedMultiset.tailMultiset(c.getElement(), OPEN), a);
    expectAddFailure(sortedMultiset.tailMultiset(c.getElement(), OPEN), b);
    expectAddFailure(sortedMultiset.tailMultiset(c.getElement(), OPEN), c);
  } 
 
  @CollectionSize.Require(ONE) 
  @CollectionFeature.Require(SUPPORTS_ADD) 
  public void testAddOutOfHeadBoundsOne() { 
    expectAddFailure(sortedMultiset.headMultiset(a.getElement(), OPEN), a);
  } 
 
  @CollectionSize.Require(SEVERAL) 
  @CollectionFeature.Require(SUPPORTS_ADD) 
  public void testAddOutOfHeadBoundsSeveral() { 
    expectAddFailure(sortedMultiset.headMultiset(c.getElement(), OPEN), c);
    expectAddFailure(sortedMultiset.headMultiset(b.getElement(), CLOSED), c);
    expectAddFailure(sortedMultiset.headMultiset(b.getElement(), OPEN), c);
    expectAddFailure(sortedMultiset.headMultiset(b.getElement(), OPEN), b);
    expectAddFailure(sortedMultiset.headMultiset(a.getElement(), CLOSED), c);
    expectAddFailure(sortedMultiset.headMultiset(a.getElement(), CLOSED), b);
    expectAddFailure(sortedMultiset.headMultiset(a.getElement(), OPEN), c);
    expectAddFailure(sortedMultiset.headMultiset(a.getElement(), OPEN), b);
    expectAddFailure(sortedMultiset.headMultiset(a.getElement(), OPEN), a);
  } 
 
  @CollectionSize.Require(ONE) 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  public void testRemoveOutOfTailBoundsOne() { 
    expectRemoveZero(sortedMultiset.tailMultiset(a.getElement(), OPEN), a);
  } 
 
  @CollectionSize.Require(SEVERAL) 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  public void testRemoveOutOfTailBoundsSeveral() { 
Experience pair programming with AI  Get Codota for Java