Java Code Examples for com.google.common.collect.testing.features.CollectionFeature.Require

The following are Jave code examples for showing how to use Require of the com.google.common.collect.testing.features.CollectionFeature class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: googles-monorepo-demo   File: AbstractMultisetSetCountTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(absent = {SUPPORTS_ADD, SUPPORTS_REMOVE})
public void testSetCount_zeroToZero_unsupported() {
  try {
    assertZeroToZero();
  } catch (UnsupportedOperationException tolerated) {
  }
}
 
Example 2
Project: guava-mock   File: MultisetNavigationTester.java   View Source Code Vote up 5 votes
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testClearTailClosed() {
  List<Entry<E>> expected =
      copyToList(sortedMultiset.headMultiset(b.getElement(), OPEN).entrySet());
  sortedMultiset.tailMultiset(b.getElement(), CLOSED).clear();
  assertEquals(expected, copyToList(sortedMultiset.entrySet()));
}
 
Example 3
Project: googles-monorepo-demo   File: MultisetRemoveTester.java   View Source Code Vote up 5 votes
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllIgnoresCount() {
  initThreeCopies();
  assertTrue(getMultiset().removeAll(Collections.singleton(e0())));
  assertEmpty(getMultiset());
}
 
Example 4
Project: googles-monorepo-demo   File: CollectionAddTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(absent = SUPPORTS_ADD)
public void testAdd_unsupportedNotPresent() {
  try {
    collection.add(e3());
    fail("add(notPresent) should throw");
  } catch (UnsupportedOperationException expected) {
  }
  expectUnchanged();
  expectMissing(e3());
}
 
Example 5
Project: guava-mock   File: AbstractMultisetSetCountTester.java   View Source Code Vote up 5 votes
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(absent = {SUPPORTS_ADD, SUPPORTS_REMOVE})
public void testSetCount_threeToThree_unsupported() {
  try {
    assertThreeToThree();
  } catch (UnsupportedOperationException tolerated) {
  }
}
 
Example 6
Project: googles-monorepo-demo   File: MultisetAddTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(absent = SUPPORTS_ADD)
public void testAddOccurrences_unsupported() {
  try {
    getMultiset().add(e0(), 2);
    fail("unsupported multiset.add(E, int) didn't throw exception");
  } catch (UnsupportedOperationException required) {
  }
}
 
Example 7
Project: googles-monorepo-demo   File: ListRetainAllTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testRetainAll_duplicatesKept() {
  E[] array = createSamplesArray();
  array[1] = e0();
  collection = getSubjectGenerator().create(array);
  assertFalse(
      "containsDuplicates.retainAll(superset) should return false",
      collection.retainAll(MinimalCollection.of(createSamplesArray())));
  expectContents(array);
}
 
Example 8
Project: guava-mock   File: SetRemoveTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
  getSet().remove(e0());
  assertFalse(
      "After remove(present) a set should not contain the removed element.",
      getSet().contains(e0()));
}
 
Example 9
Project: googles-monorepo-demo   File: AbstractMultisetSetCountTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testSetCount_negative_removeSupported() {
  try {
    setCountNoCheckReturnValue(e3(), -1);
    fail("calling setCount() with a negative count should throw IllegalArgumentException");
  } catch (IllegalArgumentException expected) {
  }
}
 
Example 10
Project: guava-mock   File: MultisetElementSetTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(SUPPORTS_ADD)
public void testElementSetReflectsAddAbsent() {
  Set<E> elementSet = getMultiset().elementSet();
  assertFalse(elementSet.contains(e3()));
  getMultiset().add(e3(), 4);
  assertTrue(elementSet.contains(e3()));
}
 
Example 11
Project: googles-monorepo-demo   File: MultisetIteratorTester.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
@CollectionFeature.Require({SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
public void testRemovingIteratorKnownOrder() {
  new IteratorTester<E>(
      4,
      MODIFIABLE,
      getSubjectGenerator().order(Arrays.asList(e0(), e1(), e1(), e2())),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override
    protected Iterator<E> newTargetIterator() {
      return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
    }
  }.test();
}
 
Example 12
Project: guava-mock   File: MultisetSetCountConditionallyTester.java   View Source Code Vote up 5 votes
@CollectionFeature.Require(absent = SUPPORTS_ADD)
public void testSetCountConditional_negativeOldCount_addUnsupported() {
  try {
    assertSetCountNegativeOldCount();
  } catch (UnsupportedOperationException tolerated) {
  }
}
 
Example 13
Project: googles-monorepo-demo   File: SetAddAllTester.java   View Source Code Vote up 4 votes
@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_withDuplicates() {
  MinimalCollection<E> elementsToAdd = MinimalCollection.of(e3(), e4(), e3(), e4());
  assertTrue("add(hasDuplicates) should return true", getSet().addAll(elementsToAdd));
  expectAdded(e3(), e4());
}
 
Example 14
Project: guava-mock   File: ListAddTester.java   View Source Code Vote up 4 votes
@CollectionFeature.Require(SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAdd_supportedPresent() {
  assertTrue("add(present) should return true", getList().add(e0()));
  expectAdded(e0());
}
 
Example 15
Project: googles-monorepo-demo   File: AbstractMultisetSetCountTester.java   View Source Code Vote up 4 votes
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testSetCount_oneToZero_unsupported() {
  assertSetCountDecreasingFailure(e0(), 0);
}
 
Example 16
Project: googles-monorepo-demo   File: CollectionRetainAllTester.java   View Source Code Vote up 4 votes
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRetainAll_nullSingletonPreviouslyNonEmpty() {
  expectReturnsTrue(nullSingleton);
  expectContents();
}
 
Example 17
Project: googles-monorepo-demo   File: CollectionRetainAllTester.java   View Source Code Vote up 4 votes
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRetainAll_sameElementsUnsupported() {
  expectReturnsFalseOrThrows(sameElements);
  expectUnchanged();
}
 
Example 18
Project: googles-monorepo-demo   File: AbstractMultisetSetCountTester.java   View Source Code Vote up 4 votes
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testSetCount_threeToOne_unsupported() {
  initThreeCopies();
  assertSetCountDecreasingFailure(e0(), 1);
}
 
Example 19
Project: googles-monorepo-demo   File: CollectionRetainAllTester.java   View Source Code Vote up 4 votes
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRetainAll_emptyPreviouslyNonEmptyUnsupported() {
  expectThrows(empty);
  expectUnchanged();
}
 
Example 20
Project: guava-mock   File: CollectionRetainAllTester.java   View Source Code Vote up 4 votes
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRetainAll_supersetUnsupported() {
  expectReturnsFalseOrThrows(superset);
  expectUnchanged();
}