code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public void containsAnyIn(Iterable<? extends E> expected) {
Collection<A> actual = iterableToCollection(getCastActual());
Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable();
for (E expectedItem : expected) {
for (A actualItem : actual) {
if (corres... | Checks that the actual iterable contains at least one element that corresponds to at least
one of the expected elements. | containsAnyIn | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@SuppressWarnings("AvoidObjectArrays")
public void containsAnyIn(E[] expected) {
containsAnyIn(asList(expected));
} | Checks that the actual iterable contains at least one element that corresponds to at least
one of the expected elements. | containsAnyIn | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
private ImmutableList<Fact> describeAnyMatchesByKey(
Pairing<A, E> pairing, Correspondence.ExceptionStore exceptions) {
ImmutableList.Builder<Fact> facts = ImmutableList.builder();
for (Object key : pairing.pairedKeysToExpectedValues.keySet()) {
E expected = pairing.pairedKeysToExpectedValue... | Checks that the actual iterable contains at least one element that corresponds to at least
one of the expected elements. | describeAnyMatchesByKey | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@SafeVarargs
public final void containsNoneOf(
E firstExcluded, E secondExcluded, E @Nullable ... restOfExcluded) {
containsNoneIn(accumulate(firstExcluded, secondExcluded, restOfExcluded));
} | Checks that the actual iterable contains no elements that correspond to any of the given
elements. | containsNoneOf | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@SuppressWarnings("nullness") // TODO: b/423853632 - Remove after checker is fixed.
public void containsNoneIn(Iterable<? extends E> excluded) {
Collection<A> actual = iterableToCollection(getCastActual());
ListMultimap<E, A> present = LinkedListMultimap.create();
Correspondence.ExceptionStore exc... | Checks that the actual iterable contains no elements that correspond to any of the given
elements. | containsNoneIn | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@SuppressWarnings("AvoidObjectArrays")
public void containsNoneIn(E[] excluded) {
containsNoneIn(asList(excluded));
} | Checks that the subject contains no elements that correspond to any of the given elements. | containsNoneIn | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@SuppressWarnings("unchecked") // throwing ClassCastException is the correct behaviour
private Iterable<A> getCastActual() {
return (Iterable<A>) checkNotNull(subject.actual);
} | Checks that the subject contains no elements that correspond to any of the given elements. | getCastActual | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@Nullable Pairing<A, E> pair(
List<? extends E> expectedValues,
List<? extends A> actualValues,
Correspondence.ExceptionStore exceptions) {
Pairing<A, E> pairing = Pairing.create();
// Populate expectedKeys with the keys of the corresponding elements of expectedValues.
... | Returns a {@link Pairing} of the given expected and actual values, or {@code null} if the
expected values are not uniquely keyed. | pair | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
List<A> pairOne(
E expectedValue,
Iterable<? extends A> actualValues,
Correspondence.ExceptionStore exceptions) {
Object key = expectedKey(expectedValue, exceptions);
List<A> matches = new ArrayList<>();
if (key != null) {
for (A actual : actualValues) {
... | Returns a {@link Pairing} of the given expected and actual values, or {@code null} if the
expected values are not uniquely keyed. | pairOne | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
private @Nullable Object actualKey(A actual, Correspondence.ExceptionStore exceptions) {
try {
return actualKeyFunction.apply(actual);
} catch (RuntimeException e) {
exceptions.addActualKeyFunctionException(
IterableSubject.UsingCorrespondence.Pairer.class, e, actual);
... | Returns a {@link Pairing} of the given expected and actual values, or {@code null} if the
expected values are not uniquely keyed. | actualKey | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
private @Nullable Object expectedKey(E expected, Correspondence.ExceptionStore exceptions) {
try {
return expectedKeyFunction.apply(expected);
} catch (RuntimeException e) {
exceptions.addExpectedKeyFunctionException(
IterableSubject.UsingCorrespondence.Pairer.class, e,... | Returns a {@link Pairing} of the given expected and actual values, or {@code null} if the
expected values are not uniquely keyed. | expectedKey | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
static <A extends @Nullable Object, E extends @Nullable Object> Pairer<A, E> create(
Function<? super A, ?> actualKeyFunction, Function<? super E, ?> expectedKeyFunction) {
return new Pairer<>(actualKeyFunction, expectedKeyFunction);
} | Returns a {@link Pairing} of the given expected and actual values, or {@code null} if the
expected values are not uniquely keyed. | create | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
static <A extends @Nullable Object, E extends @Nullable Object> Pairing<A, E> create() {
return new Pairing<>();
} | List of the actual values not used in the pairing. Iterates in the order they appear in the
input. | create | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
static Factory<IterableSubject, Iterable<?>> iterables() {
return IterableSubject::new;
} | List of the actual values not used in the pairing. Iterates in the order they appear in the
input. | iterables | java | google/truth | core/src/main/java/com/google/common/truth/IterableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/IterableSubject.java | Apache-2.0 |
@Deprecated
@SuppressWarnings("InlineMeSuggester") // We want users to remove the surrounding call entirely.
public static Factory<LongStreamSubject, LongStream> longStreams() {
return LongStreamSubject::new;
} | Obsolete factory instance. This factory was previously necessary for assertions like {@code
assertWithMessage(...).about(longStreams()).that(stream)....}. Now, you can perform assertions
like that without the {@code about(...)} call.
@deprecated Instead of {@code about(longStreams()).that(...)}, use just {@code that(.... | longStreams | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
@SuppressWarnings("GoodTime") // false positive; b/122617528
public void containsAnyOf(long first, long second, long... rest) {
checkThatContentsList().containsAnyOf(first, second, box(rest));
} | Checks that the actual stream contains at least one of the given elements. | containsAnyOf | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
@SuppressWarnings("GoodTime") // false positive; b/122617528
@CanIgnoreReturnValue
public Ordered containsAtLeast(long first, long second, long... rest) {
return checkThatContentsList().containsAtLeast(first, second, box(rest));
} | Checks that the actual stream contains all of the given elements. If an element appears more
than once in the given elements, then it must appear at least that number of times in the
actual elements.
<p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
on the object returned by... | containsAtLeast | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public Ordered containsAtLeastElementsIn(@Nullable Iterable<?> expected) {
return checkThatContentsList().containsAtLeastElementsIn(expected);
} | Checks that the actual stream contains all of the given elements. If an element appears more
than once in the given elements, then it must appear at least that number of times in the
actual elements.
<p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
on the object returned by... | containsAtLeastElementsIn | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public Ordered containsExactlyElementsIn(@Nullable Iterable<?> expected) {
return checkThatContentsList().containsExactlyElementsIn(expected);
} | Checks that the actual stream contains exactly the given elements.
<p>Multiplicity is respected. For example, an object duplicated exactly 3 times in the
parameters asserts that the object must likewise be duplicated exactly 3 times in the actual
stream.
<p>To also test that the contents appear in the given order, ma... | containsExactlyElementsIn | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
@SuppressWarnings("GoodTime") // false positive; b/122617528
public void containsNoneOf(long first, long second, long... rest) {
checkThatContentsList().containsNoneOf(first, second, box(rest));
} | Checks that the actual stream does not contain any of the given elements. | containsNoneOf | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
private IterableSubject checkThatContentsList() {
return substituteCheck().that(listSupplier.get());
} | Be careful with using this, as documented on {@link Subject#substituteCheck}. | checkThatContentsList | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
private static Supplier<@Nullable List<?>> listCollector(@Nullable LongStream actual) {
return () -> actual == null ? null : actual.boxed().collect(toCollection(ArrayList::new));
} | Be careful with using this, as documented on {@link Subject#substituteCheck}. | listCollector | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
private static Object[] box(long[] rest) {
return LongStream.of(rest).boxed().toArray(Long[]::new);
} | Be careful with using this, as documented on {@link Subject#substituteCheck}. | box | java | google/truth | core/src/main/java/com/google/common/truth/LongStreamSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongStreamSubject.java | Apache-2.0 |
@Deprecated
@Override
public boolean equals(@Nullable Object o) {
throw new UnsupportedOperationException(
"If you meant to compare longs, use .of(long) instead.");
} | @throws UnsupportedOperationException always
@deprecated {@link Object#equals(Object)} is not supported on TolerantLongComparison. If you
meant to compare longs, use {@link #of(long)} instead. | equals | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
@Deprecated
@Override
public int hashCode() {
throw new UnsupportedOperationException("Subject.hashCode() is not supported.");
} | @throws UnsupportedOperationException always
@deprecated {@link Object#hashCode()} is not supported on TolerantLongComparison | hashCode | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
static TolerantLongComparison create(LongComparer comparer) {
return new TolerantLongComparison(comparer);
} | @throws UnsupportedOperationException always
@deprecated {@link Object#hashCode()} is not supported on TolerantLongComparison | create | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
public TolerantLongComparison isWithin(long tolerance) {
return TolerantLongComparison.create(
other -> {
if (tolerance < 0) {
failWithoutActual(
simpleFact(
"could not perform approximate-equality check because tolerance is negative"),
... | Prepares for a check that the actual value is a number within the given tolerance of an
expected value that will be provided in the next call in the fluent chain.
@param tolerance an inclusive upper bound on the difference between the actual value and
expected value allowed by the check, which must be a non-negati... | isWithin | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
public TolerantLongComparison isNotWithin(long tolerance) {
return TolerantLongComparison.create(
other -> {
if (tolerance < 0) {
failWithoutActual(
simpleFact(
"could not perform approximate-equality check because tolerance is negative"),
... | Prepares for a check that the actual value is a number not within the given tolerance of an
expected value that will be provided in the next call in the fluent chain.
@param tolerance an exclusive lower bound on the difference between the actual value and
expected value allowed by the check, which must be a non-ne... | isNotWithin | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
@Override
@Deprecated
public final void isEquivalentAccordingToCompareTo(@Nullable Long other) {
super.isEquivalentAccordingToCompareTo(other);
} | @deprecated Use {@link #isEqualTo} instead. Long comparison is consistent with equality. | isEquivalentAccordingToCompareTo | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
public final void isGreaterThan(int other) {
isGreaterThan((long) other);
} | Checks that the actual value is greater than {@code other}.
<p>To check that the actual value is greater than <i>or equal to</i> {@code other}, use {@link
#isAtLeast}. | isGreaterThan | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
public final void isLessThan(int other) {
isLessThan((long) other);
} | Checks that the actual value is less than {@code other}.
<p>To check that the actual value is less than <i>or equal to</i> {@code other}, use {@link
#isAtMost} . | isLessThan | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
public final void isAtMost(int other) {
isAtMost((long) other);
} | Checks that the actual value is less than or equal to {@code other}.
<p>To check that the actual value is <i>strictly</i> less than {@code other}, use {@link
#isLessThan}. | isAtMost | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
public final void isAtLeast(int other) {
isAtLeast((long) other);
} | Checks that the actual value is greater than or equal to {@code other}.
<p>To check that the actual value is <i>strictly</i> greater than {@code other}, use {@link
#isGreaterThan}. | isAtLeast | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
static Factory<LongSubject, Long> longs() {
return LongSubject::new;
} | Checks that the actual value is greater than or equal to {@code other}.
<p>To check that the actual value is <i>strictly</i> greater than {@code other}, use {@link
#isGreaterThan}. | longs | java | google/truth | core/src/main/java/com/google/common/truth/LongSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/LongSubject.java | Apache-2.0 |
@Override
public final void isEqualTo(@Nullable Object other) {
if (Objects.equals(actual, other)) {
return;
}
// Fail but with a more descriptive message:
if (actual == null || !(other instanceof Map)) {
super.isEqualTo(other);
return;
}
containsEntriesInAnyOrder((Map<?, ... | Constructor for use by subclasses. If you want to create an instance of this class itself, call
{@link Subject#check(String, Object...) check(...)}{@code .that(actual)}. | isEqualTo | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final void isEmpty() {
if (!checkNotNull(actual).isEmpty()) {
failWithActual(simpleFact("expected to be empty"));
}
} | Checks that the actual map is empty. | isEmpty | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final void isNotEmpty() {
if (checkNotNull(actual).isEmpty()) {
failWithoutActual(simpleFact("expected not to be empty"));
}
} | Checks that the actual map is not empty. | isNotEmpty | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final void hasSize(int expectedSize) {
checkArgument(expectedSize >= 0, "expectedSize (%s) must be >= 0", expectedSize);
check("size()").that(checkNotNull(actual).size()).isEqualTo(expectedSize);
} | Checks that the actual map has the given size. | hasSize | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final void containsEntry(@Nullable Object key, @Nullable Object value) {
Map.Entry<@Nullable Object, @Nullable Object> entry = immutableEntry(key, value);
checkNotNull(actual);
if (!actual.entrySet().contains(entry)) {
List<@Nullable Object> keyList = singletonList(key);
List<@Nullable Ob... | Checks that the actual map contains the given entry. | containsEntry | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final void doesNotContainEntry(@Nullable Object key, @Nullable Object value) {
checkNoNeedToDisplayBothValues("entrySet()")
.that(checkNotNull(actual).entrySet())
.doesNotContain(immutableEntry(key, value));
} | Checks that the actual map does not contain the given entry. | doesNotContainEntry | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsExactly() {
return containsExactlyEntriesIn(ImmutableMap.of());
} | Checks that the actual map is empty. | containsExactly | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsExactly(
@Nullable Object k0, @Nullable Object v0, @Nullable Object... rest) {
return containsExactlyEntriesIn(accumulateMap("containsExactly", k0, v0, rest));
} | Checks that the actual map contains exactly the given set of key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs!
<p>The arguments must not contain duplicate keys. | containsExactly | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsAtLeast(
@Nullable Object k0, @Nullable Object v0, @Nullable Object... rest) {
return containsAtLeastEntriesIn(accumulateMap("containsAtLeast", k0, v0, rest));
} | Checks that the actual map contains exactly the given set of key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs!
<p>The arguments must not contain duplicate keys. | containsAtLeast | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private static Map<@Nullable Object, @Nullable Object> accumulateMap(
String functionName, @Nullable Object k0, @Nullable Object v0, @Nullable Object... rest) {
checkArgument(
rest.length % 2 == 0,
"There must be an equal number of key/value pairs "
+ "(i.e., the number of key/valu... | Checks that the actual map contains exactly the given set of key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs!
<p>The arguments must not contain duplicate keys. | accumulateMap | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsExactlyEntriesIn(Map<?, ?> expectedMap) {
if (expectedMap.isEmpty()) {
if (checkNotNull(actual).isEmpty()) {
return IN_ORDER;
} else {
isEmpty(); // fails
return ALREADY_FAILED;
}
}
boolean containsAnyOrder = cont... | Checks that the actual map contains exactly the given set of entries in the given map. | containsExactlyEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsAtLeastEntriesIn(Map<?, ?> expectedMap) {
if (expectedMap.isEmpty()) {
return IN_ORDER;
}
boolean containsAnyOrder = containsEntriesInAnyOrder(expectedMap, /* allowUnexpected= */ true);
if (containsAnyOrder) {
return MapInOrder.create(
... | Checks that the actual map contains at least the given set of entries in the given map. | containsAtLeastEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
private boolean containsEntriesInAnyOrder(Map<?, ?> expectedMap, boolean allowUnexpected) {
MapDifference<@Nullable Object, @Nullable Object, @Nullable Object> diff =
MapDifference.create(checkNotNull(actual), expectedMap, allowUnexpected, Objects::equals);
if (diff.isEmpty()) {
... | Checks that the actual map contains at least the given set of entries in the given map. | containsEntriesInAnyOrder | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
static <K extends @Nullable Object, A extends @Nullable Object, E extends @Nullable Object>
MapDifference<K, A, E> create(
Map<? extends K, ? extends A> actual,
Map<? extends K, ? extends E> expected,
boolean allowUnexpected,
ValueTester<? super A, ? super E> valu... | Checks that the actual map contains at least the given set of entries in the given map. | create | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
boolean isEmpty() {
return missing.isEmpty() && unexpected.isEmpty() && wrongValues.isEmpty();
} | Checks that the actual map contains at least the given set of entries in the given map. | isEmpty | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
ImmutableList<Fact> describe(@Nullable Differ<? super A, ? super E> differ) {
boolean includeKeyTypes = includeKeyTypes();
ImmutableList.Builder<Fact> facts = ImmutableList.builder();
if (!wrongValues.isEmpty()) {
facts.add(simpleFact("keys with wrong values"));
}
for (Map.Entry<K,... | Checks that the actual map contains at least the given set of entries in the given map. | describe | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private boolean includeKeyTypes() {
// We will annotate all the keys in the diff with their types if any of the keys involved have
// the same toString() without being equal.
Set<K> keys = new HashSet<>();
keys.addAll(missing.keySet());
keys.addAll(unexpected.keySet());
keys.addAll(w... | Checks that the actual map contains at least the given set of entries in the given map. | includeKeyTypes | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
ImmutableList<Fact> describe(@Nullable Differ<? super A, ? super E> differ) {
boolean includeTypes =
differ == null && String.valueOf(actual).equals(String.valueOf(expected));
ImmutableList.Builder<Fact> facts =
ImmutableList.<Fact>builder()
.add(fact("expected value", mayb... | Checks that the actual map contains at least the given set of entries in the given map. | describe | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
static <A extends @Nullable Object, E extends @Nullable Object> ValueDifference<A, E> create(
A actual, E expected) {
return new ValueDifference<>(actual, expected);
} | Checks that the actual map contains at least the given set of entries in the given map. | create | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private static String maybeAddType(@Nullable Object o, boolean includeTypes) {
return includeTypes ? lenientFormat("%s (%s)", o, objectToTypeName(o)) : String.valueOf(o);
} | Checks that the actual map contains at least the given set of entries in the given map. | maybeAddType | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@Override
public void inOrder() {
// We're using the fact that Sets.intersection keeps the order of the first set.
checkNotNull(subject.actual);
List<?> expectedKeyOrder =
new ArrayList<>(Sets.intersection(expectedMap.keySet(), subject.actual.keySet()));
List<?> actualKeyOrder =
... | Checks whether the common elements between actual and expected are in the same order.
<p>This doesn't check whether the keys have the same values or whether all the required keys
are actually present. That was supposed to be done before the "in order" part. | inOrder | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
static MapInOrder create(
MapSubject subject,
Map<?, ?> expectedMap,
boolean allowUnexpected,
@Nullable Correspondence<?, ?> correspondence) {
return new MapInOrder(subject, expectedMap, allowUnexpected, correspondence);
} | Checks whether the common elements between actual and expected are in the same order.
<p>This doesn't check whether the keys have the same values or whether all the required keys
are actually present. That was supposed to be done before the "in order" part. | create | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final <A extends @Nullable Object, E extends @Nullable Object>
UsingCorrespondence<A, E> comparingValuesUsing(
Correspondence<? super A, ? super E> correspondence) {
return UsingCorrespondence.create(this, correspondence);
} | Starts a method chain for a check in which the actual values (i.e. the values of the {@link
Map} under test) are compared to expected values using the given {@link Correspondence}. The
actual values must be of type {@code A}, the expected values must be of type {@code E}. The
check is actually executed by continuing th... | comparingValuesUsing | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
public final <V extends @Nullable Object> UsingCorrespondence<V, V> formattingDiffsUsing(
DiffFormatter<? super V, ? super V> formatter) {
return comparingValuesUsing(Correspondence.<V>equality().formattingDiffsUsing(formatter));
} | Starts a method chain for a check in which failure messages may use the given {@link
DiffFormatter} to describe the difference between an actual map (i.e. a value in the {@link
Map} under test) and the value it is expected to be equal to, but isn't. The actual and
expected values must be of type {@code V}. The check is... | formattingDiffsUsing | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@SuppressWarnings("UnnecessaryCast") // needed by nullness checker
public void containsEntry(@Nullable Object expectedKey, E expectedValue) {
if (checkNotNull(actual).containsKey(expectedKey)) {
// Found matching key.
A actualValue = getCastSubject().get(expectedKey);
Correspondence.Ex... | Checks that the actual map contains an entry with the given key and a value that corresponds
to the given value. | containsEntry | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@SuppressWarnings("UnnecessaryCast") // needed by nullness checker
public void doesNotContainEntry(@Nullable Object excludedKey, E excludedValue) {
if (checkNotNull(actual).containsKey(excludedKey)) {
// Found matching key. Fail if the value matches, too.
A actualValue = getCastSubject().get(e... | Checks that the actual map does not contain an entry with the given key and a value that
corresponds to the given value. | doesNotContainEntry | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public Ordered containsExactly(@Nullable Object k0, @Nullable E v0, @Nullable Object... rest) {
@SuppressWarnings("unchecked") // throwing ClassCastException is the correct behaviour
Map<Object, E> expectedMap = (Map<Object, E>) accumulateMap("containsExactly", k0, v0, rest);
... | Checks that the actual map contains exactly the given set of keys mapping to values that
correspond to the given values.
<p>The values must all be of type {@code E}, and a {@link ClassCastException} will be thrown
if any other type is encountered.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee a... | containsExactly | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public Ordered containsAtLeast(@Nullable Object k0, @Nullable E v0, @Nullable Object... rest) {
@SuppressWarnings("unchecked") // throwing ClassCastException is the correct behaviour
Map<Object, E> expectedMap = (Map<Object, E>) accumulateMap("containsAtLeast", k0, v0, rest);
... | Checks that the actual map contains at least the given set of keys mapping to values that
correspond to the given values.
<p>The values must all be of type {@code E}, and a {@link ClassCastException} will be thrown
if any other type is encountered.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee ... | containsAtLeast | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public Ordered containsExactlyEntriesIn(Map<?, ? extends E> expectedMap) {
if (expectedMap.isEmpty()) {
if (checkNotNull(actual).isEmpty()) {
return IN_ORDER;
} else {
subject.isEmpty(); // fails
return ALREADY_FAILED;
}
}
... | Checks that the actual map contains exactly the keys in the given map, mapping to values that
correspond to the values of the given map. | containsExactlyEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public Ordered containsAtLeastEntriesIn(Map<?, ? extends E> expectedMap) {
if (expectedMap.isEmpty()) {
return IN_ORDER;
}
return internalContainsEntriesIn(expectedMap, /* allowUnexpected= */ true);
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | containsAtLeastEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private <K extends @Nullable Object, V extends E> Ordered internalContainsEntriesIn(
Map<K, V> expectedMap, boolean allowUnexpected) {
Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forMapValues();
MapDifference<@Nullable Object, A, V> diff =
MapDifference.create(... | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | internalContainsEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private <V extends E> Differ<A, V> differ(Correspondence.ExceptionStore exceptions) {
return (actual, expected) -> correspondence.safeFormatDiff(actual, expected, exceptions);
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | differ | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
@SuppressWarnings("unchecked") // throwing ClassCastException is the correct behaviour
private Map<?, A> getCastSubject() {
return (Map<?, A>) checkNotNull(actual);
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | getCastSubject | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private String actualCustomStringRepresentationForPackageMembersToCall() {
return subject.actualCustomStringRepresentationForPackageMembersToCall();
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | actualCustomStringRepresentationForPackageMembersToCall | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
private Fact butWas() {
return subject.butWas();
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | butWas | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
static <A extends @Nullable Object, E extends @Nullable Object>
UsingCorrespondence<A, E> create(
MapSubject subject, Correspondence<? super A, ? super E> correspondence) {
return new UsingCorrespondence<>(subject, correspondence);
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | create | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
static Factory<MapSubject, Map<?, ?>> maps() {
return MapSubject::new;
} | Checks that the actual map contains at least the keys in the given map, mapping to values
that correspond to the values of the given map. | maps | java | google/truth | core/src/main/java/com/google/common/truth/MapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MapSubject.java | Apache-2.0 |
static boolean equalWithinTolerance(long left, long right, long tolerance) {
try {
long absDiff = abs(subtractExact(left, right));
return 0 <= absDiff && absDiff <= abs(tolerance);
} catch (ArithmeticException e) {
// The numbers are so far apart their difference isn't even a long.
retur... | Returns true iff {@code left} and {@code right} are values within {@code tolerance} of each
other. | equalWithinTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
static boolean equalWithinTolerance(int left, int right, int tolerance) {
try {
int absDiff = abs(subtractExact(left, right));
return 0 <= absDiff && absDiff <= abs(tolerance);
} catch (ArithmeticException e) {
// The numbers are so far apart their difference isn't even a int.
return fal... | Returns true iff {@code left} and {@code right} are values within {@code tolerance} of each
other. | equalWithinTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
public static boolean equalWithinTolerance(double left, double right, double tolerance) {
return abs(left - right) <= abs(tolerance);
} | Returns true iff {@code left} and {@code right} are finite values within {@code tolerance} of
each other. Note that both this method and {@link #notEqualWithinTolerance} returns false if
either {@code left} or {@code right} is infinite or NaN. | equalWithinTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
public static boolean equalWithinTolerance(float left, float right, float tolerance) {
return equalWithinTolerance(left, right, (double) tolerance);
} | Returns true iff {@code left} and {@code right} are finite values within {@code tolerance} of
each other. Note that both this method and {@link #notEqualWithinTolerance} returns false if
either {@code left} or {@code right} is infinite or NaN. | equalWithinTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
public static boolean notEqualWithinTolerance(double left, double right, double tolerance) {
return isFinite(left) && isFinite(right) && abs(left - right) > abs(tolerance);
} | Returns true iff {@code left} and {@code right} are finite values not within {@code tolerance}
of each other. Note that both this method and {@link #equalWithinTolerance} returns false if
either {@code left} or {@code right} is infinite or NaN. | notEqualWithinTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
public static boolean notEqualWithinTolerance(float left, float right, float tolerance) {
return notEqualWithinTolerance(left, right, (double) tolerance);
} | Returns true iff {@code left} and {@code right} are finite values not within {@code tolerance}
of each other. Note that both this method and {@link #equalWithinTolerance} returns false if
either {@code left} or {@code right} is infinite or NaN. | notEqualWithinTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
static void checkTolerance(double tolerance) {
checkArgument(!Double.isNaN(tolerance), "tolerance cannot be NaN");
checkArgument(
Double.compare(tolerance, 0.0) >= 0, "tolerance (%s) cannot be negative", tolerance);
checkArgument(tolerance != Double.POSITIVE_INFINITY, "tolerance cannot be POSITIVE_I... | Ensures that the given tolerance is a non-negative finite value, i.e. not {@code Double.NaN},
{@code Double.POSITIVE_INFINITY}, or negative, including {@code -0.0}. | checkTolerance | java | google/truth | core/src/main/java/com/google/common/truth/MathUtil.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MathUtil.java | Apache-2.0 |
public final void isEmpty() {
if (!checkNotNull(actual).isEmpty()) {
failWithActual(simpleFact("expected to be empty"));
}
} | Checks that the actual multimap is empty. | isEmpty | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
public final void isNotEmpty() {
if (checkNotNull(actual).isEmpty()) {
failWithoutActual(simpleFact("expected not to be empty"));
}
} | Checks that the actual multimap is not empty. | isNotEmpty | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
public final void hasSize(int expectedSize) {
checkArgument(expectedSize >= 0, "expectedSize(%s) must be >= 0", expectedSize);
check("size()").that(checkNotNull(actual).size()).isEqualTo(expectedSize);
} | Checks that the actual multimap has the given size. | hasSize | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
public final void containsEntry(@Nullable Object key, @Nullable Object value) {
// TODO(kak): Can we share any of this logic w/ MapSubject.containsEntry()?
checkNotNull(actual);
if (!actual.containsEntry(key, value)) {
Map.Entry<@Nullable Object, @Nullable Object> entry = immutableEntry(key, value);
... | Checks that the actual multimap contains the given entry. | containsEntry | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
public final void doesNotContainEntry(@Nullable Object key, @Nullable Object value) {
checkNoNeedToDisplayBothValues("entries()")
.that(checkNotNull(actual).entries())
.doesNotContain(immutableEntry(key, value));
} | Checks that the actual multimap does not contain the given entry. | doesNotContainEntry | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@SuppressWarnings("unchecked") // safe because we only read, not write
/*
* non-final because it's overridden by MultimapWithProtoValuesSubject.
*
* If we really, really wanted it to be final, we could investigate whether
* MultimapWithProtoValuesFluentAssertion could provide its own valuesForKey method. ... | Returns a {@link Subject} for making assertions about the values for the given key within the
{@link Multimap}.
<p>This method performs no checks on its own and cannot cause test failures. Subsequent
assertions must be chained onto this method call to test properties of the {@link Multimap}. | valuesForKey | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@Override
public final void isEqualTo(@Nullable Object other) {
@SuppressWarnings("UndefinedEquals") // the contract of this method is to follow Multimap.equals
boolean isEqual = Objects.equals(actual, other);
if (isEqual) {
return;
}
// Fail but with a more descriptive message:
if ((ac... | Returns a {@link Subject} for making assertions about the values for the given key within the
{@link Multimap}.
<p>This method performs no checks on its own and cannot cause test failures. Subsequent
assertions must be chained onto this method call to test properties of the {@link Multimap}. | isEqualTo | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsExactlyEntriesIn(Multimap<?, ?> expectedMultimap) {
checkNotNull(expectedMultimap, "expectedMultimap");
checkNotNull(actual);
ListMultimap<?, ?> missing = difference(expectedMultimap, actual);
ListMultimap<?, ?> extra = difference(actual, expectedMult... | Checks that the actual multimap contains precisely the same entries as the argument {@link
Multimap}.
<p>A subsequent call to {@link Ordered#inOrder} may be made if the caller wishes to verify that
the two multimaps iterate fully in the same order. That is, their key sets iterate in the same
order, and the value colle... | containsExactlyEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsAtLeastEntriesIn(Multimap<?, ?> expectedMultimap) {
checkNotNull(expectedMultimap, "expectedMultimap");
checkNotNull(actual);
ListMultimap<?, ?> missing = difference(expectedMultimap, actual);
// TODO(kak): Possible enhancement: Include "[1 copy]" if... | Checks that the actual multimap contains at least the entries in the argument {@link Multimap}.
<p>A subsequent call to {@link Ordered#inOrder} may be made if the caller wishes to verify that
the entries are present in the same order as given. That is, the keys are present in the given
order in the key set, and the va... | containsAtLeastEntriesIn | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsExactly() {
return substituteCheck()
.about(iterableEntries())
.that(checkNotNull(actual).entries())
.containsExactly();
} | Checks that the actual multimap is empty. | containsExactly | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsExactly(
@Nullable Object k0, @Nullable Object v0, @Nullable Object... rest) {
return containsExactlyEntriesIn(accumulateMultimap(k0, v0, rest));
} | Checks that the actual multimap contains exactly the given set of key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! | containsExactly | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@CanIgnoreReturnValue
public final Ordered containsAtLeast(
@Nullable Object k0, @Nullable Object v0, @Nullable Object... rest) {
return containsAtLeastEntriesIn(accumulateMultimap(k0, v0, rest));
} | Checks that the actual multimap contains at least the given key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! | containsAtLeast | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
private static ListMultimap<@Nullable Object, @Nullable Object> accumulateMultimap(
@Nullable Object k0, @Nullable Object v0, @Nullable Object... rest) {
checkArgument(
rest.length % 2 == 0,
"There must be an equal number of key/value pairs "
+ "(i.e., the number of key/value param... | Checks that the actual multimap contains at least the given key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! | accumulateMultimap | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
private Factory<IterableSubject, Iterable<?>> iterableEntries() {
return (metadata, actual) ->
IterableEntries.create(metadata, checkNotNull(actual), MultimapSubject.this);
} | Checks that the actual multimap contains at least the given key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! | iterableEntries | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@Override
protected String actualCustomStringRepresentation() {
// We want to use the multimap's toString() instead of the iterable of entries' toString():
return multimapSubject.actualCustomStringRepresentationForPackageMembersToCall();
} | Checks that the actual multimap contains at least the given key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! | actualCustomStringRepresentation | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
static IterableEntries create(
FailureMetadata metadata, Iterable<?> actual, MultimapSubject multimapSubject) {
return new IterableEntries(metadata, actual, multimapSubject);
} | Checks that the actual multimap contains at least the given key/value pairs.
<p><b>Warning:</b> the use of varargs means that we cannot guarantee an equal number of
key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! | create | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@Override
public void inOrder() {
// We use the fact that Sets.intersection's result has the same order as the first parameter
checkNotNull(subject.actual);
@SuppressWarnings("nullness") // TODO: b/339070656: Remove suppression after fix.
boolean keysInOrder =
new ArrayList<>(Sets.... | Checks whether entries in expected appear in the same order in actual.
<p>We allow for actual to have more items than the expected to support both {@link
#containsExactly} and {@link #containsAtLeast}. | inOrder | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
static MultimapInOrder create(
MultimapSubject subject, boolean allowUnexpected, Multimap<?, ?> expectedMultimap) {
return new MultimapInOrder(subject, allowUnexpected, expectedMultimap);
} | Checks whether entries in expected appear in the same order in actual.
<p>We allow for actual to have more items than the expected to support both {@link
#containsExactly} and {@link #containsAtLeast}. | create | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
private static boolean advanceToFind(Iterator<?> iterator, @Nullable Object value) {
while (iterator.hasNext()) {
if (Objects.equals(iterator.next(), value)) {
return true;
}
}
return false;
} | Advances the iterator until it either returns value, or has no more elements.
<p>Returns true if the value was found, false if the end was reached before finding it.
<p>This is basically the same as {@link com.google.common.collect.Iterables#contains}, but
where the contract explicitly states that the iterator isn't ... | advanceToFind | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
@SuppressWarnings("EmptyList") // ImmutableList doesn't support nullable types
private static <V extends @Nullable Object> Collection<V> get(
Multimap<?, V> multimap, @Nullable Object key) {
if (multimap.containsKey(key)) {
return checkNotNull(multimap.asMap().get(key));
} else {
return empt... | Advances the iterator until it either returns value, or has no more elements.
<p>Returns true if the value was found, false if the end was reached before finding it.
<p>This is basically the same as {@link com.google.common.collect.Iterables#contains}, but
where the contract explicitly states that the iterator isn't ... | get | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
private static ListMultimap<?, ?> difference(Multimap<?, ?> minuend, Multimap<?, ?> subtrahend) {
ListMultimap<@Nullable Object, @Nullable Object> difference = LinkedListMultimap.create();
for (Object key : minuend.keySet()) {
List<?> valDifference =
difference(new ArrayList<>(get(minuend, key))... | Advances the iterator until it either returns value, or has no more elements.
<p>Returns true if the value was found, false if the end was reached before finding it.
<p>This is basically the same as {@link com.google.common.collect.Iterables#contains}, but
where the contract explicitly states that the iterator isn't ... | difference | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
private static List<?> difference(List<?> minuend, List<?> subtrahend) {
LinkedHashMultiset<@Nullable Object> remaining =
LinkedHashMultiset.<@Nullable Object>create(subtrahend);
List<@Nullable Object> difference = new ArrayList<>();
for (Object elem : minuend) {
if (!remaining.remove(elem)) {... | Advances the iterator until it either returns value, or has no more elements.
<p>Returns true if the value was found, false if the end was reached before finding it.
<p>This is basically the same as {@link com.google.common.collect.Iterables#contains}, but
where the contract explicitly states that the iterator isn't ... | difference | java | google/truth | core/src/main/java/com/google/common/truth/MultimapSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/MultimapSubject.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.