code
stringlengths
25
201k
docstring
stringlengths
19
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
51
path
stringlengths
11
314
url
stringlengths
62
377
license
stringclasses
7 values
protected final StandardSubjectBuilder ignoreCheck() { return StandardSubjectBuilder.forCustomFailureStrategy(failure -> {}); }
Begins a new call chain that ignores any failures. This is useful for subjects that normally delegate with to other subjects by using {@link #check} but have already reported a failure. In such cases it may still be necessary to return a {@code Subject} instance even though any subsequent assertions are meaningless. Fo...
ignoreCheck
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
protected final void failWithActual(String key, @Nullable Object value) { failWithActual(fact(key, value)); }
Fails, reporting a message with two "{@linkplain Fact facts}": <ul> <li><i>key</i>: <i>value</i> <li>but was: <i>actual value</i>. </ul> <p>This is the simplest failure API. For more advanced needs, see {@linkplain #failWithActual(Fact, Fact...) the other overload} and {@link #failWithoutActual(Fact, Fact...) fai...
failWithActual
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
protected final void failWithActual(Fact first, Fact... rest) { metadata.fail(sandwich(first, rest, butWas())); }
Fails, reporting a message with the given facts, followed by an automatically added fact of the form: <ul> <li>but was: <i>actual value</i>. </ul> <p>If you have only one fact to report (and it's a {@linkplain Fact#fact key-value fact}), prefer {@linkplain #failWithActual(String, Object) the simpler overload}. <p>...
failWithActual
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
final void failWithActual(Iterable<Fact> facts) { metadata.fail(append(ImmutableList.copyOf(facts), butWas())); }
Internal variant of {@link #failWithActual(Fact, Fact...)} that accepts an {@link Iterable}. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} met...
failWithActual
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void fail(String check) { fail(check, new Object[0]); }
Legacy failure method. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} methods may instea...
fail
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void fail(String verb, Object other) { fail(verb, new Object[] {other}); }
Legacy failure method. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} methods may instea...
fail
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void fail(String verb, @Nullable Object... messageParts) { StringBuilder message = new StringBuilder("Not true that <"); message.append(actualCustomStringRepresentation()).append("> ").append(verb); for (Object part : messageParts) { message.append(" <").append(part).append(">"); ...
Legacy failure method. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} methods may instea...
fail
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
final void failEqualityCheckForEqualsWithoutDescription(@Nullable Object expected) { failEqualityCheck(EqualityCheck.EQUAL, expected, ComparisonResult.differentNoDescription()); }
Special version of {@link #failEqualityCheck} for use from {@link IterableSubject}, documented further there. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@...
failEqualityCheckForEqualsWithoutDescription
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
private void failEqualityCheck( EqualityCheck equalityCheck, @Nullable Object expected, ComparisonResult difference) { String actualString = actualCustomStringRepresentation(); String expectedString = formatActualOrExpected(expected); String actualClass = actual == null ? "(null reference)" : actual.g...
Fails, potentially producing a {@code ComparisonFailure}. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} methods may instead record the failure...
failEqualityCheck
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void failWithBadResults( String verb, @Nullable Object expected, String failVerb, @Nullable Object actual) { String message = lenientFormat( "Not true that <%s> %s <%s>. It %s <%s>", actualCustomStringRepresentation(), verb, expected,...
Legacy failure method. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} methods may instea...
failWithBadResults
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void failWithCustomSubject( String verb, @Nullable Object expected, @Nullable Object actual) { String message = lenientFormat( "Not true that <%s> %s <%s>", actual == null ? "null reference" : actual, verb, expected); failWithoutActual(simpleFact(message...
Legacy failure method that accepts an alternative representation of the actual value. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy},...
failWithCustomSubject
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void failWithoutSubject(String check) { failWithoutActual(simpleFact(lenientFormat("Not true that the subject %s", check))); }
Legacy failure method. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@code fail*()} methods may instea...
failWithoutSubject
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
protected final void failWithoutActual(Fact first, Fact... rest) { metadata.fail(ImmutableList.copyOf(Lists.asList(first, rest))); }
Fails, reporting a message with the given facts, <i>without automatically adding the actual value.</i> <p>Most failure messages should report the actual value, so most checks should call {@link #failWithActual(Fact, Fact...) failWithActual} instead. However, {@code failWithoutActual} is useful in some cases: <ul> <...
failWithoutActual
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@Deprecated final void failWithoutActual(String check) { failWithoutSubject(check); }
Legacy failure method that excludes the actual value. Prefer the {@code fail*Actual(...)} family of methods. <p><b>Note:</b> While Truth's {@code fail*()} methods usually throw {@link AssertionError}, they do not do so in all cases: When users use an alternative {@link FailureStrategy}, such as {@link Expect}, the {@c...
failWithoutActual
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@DoNotCall( "Subject.equals() is not supported. Did you mean to call" + " assertThat(actual).isEqualTo(expected) instead of" + " assertThat(actual).equals(expected)?") @Deprecated @Override public final boolean equals(@Nullable Object o) { throw new UnsupportedOperationException( ...
@throws UnsupportedOperationException always @deprecated {@link Object#equals(Object)} is not supported on Truth subjects. If you are writing a test assertion (actual vs. expected), use {@link #isEqualTo(Object)} instead.
equals
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
@DoNotCall("Subject.hashCode() is not supported.") @Deprecated @Override public final int hashCode() { throw new UnsupportedOperationException("Subject.hashCode() is not supported."); }
@throws UnsupportedOperationException always @deprecated {@link Object#hashCode()} is not supported on Truth subjects.
hashCode
java
google/truth
core/src/main/java/com/google/common/truth/Subject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Subject.java
Apache-2.0
static String countDuplicatesAndAddTypeInfo(Iterable<?> itemsIterable) { Collection<?> items = iterableToCollection(itemsIterable); String homogeneousTypeName = getHomogeneousTypeName(items); return homogeneousTypeName != null ? lenientFormat("%s (%s)", countDuplicates(items), homogeneousTypeName) ...
Makes a String representation of {@code items} with collapsed duplicates and additional class info. <p>Example: {@code countDuplicatesAndAddTypeInfo([1, 2, 2, 3]) == "[1, 2 [3 copies]] (java.lang.Integer)"} and {@code countDuplicatesAndAddTypeInfo([1, 2L]) == "[1 (java.lang.Integer), 2 (java.lang.Long)]"}.
countDuplicatesAndAddTypeInfo
java
google/truth
core/src/main/java/com/google/common/truth/SubjectUtils.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/SubjectUtils.java
Apache-2.0
static List<@Nullable Object> retainMatchingToString( Iterable<?> items, Iterable<?> itemsToCheck) { ListMultimap<String, @Nullable Object> stringValueToItemsToCheck = ArrayListMultimap.create(); for (Object itemToCheck : itemsToCheck) { stringValueToItemsToCheck.put(String.valueOf(itemToCheck), ite...
Returns a new collection containing all elements in {@code items} for which there exists at least one element in {@code itemsToCheck} that has the same {@code toString()} value without being equal. <p>Example: {@code retainMatchingToString([1L, 2L, 2L], [2, 3]) == [2L, 2L]}
retainMatchingToString
java
google/truth
core/src/main/java/com/google/common/truth/SubjectUtils.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/SubjectUtils.java
Apache-2.0
public void isEmpty() { if (!checkNotNull(actual).isEmpty()) { failWithActual(simpleFact("expected to be empty")); } }
Checks that the actual table is empty.
isEmpty
java
google/truth
core/src/main/java/com/google/common/truth/TableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TableSubject.java
Apache-2.0
public void isNotEmpty() { if (checkNotNull(actual).isEmpty()) { failWithoutActual(simpleFact("expected not to be empty")); } }
Checks that the actual table is not empty.
isNotEmpty
java
google/truth
core/src/main/java/com/google/common/truth/TableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TableSubject.java
Apache-2.0
public 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 table has the given size.
hasSize
java
google/truth
core/src/main/java/com/google/common/truth/TableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TableSubject.java
Apache-2.0
public void contains(@Nullable Object rowKey, @Nullable Object columnKey) { if (!checkNotNull(actual).contains(rowKey, columnKey)) { /* * TODO(cpovirk): Consider including information about whether any cell with the given row * *or* column was present. */ failWithActual( s...
Checks that the actual table contains a mapping for the given row key and column key.
contains
java
google/truth
core/src/main/java/com/google/common/truth/TableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TableSubject.java
Apache-2.0
public void doesNotContain(@Nullable Object rowKey, @Nullable Object columnKey) { if (checkNotNull(actual).contains(rowKey, columnKey)) { failWithoutActual( simpleFact("expected not to contain mapping for row-column key pair"), fact("row key", rowKey), fact("column key", columnKe...
Checks that the actual table does not contain a mapping for the given row key and column key.
doesNotContain
java
google/truth
core/src/main/java/com/google/common/truth/TableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TableSubject.java
Apache-2.0
static Factory<TableSubject, Table<?, ?, ?>> tables() { return TableSubject::new; }
Checks that the actual table contains the given value.
tables
java
google/truth
core/src/main/java/com/google/common/truth/TableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TableSubject.java
Apache-2.0
public final StringSubject hasMessageThat() { // We provide a more helpful error message if hasCauseThat() methods are chained too deep, as in // assertThat(new Exception()).hasCauseThat().hasMessageThat().... // This message also triggers for the simpler case of assertThat(null).hasMessageThat().... if...
Returns a {@code StringSubject} to make assertions about the throwable's message.
hasMessageThat
java
google/truth
core/src/main/java/com/google/common/truth/ThrowableSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ThrowableSubject.java
Apache-2.0
@SuppressWarnings("MemberName") // The underscore is a weird but intentional choice. public static StandardSubjectBuilder assert_() { return ASSERT; }
Begins a call chain with the fluent Truth API. If the check made by the chain fails, it will throw {@link AssertionError}.
assert_
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static StandardSubjectBuilder assertWithMessage(@Nullable String messageToPrepend) { return assert_().withMessage(messageToPrepend); }
Begins an assertion that, if it fails, will prepend the given message to the failure message. <p>This method is a shortcut for {@code assert_().withMessage(...)}. <p>To set a message when using a custom subject, use {@code assertWithMessage(...).}{@link StandardSubjectBuilder#about about(...)}, as discussed in <a hre...
assertWithMessage
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static StandardSubjectBuilder assertWithMessage(String format, @Nullable Object... args) { return assert_().withMessage(format, args); }
Begins an assertion that, if it fails, will prepend the given message to the failure message. <p><b>Note:</b> the arguments will be substituted into the format template using {@link com.google.common.base.Strings#lenientFormat Strings.lenientFormat}. Note this only supports the {@code %s} specifier. <p>This method is...
assertWithMessage
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static <S extends Subject, T> SimpleSubjectBuilder<S, T> assertAbout( Subject.Factory<S, T> factory) { return assert_().about(factory); }
Given a factory for some {@code Subject} class, returns a builder whose {@code that(actual)} method creates instances of that class.
assertAbout
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectBuilderT assertAbout( CustomSubjectBuilder.Factory<CustomSubjectBuilderT> factory) { return assert_().about(factory); }
A generic, advanced method of extension of Truth to new types, which is documented on {@link CustomSubjectBuilder}. Extension creators should prefer {@link Subject.Factory} if possible.
assertAbout
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static <ComparableT extends Comparable<?>> ComparableSubject<ComparableT> assertThat( @Nullable ComparableT actual) { return assert_().that(actual); }
Begins an assertion about a {@link Comparable}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static BigDecimalSubject assertThat(@Nullable BigDecimal actual) { return assert_().that(actual); }
Begins an assertion about a {@link BigDecimal}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static Subject assertThat(@Nullable Object actual) { return assert_().that(actual); }
Begins an assertion about an {@link Object}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
@GwtIncompatible("ClassSubject.java") @J2ktIncompatible public static ClassSubject assertThat(@Nullable Class<?> actual) { return assert_().that(actual); }
Begins an assertion about a {@link Class}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static ThrowableSubject assertThat(@Nullable Throwable actual) { return assert_().that(actual); }
Begins an assertion about a {@link Throwable}. <p>Truth does not provide its own support for calling a method and automatically catching an expected exception, only for asserting on the exception after it has been caught. To catch the exception, we suggest {@link org.junit.Assert#assertThrows(Class, org.junit.function...
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static LongSubject assertThat(@Nullable Long actual) { return assert_().that(actual); }
Begins an assertion about a {@link Long}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static DoubleSubject assertThat(@Nullable Double actual) { return assert_().that(actual); }
Begins an assertion about a {@link Double}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static FloatSubject assertThat(@Nullable Float actual) { return assert_().that(actual); }
Begins an assertion about a {@link Float}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static IntegerSubject assertThat(@Nullable Integer actual) { return assert_().that(actual); }
Begins an assertion about an {@link Integer}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static BooleanSubject assertThat(@Nullable Boolean actual) { return assert_().that(actual); }
Begins an assertion about a {@link Boolean}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static StringSubject assertThat(@Nullable String actual) { return assert_().that(actual); }
Begins an assertion about a {@link String}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static IterableSubject assertThat(@Nullable Iterable<?> actual) { return assert_().that(actual); }
Begins an assertion about an {@link Iterable}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
@SuppressWarnings("AvoidObjectArrays") public static <T extends @Nullable Object> ObjectArraySubject<T> assertThat( T @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about an {@link Object} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveBooleanArraySubject assertThat(boolean @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code boolean} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveShortArraySubject assertThat(short @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code short} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveIntArraySubject assertThat(int @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about an {@code int} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveLongArraySubject assertThat(long @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code long} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveByteArraySubject assertThat(byte @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code byte} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveCharArraySubject assertThat(char @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code char} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveFloatArraySubject assertThat(float @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code float} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static PrimitiveDoubleArraySubject assertThat(double @Nullable [] actual) { return assert_().that(actual); }
Begins an assertion about a {@code double} array.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static GuavaOptionalSubject assertThat( com.google.common.base.@Nullable Optional<?> actual) { return assert_().that(actual); }
Begins an assertion about a Guava {@link com.google.common.base.Optional}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static MapSubject assertThat(@Nullable Map<?, ?> actual) { return assert_().that(actual); }
Begins an assertion about a {@link Map}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static MultimapSubject assertThat(@Nullable Multimap<?, ?> actual) { return assert_().that(actual); }
Begins an assertion about a {@link Multimap}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static MultisetSubject assertThat(@Nullable Multiset<?> actual) { return assert_().that(actual); }
Begins an assertion about a {@link Multiset}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static TableSubject assertThat(@Nullable Table<?, ?, ?> actual) { return assert_().that(actual); }
Begins an assertion about a {@link Table}.
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
@SuppressWarnings("NullableOptional") // Truth always accepts nulls, no matter the type public static OptionalSubject assertThat(@Nullable Optional<?> actual) { return assert_().that(actual); }
Begins an assertion about an {@link Optional}. @since 1.3.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static OptionalIntSubject assertThat(@Nullable OptionalInt actual) { return assert_().that(actual); }
Begins an assertion about an {@link OptionalInt}. @since 1.3.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static OptionalLongSubject assertThat(@Nullable OptionalLong actual) { return assert_().that(actual); }
Begins an assertion about an {@link OptionalLong}. @since 1.4.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static OptionalDoubleSubject assertThat(@Nullable OptionalDouble actual) { return assert_().that(actual); }
Begins an assertion about an {@link OptionalDouble}. @since 1.4.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static StreamSubject assertThat(@Nullable Stream<?> actual) { return assert_().that(actual); }
Begins an assertion about a {@link Stream}. @since 1.4.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static IntStreamSubject assertThat(@Nullable IntStream actual) { return assert_().that(actual); }
Begins an assertion about an {@link IntStream}. @since 1.4.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static LongStreamSubject assertThat(@Nullable LongStream actual) { return assert_().that(actual); }
Begins an assertion about a {@link LongStream}. @since 1.4.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
@GwtIncompatible @J2ObjCIncompatible @J2ktIncompatible public static PathSubject assertThat(@Nullable Path actual) { return assert_().that(actual); }
Begins an assertion about a {@link Path}. @since 1.4.0 (present in {@link Truth8} since before 1.0)
assertThat
java
google/truth
core/src/main/java/com/google/common/truth/Truth.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth.java
Apache-2.0
public static Factory<TruthFailureSubject, AssertionError> truthFailures() { return TruthFailureSubject::new; }
Factory for creating {@link TruthFailureSubject} instances. Most users will just use {@link ExpectFailure#assertThat}.
truthFailures
java
google/truth
core/src/main/java/com/google/common/truth/TruthFailureSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TruthFailureSubject.java
Apache-2.0
public StringSubject factValue(String key) { return doFactValue(key, null); }
Returns a subject for the value with the given name. <p>The value is always a string, the {@code String.valueOf} representation of the value passed to {@link Fact#fact}. <p>The value is never null: <ul> <li>In the case of {@linkplain Fact#simpleFact facts that have no value}, {@code factValue} throws an exce...
factValue
java
google/truth
core/src/main/java/com/google/common/truth/TruthFailureSubject.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TruthFailureSubject.java
Apache-2.0
public static StandardSubjectBuilder assume() { return ASSUME; }
Begins a call chain with the fluent Truth API. If the check made by the chain fails, it will throw {@link AssumptionViolatedException}.
assume
java
google/truth
core/src/main/java/com/google/common/truth/TruthJUnit.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/TruthJUnit.java
Apache-2.0
static boolean isAndroid() { return false; }
Tests if current platform is Android which is always false.
isAndroid
java
google/truth
core/src/main/java/com/google/common/truth/super/com/google/common/truth/Platform.java
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/super/com/google/common/truth/Platform.java
Apache-2.0
private static void addCompareException(Correspondence.ExceptionStore exceptions) { try { boolean unused = TestCorrespondences.WITHIN_10_OF.compare(null, 123); } catch (RuntimeException e) { exceptions.addCompareException(CorrespondenceExceptionStoreTest.class, e, null, 123); } }
Adds a somewhat realistic exception from {@link Correspondence#compare} to the given store.
addCompareException
java
google/truth
core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java
Apache-2.0
private static void assertExpectedFacts(Iterable<Fact> facts, String expectedFirstKey) { assertThat(facts).hasSize(2); Fact first = Iterables.get(facts, 0); Fact second = Iterables.get(facts, 1); assertThat(first.key).isEqualTo(expectedFirstKey); assertThat(first.value).isNull(); assertThat(seco...
Asserts that the given iterable has two facts, the first with the given key and no value, the second with a key of {@code "first exception"} and a value describing the exception added by {@link #addCompareException}.
assertExpectedFacts
java
google/truth
core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java
Apache-2.0
@Test @SuppressWarnings("TruthSelfEquals") public void expectTwoFailures() { failToExpect.delegate.that(4).isNotEqualTo(4); failToExpect.delegate.that("abc").contains("x"); }
Test that stack traces are included in the error message created by Expect.
expectTwoFailures
java
google/truth
core/src/test/java/com/google/common/truth/ExpectFailureWithStackTraceTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ExpectFailureWithStackTraceTest.java
Apache-2.0
@Override public void evaluate() throws Throwable { base.evaluate(); testMethodComplete.countDown(); taskToAwait.get(); }
Tests (and effectively sample code) for the Expect verb (implemented as a rule) @author David Saff @author Christian Gruber (cgruber@israfil.net)
evaluate
java
google/truth
core/src/test/java/com/google/common/truth/ExpectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ExpectTest.java
Apache-2.0
static void assertFailureValueIndexed(AssertionError e, String key, int index, String value) { assertThat(e).factValue(key, index).isEqualTo(value); }
Convenience methods for {@link Subject} tests.
assertFailureValueIndexed
java
google/truth
core/src/test/java/com/google/common/truth/FailureAssertions.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/FailureAssertions.java
Apache-2.0
static TestInstance empty() { return new TestInstance(ImmutableListMultimap.<String, String>of()); }
Generates a test instance with an empty bipartite graph.
empty
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
static TestInstance fullyConnected(int lhsSize, int rhsSize) { ImmutableListMultimap.Builder<String, String> edges = ImmutableListMultimap.builder(); for (int lhs = 0; lhs < lhsSize; lhs++) { for (int rhs = 0; rhs < rhsSize; rhs++) { edges.put("L" + lhs, "R" + rhs); } } ...
Generates a test instance with a fully-connected bipartite graph where there are {@code lhsSize} elements in one set of vertices (which we call the LHS) and {@code rhsSize} elements in the other (the RHS).
fullyConnected
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
static TestInstance fromBits(int lhsSize, int rhsSize, BitSet bits) { ImmutableListMultimap.Builder<String, String> edges = ImmutableListMultimap.builder(); for (int lhs = 0; lhs < lhsSize; lhs++) { for (int rhs = 0; rhs < rhsSize; rhs++) { if (bits.get(lhs * rhsSize + rhs)) { ...
Generates a test instance with a bipartite graph where there are {@code lhsSize} elements in one set of vertices (which we call the LHS) and {@code rhsSize} elements in the other (the RHS) and whether or not each of the {@code lhsSize * rhsSize} possible edges is included or not according to whether one of the first {@...
fromBits
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
void testAgainstBruteForce() { ImmutableBiMap<String, String> actual = maximumCardinalityBipartiteMatching(edges); for (Map.Entry<String, String> entry : actual.entrySet()) { assertWithMessage( "The returned bimap <%s> was not a matching of the bipartite graph <%s>", ...
Finds the maximum bipartite matching using the method under test and asserts both that it is actually a matching of this bipartite graph and that it has the same size as a maximum bipartite matching found by a brute-force approach.
testAgainstBruteForce
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
void testAgainstKnownSize(int expectedSize) { ImmutableBiMap<String, String> actual = maximumCardinalityBipartiteMatching(edges); for (Map.Entry<String, String> entry : actual.entrySet()) { assertWithMessage( "The returned bimap <%s> was not a matching of the bipartite graph <%s>", ...
Finds the maximum bipartite matching using the method under test and asserts both that it is actually a matching of this bipartite graph and that it has the expected size.
testAgainstKnownSize
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
private ImmutableBiMap<String, String> bruteForceMaximalMatching() { ImmutableBiMap<String, String> best = ImmutableBiMap.of(); Matching candidate = new Matching(); while (candidate.valid()) { if (candidate.size() > best.size()) { best = candidate.asBiMap(); } candida...
Returns a maximal bipartite matching of the bipartite graph, performing a brute force evaluation of every possible matching.
bruteForceMaximalMatching
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
boolean valid() { // When advance() has advanced through all the non-empty maps, the final state is that // selectedEdges is empty, so we use that state as a marker of the final invalid cursor. return !selectedEdges.isEmpty(); }
Returns whether this cursor is valid. Returns true if it has been advanced past the end of the sequence.
valid
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
ImmutableBiMap<String, String> asBiMap() { Preconditions.checkState(valid()); return ImmutableBiMap.copyOf(selectedEdges); }
Returns an immutable representation of the current state of the matching as a bimap giving the edges used in the matching, where the keys identify the vertices in the first set and the values identify the vertices in the second set. The bimap is guaranteed not to be empty. Fails if this cursor is invalid.
asBiMap
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
int size() { Preconditions.checkState(valid()); return selectedEdges.size(); }
Returns the size (i.e. the number of edges in) the current matching, which is guaranteed to be positive (not zer). Fails if this cursor is invalid.
size
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
void advance() { Preconditions.checkState(valid()); // We essentially do a depth-first traversal through the possible matchings. // First we try to add an edge. Edge lastEdge = edgeStack.getLast(); Edge nextEdge = new Edge(lastEdge); nextEdge.advance(); if (nextEd...
Advances to the next matching in the sequence, or invalidates the cursor if this was the last. Fails if this cursor is invalid.
advance
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
boolean valid() { // When advance() has advanced through all the edges, the final state is that lhsIndex == // lhsVertices.size(), so we use that state as a marker of the final invalid cursor. return lhsIndex < lhsVertices.size(); }
Returns whether this cursor is valid. Returns true if it has been advanced past the end of the sequence.
valid
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
void addToSelected() { Preconditions.checkState(valid()); Preconditions.checkState(!selectedEdges.containsKey(lhsVertex())); Preconditions.checkState(!selectedEdges.containsValue(rhsVertex())); selectedEdges.put(lhsVertex(), rhsVertex()); }
Adds the current edge to the matching. Fails if either of the vertices in the edge is already in the matching. Fails if this cursor is invalid.
addToSelected
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
void removeFromSelected() { Preconditions.checkState(valid()); Preconditions.checkState(selectedEdges.containsKey(lhsVertex())); Preconditions.checkState(selectedEdges.get(lhsVertex()).equals(rhsVertex())); selectedEdges.remove(lhsVertex()); }
Removes the current edge from the matching. Fails if this edge is not in the matching. Fails if this cursor is invalid.
removeFromSelected
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
private static BitSet intBits(int intValue) { BitSet bits = new BitSet(); for (int bitIndex = 0; bitIndex < Integer.SIZE; bitIndex++) { bits.set(bitIndex, (intValue & (1L << bitIndex)) != 0); } return bits; }
Returns a bitset corresponding to the binary representation of the given integer.
intBits
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
private static BitSet randomBits(int maxBits, double bitProbability, Random rng) { BitSet bits = new BitSet(); for (int bitIndex = 0; bitIndex < maxBits; bitIndex++) { bits.set(bitIndex, rng.nextDouble() < bitProbability); } return bits; }
Returns a bitset of up to {@code maxBits} bits where each bit is set with a probability {@code bitProbability} using the given RNG.
randomBits
java
google/truth
core/src/test/java/com/google/common/truth/GraphMatchingTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/GraphMatchingTest.java
Apache-2.0
public static void main(String[] args) { try { assertThat("a").isEqualTo("b"); throw new Error("assertion should have failed"); } catch (AssertionError expected) { ImmutableList<Fact> facts = ((AssertionErrorWithFacts) expected).facts(); assertThat(facts.get(0).key).isEqualTo("expected")...
Truth-using binary to be run without JUnit on the classpath to verify that it still works.
main
java
google/truth
core/src/test/java/com/google/common/truth/NoJUnitTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NoJUnitTest.java
Apache-2.0
public void testSimple() { try { assertThat(0).isEqualTo(1); throw new Error(); } catch (AssertionError failure) { assertThat(failure.getStackTrace()).hasLength(1); } }
JUnit3 tests for {@link StackTraceCleaner}. <p>The "main" tests are in {@link StackTraceCleanerTest}.
testSimple
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerJUnit3Test.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerJUnit3Test.java
Apache-2.0
private static boolean stringParsesToInteger( @Nullable String actual, @Nullable Integer expected) { if (actual == null) { return expected == null; } try { // Older versions of Android reject leading plus signs, per the pre-Java-7 contract: // https://docs.oracle.com/javase/6/docs/ap...
A correspondence between strings and integers which tests whether the string parses as the integer. Parsing is as specified by {@link Integer#decode(String)}. It considers null to correspond to null only.
stringParsesToInteger
java
google/truth
core/src/test/java/com/google/common/truth/TestCorrespondences.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TestCorrespondences.java
Apache-2.0
@SuppressWarnings("Casing_StringEqualsIgnoreCase") private static boolean equalsIgnoreCaseHalfNullSafe(String actual, String expected) { if (actual == null && expected == null) { return true; } // Oops! We don't handle the case where actual == null but expected != null. return actual.equalsIgnor...
A correspondence between strings which tests for case-insensitive equality, with a broken attempt at null-safety. The {@link Correspondence#compare} implementation returns true for (null, null) and false for (non-null, null), but throws {@link NullPointerException} for (null, non-null).
equalsIgnoreCaseHalfNullSafe
java
google/truth
core/src/test/java/com/google/common/truth/TestCorrespondences.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TestCorrespondences.java
Apache-2.0
@Override public String toString() { return Joiner.on('/').join(hasId() ? getId() : "none", getScore()); }
Returns the string form of the record, which is the {@code id} value or the literal {@code none} if none, the literal {@code /}, and the {@code score} value concatenated.
toString
java
google/truth
core/src/test/java/com/google/common/truth/TestCorrespondences.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TestCorrespondences.java
Apache-2.0
static @Nullable MyRecord parse(String str) { List<String> parts = Splitter.on('/').splitToList(str); if (parts.size() != 2) { return null; } Integer id = parts.get(0).equals("none") ? -1 : Ints.tryParse(parts.get(0)); Integer score = Ints.tryParse(parts.get(1)); if (id == nu...
If the argument is the string form of a record, returns that record; otherwise returns {@code null}.
parse
java
google/truth
core/src/test/java/com/google/common/truth/TestCorrespondences.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TestCorrespondences.java
Apache-2.0
@Override public void isEqualTo(@Nullable Object expected) { // TODO(user): Do better here when MessageLite descriptors are available. if (Objects.equals(actual, expected)) { return; } if (actual == null || expected == null) { super.isEqualTo(expected); } else if (actual.getClass() !=...
Checks whether the MessageLite is equivalent to the argument, using the standard equals() implementation.
isEqualTo
java
google/truth
extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
Apache-2.0
@Deprecated public void isNotEqualTo(MessageLite.@Nullable Builder builder) { isNotEqualTo((Object) builder); }
@deprecated A Builder will never compare equal to a MessageLite instance. Use {@code build()}, or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or, if you are passing {@code null}, use {@link #isNotNull()}.
isNotEqualTo
java
google/truth
extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
Apache-2.0
public void isEqualToDefaultInstance() { if (actual == null) { failWithoutActual( simpleFact( lenientFormat( "Not true that <%s> is a default proto instance. It is null.", actualCustomStringRepresentationForProtoPackageMembersToCall()))); } else ...
Checks whether the subject is a {@link MessageLite} with no fields set.
isEqualToDefaultInstance
java
google/truth
extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
Apache-2.0
public void isNotEqualToDefaultInstance() { if (actual != null && actual.equals(actual.getDefaultInstanceForType())) { failWithoutActual( simpleFact( lenientFormat( "Not true that (%s) <%s> is not a default proto instance. It has no set values.", act...
Checks whether the subject is not equivalent to a {@link MessageLite} with no fields set.
isNotEqualToDefaultInstance
java
google/truth
extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
Apache-2.0
public void hasAllRequiredFields() { if (!actual.isInitialized()) { // MessageLite doesn't support reflection so this is the best we can do. failWithoutActual( simpleFact("expected to have all required fields set"), fact("but was", actualCustomStringRepresentationForProtoPackageMembe...
Checks whether the subject has all required fields set. Cannot fail for a proto built with {@code build()}, which itself fails if required fields aren't set.
hasAllRequiredFields
java
google/truth
extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java
Apache-2.0
static Optional<Message> unpack( Message any, TypeRegistry typeRegistry, ExtensionRegistry extensionRegistry) { Preconditions.checkArgument( any.getDescriptorForType().equals(Any.getDescriptor()), "Expected type google.protobuf.Any, but was: %s", any.getDescriptorForType().getFullName(...
Unpack an `Any` proto using the given TypeRegistry and ExtensionRegistry.
unpack
java
google/truth
extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java
https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java
Apache-2.0