private Entry<K, V>[] getEntriesMultipleNonNullKeys() { Entry<K, V>[] entries = createSamplesArray(); entries[0] = entry(k1(), v0()); return entries; }
/** * Used to delay string formatting until actually required, as it otherwise shows up in the test * execution profile when running an extremely large numbers of tests. */ private String reportContext(List<E> expected) { return Platform.format( "expected collection %s; actual collection %s", expected, this.collection); } }
@Override protected void verify(List<E> elements) { expectContents(elements); } }.test();
@Override protected Collection<Method> suppressForTreeMapNatural() { return Arrays.asList( getPutNullKeyUnsupportedMethod(), getPutAllNullKeyUnsupportedMethod(), getCreateWithNullKeyUnsupportedMethod(), getCreateWithNullUnsupportedMethod(), // for keySet getContainsEntryWithIncomparableKeyMethod(), getContainsEntryWithIncomparableValueMethod()); }
protected Collection<Method> suppressForCopyOnWriteArrayList() { return asList( getSubListOriginalListSetAffectsSubListMethod(), getSubListOriginalListSetAffectsSubListLargeListMethod(), getSubListSubListRemoveAffectsOriginalLargeListMethod(), getListIteratorFullyModifiableMethod(), getSpliteratorNotImmutableCollectionAllowsAddMethod(), getSpliteratorNotImmutableCollectionAllowsRemoveMethod()); }
private void runRemoveTest(int index) { assertEquals( Platform.format("remove(%d) should return the element at index %d", index, index), getList().get(index), getList().remove(index)); List<E> expected = Helpers.copyToList(createSamplesArray()); expected.remove(index); expectContents(expected); } }
@Override protected Collection<Method> suppressForCheckedList() { return Arrays.asList( CollectionAddTester.getAddNullSupportedMethod(), getAddSupportedNullPresentMethod(), ListAddAtIndexTester.getAddNullSupportedMethod(), getSetNullSupportedMethod()); } }
public void testFind_no() { assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3())); }
public void testFind_wrongType() { try { assertEquals( getMethodName() + "(wrongType) should return -1 or throw", -1, find(WrongType.VALUE)); } catch (ClassCastException tolerated) { } } }
@Override protected Collection<Method> suppressForTreeSetNatural() { return Arrays.asList( getAddNullUnsupportedMethod(), getAddAllNullUnsupportedMethod(), getCreateWithNullUnsupportedMethod()); }
public void testGet_no() { assertNull("get(notPresent) should return null", get(k3())); }
private void expectReturnsFalseOrThrows(Target target) { String message = Platform.format("retainAll(%s) should return false or throw", target); try { assertFalse(message, collection.retainAll(target.toRetain)); } catch (UnsupportedOperationException tolerated) { } } }
private void runIteratorTest( Set<IteratorFeature> features, IteratorTester.KnownOrder knownOrder, Iterable<E> elements) { new IteratorTester<E>( Platform.collectionIteratorTesterNumIterations(), features, elements, knownOrder) { @Override protected Iterator<E> newTargetIterator() { resetCollection(); return collection.iterator(); } @Override protected void verify(List<E> elements) { expectContents(elements); } }.test(); }
public void testGet_valid() { // This calls get() on each index and checks the result: expectContents(createOrderedArray()); }
private void expectReturnsTrue(Target target) { String message = Platform.format("retainAll(%s) should return true", target); assertTrue(message, collection.retainAll(target.toRetain)); }
@Override protected Collection<Method> suppressForCheckedSet() { return Arrays.asList(getAddNullSupportedMethod(), getAddSupportedNullPresentMethod()); } }
/** Resets the contents of navigableSet to have elements a, c, for the navigation tests. */ protected void resetWithHole() { super.resetContainer(getSubjectGenerator().create(a, c)); navigableSet = (NavigableSet<E>) getSet(); }
@CollectionFeature.Require(absent = ALLOWS_NULL_VALUES) public void testFind_nullNotContainedAndUnsupported() { try { assertEquals(getMethodName() + "(nullNotPresent) should return -1 or throw", -1, find(null)); } catch (NullPointerException tolerated) { } }
private void expectReturnsFalse(Target target) { String message = Platform.format("retainAll(%s) should return false", target); assertFalse(message, collection.retainAll(target.toRetain)); }