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 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
|
@SuppressWarnings("AssertAboutOptionals") // suggests infinite recursion
public static OptionalSubject assertThat(@Nullable Optional<?> target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
public static OptionalIntSubject assertThat(@Nullable OptionalInt target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
public static OptionalLongSubject assertThat(@Nullable OptionalLong target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
public static OptionalDoubleSubject assertThat(@Nullable OptionalDouble target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
public static StreamSubject assertThat(@Nullable Stream<?> target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
public static IntStreamSubject assertThat(@Nullable IntStream target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
public static LongStreamSubject assertThat(@Nullable LongStream target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.java
|
Apache-2.0
|
@GwtIncompatible
@J2ObjCIncompatible
@J2ktIncompatible
public static PathSubject assertThat(@Nullable Path target) {
return Truth.assertThat(target);
}
|
The obsolete entry point for assertions about Java 8 types.
@deprecated Instead of this class's methods, use the identical methods declared in the main
{@link Truth} class. In most cases, you can <a
href="https://github.com/google/truth/releases/tag/v1.4.0">migrate</a> your whole project
mechanically: {@code git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'}
Migration is important <i>if</i> you static import {@code assertThat}: If you do not migrate,
such static imports will become ambiguous in Truth 1.4.2, breaking your build.
|
assertThat
|
java
|
google/truth
|
core/src/main/java/com/google/common/truth/Truth8.java
|
https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Truth8.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 IterableSubject factKeys() {
if (!(actual instanceof ErrorWithFacts)) {
failWithActual(simpleFact("expected a failure thrown by Truth's failure API"));
return ignoreCheck().that(ImmutableList.of());
}
ErrorWithFacts error = (ErrorWithFacts) actual;
return check("factKeys()").that(getFactKeys(error));
}
|
Returns a subject for the list of fact keys.
|
factKeys
|
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
|
private static ImmutableList<String> getFactKeys(ErrorWithFacts error) {
ImmutableList.Builder<String> facts = ImmutableList.builder();
for (Fact fact : error.facts()) {
facts.add(fact.key);
}
return facts.build();
}
|
Returns a subject for the list of fact keys.
|
getFactKeys
|
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 exception. To test for such facts, use {@link #factKeys()}{@code
.contains(...)} or a similar method.
<li>In the case of facts that have a value that is rendered as "null" (such as those created
with {@code fact("key", null)}), {@code factValue} considers them have a string value,
the string "null."
</ul>
<p>If the failure under test contains more than one fact with the given key, this method will
fail the test. To assert about such a failure, use {@linkplain #factValue(String, int) the
other overload} of {@code factValue}.
|
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 StringSubject factValue(String key, int index) {
checkArgument(index >= 0, "index must be nonnegative: %s", index);
return doFactValue(key, index);
}
|
Returns a subject for the value of the {@code index}-th instance of the fact with the given
name. Most Truth failures do not contain multiple facts with the same key, so most tests should
use {@linkplain #factValue(String) the other overload} of {@code factValue}.
|
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
|
private StringSubject doFactValue(String key, @Nullable Integer index) {
checkNotNull(key);
if (!(actual instanceof ErrorWithFacts)) {
failWithActual(simpleFact("expected a failure thrown by Truth's failure API"));
return ignoreCheck().that("");
}
ErrorWithFacts error = (ErrorWithFacts) actual;
/*
* We don't care as much about including the actual AssertionError and its facts in these
* because the AssertionError will be attached as a cause in nearly all cases.
*/
ImmutableList<Fact> factsWithName = factsWithName(error, key);
if (factsWithName.isEmpty()) {
failWithoutActual(
fact("expected to contain fact", key), fact("but contained only", getFactKeys(error)));
return ignoreCheck().that("");
}
if (index == null && factsWithName.size() > 1) {
failWithoutActual(
fact("expected to contain a single fact with key", key),
fact("but contained multiple", factsWithName));
return ignoreCheck().that("");
}
if (index != null && index > factsWithName.size()) {
failWithoutActual(
fact("for key", key),
fact("index too high", index),
fact("fact count was", factsWithName.size()));
return ignoreCheck().that("");
}
String value = factsWithName.get(firstNonNull(index, 0)).value;
if (value == null) {
if (index == null) {
failWithoutActual(
simpleFact("expected to have a value"),
fact("for key", key),
simpleFact("but the key was present with no value"),
HOW_TO_TEST_KEYS_WITHOUT_VALUES);
} else {
failWithoutActual(
simpleFact("expected to have a value"),
fact("for key", key),
fact("and index", index),
simpleFact("but the key was present with no value"),
HOW_TO_TEST_KEYS_WITHOUT_VALUES);
}
return ignoreCheck().that("");
}
StandardSubjectBuilder check =
index == null ? check("factValue(%s)", key) : check("factValue(%s, %s)", key, index);
return check.that(value);
}
|
Returns a subject for the value of the {@code index}-th instance of the fact with the given
name. Most Truth failures do not contain multiple facts with the same key, so most tests should
use {@linkplain #factValue(String) the other overload} of {@code factValue}.
|
doFactValue
|
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
|
private static ImmutableList<Fact> factsWithName(ErrorWithFacts error, String key) {
ImmutableList.Builder<Fact> facts = ImmutableList.builder();
for (Fact fact : error.facts()) {
if (fact.key.equals(key)) {
facts.add(fact);
}
}
return facts.build();
}
|
Returns a subject for the value of the {@code index}-th instance of the fact with the given
name. Most Truth failures do not contain multiple facts with the same key, so most tests should
use {@linkplain #factValue(String) the other overload} of {@code factValue}.
|
factsWithName
|
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 isInstanceOfType(Object instance, Class<?> clazz) {
if (clazz.isInterface()) {
throw new UnsupportedOperationException(
"On Web platforms, we can't determine whether an object is an instance of an interface"
+ " Class");
}
for (Class<?> current = instance.getClass();
current != null;
current = current.getSuperclass()) {
if (current.equals(clazz)) {
return true;
}
}
return false;
}
|
Returns true if the instance is assignable to the type Clazz.
|
isInstanceOfType
|
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
|
static boolean containsMatch(String actual, String regex) {
return compile(regex).test(actual);
}
|
Determines if the given actual value contains a match for the given regex.
|
containsMatch
|
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
|
static void cleanStackTrace(Throwable throwable) {
// Do nothing. See notes in StackTraceCleanerTest.
}
|
Determines if the given actual value contains a match for the given regex.
|
cleanStackTrace
|
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
|
static @Nullable String inferDescription() {
return null;
}
|
Determines if the given actual value contains a match for the given regex.
|
inferDescription
|
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
|
static @Nullable ImmutableList<Fact> makeDiff(String expected, String actual) {
/*
* IIUC, GWT messages lose their newlines by the time users see them. Given that, users are
* likely better served by showing the expected and actual values with mangled newlines than by
* showing a diff with mangled newlines (which would look similar but with + and - inserted into
* it). Hopefully no one under GWT has long, nearly identical messages. In any case, they've
* always been stuck like this.
*/
return null;
}
|
Determines if the given actual value contains a match for the given regex.
|
makeDiff
|
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
|
@Override
public final String toString() {
return "" + getLocalizedMessage();
}
|
Determines if the given actual value contains a match for the given regex.
|
toString
|
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
|
static String doubleToString(double value) {
// This probably doesn't match Java perfectly, but we do our best.
if (value == Double.POSITIVE_INFINITY) {
return "Infinity";
} else if (value == Double.NEGATIVE_INFINITY) {
return "-Infinity";
} else if (value == 0 && 1 / value < 0) {
return "-0.0";
} else {
// TODO(cpovirk): Would it make more sense to pass `undefined` for the locale? But how?
// Then again, we're already hardcoding "Infinity," an English word, above....
String result = toLocaleString(value);
return (parseDouble(result) == value) ? result : Double.toString(value);
}
}
|
Determines if the given actual value contains a match for the given regex.
|
doubleToString
|
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
|
static String floatToString(float value) {
// This probably doesn't match Java perfectly, but we do our best.
if (value == Float.POSITIVE_INFINITY) {
return "Infinity";
} else if (value == Float.NEGATIVE_INFINITY) {
return "-Infinity";
} else if (value == 0 && 1 / value < 0) {
return "-0.0";
} else if (value == 0) {
return "0.0";
} else {
// TODO(cpovirk): Would it make more sense to pass `undefined` for the locale? But how?
// Then again, we're already hardcoding "Infinity," an English word, above....
String result = toLocaleString(value);
return (parseFloat(result) == value) ? result : Float.toString(value);
}
}
|
Determines if the given actual value contains a match for the given regex.
|
floatToString
|
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 String toLocaleString(double value) {
// Recieve a double as a parameter so that "(Object) value" does not box it.
return ((NativeNumber) (Object) value).toLocaleString("en-US", JavaLikeOptions.INSTANCE);
}
|
Determines if the given actual value contains a match for the given regex.
|
toLocaleString
|
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
|
static String stringValueOfNonFloatingPoint(@Nullable Object o) {
// Check if we are in J2CL mode by probing a system property that only exists in GWT.
boolean inJ2clMode = "doesntexist".equals(System.getProperty("superdevmode", "doesntexist"));
if (inJ2clMode && o instanceof Message) {
Message msg = (Message) o;
boolean dumpAvailable =
"true".equals(System.getProperty("goog.DEBUG", "true"))
&& !"true".equals(System.getProperty("COMPILED", "false"));
return dumpAvailable ? dump(msg).toString() : msg.serialize();
}
return String.valueOf(o);
}
|
Turns a non-double, non-float object into a string.
|
stringValueOfNonFloatingPoint
|
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
|
static String getStackTraceAsString(Throwable throwable) {
// TODO(cpovirk): Write a naive implementation that at least dumps the main exception's stack.
return throwable.toString();
}
|
Returns a human readable string representation of the throwable's stack trace.
|
getStackTraceAsString
|
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
|
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 NativeRegExp compile(String pattern) {
return new NativeRegExp(pattern);
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
compile
|
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
|
@Override
public int getMinimumFractionDigits() {
return 1;
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
getMinimumFractionDigits
|
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
|
@Override
public int getMaximumFractionDigits() {
return 20;
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
getMaximumFractionDigits
|
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
|
@Override
public boolean getUseGrouping() {
return false;
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
getUseGrouping
|
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
|
static AssertionError makeComparisonFailure(
ImmutableList<String> messages,
ImmutableList<Fact> facts,
String expected,
String actual,
@Nullable Throwable cause) {
/*
* Despite the name, the class we're creating extends AssertionError but not ComparisonFailure
* under GWT: See its supertype, PlatformComparisonFailure, above.
*
* We're actually creating the same class as the non-GWT version of this method does. So why do
* we have supersource for this method? It's because we can't run (and, fortunately, don't need
* to run) the reflective code we have for non-GWT users, who might or might not choose to
* exclude JUnit 4 from their classpath.
*
* TODO(cpovirk): Remove ComparisonFailureWithFacts and PlatformComparisonFailure entirely under
* GWT? That would let us merge them into a single class on the server. And as noted in the
* non-GWT copy of Platform, we could consider another custom type that exposes getExpected()
* and getActual(), even in the absence of ComparisonFailure. That type would work under GWT.
*/
return ComparisonFailureWithFacts.create(messages, facts, expected, actual, cause);
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
makeComparisonFailure
|
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
|
static boolean isKotlinRange(Iterable<?> iterable) {
return false;
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
isKotlinRange
|
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
|
static boolean kotlinRangeContains(Iterable<?> haystack, @Nullable Object needle) {
throw new AssertionError(); // never called under GWT because isKotlinRange returns false
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
kotlinRangeContains
|
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
|
static boolean classMetadataUnsupported() {
return String.class.getSuperclass() == null;
}
|
A GWT-swapped version of test rule interface that does nothing. All methods extended from
{@link org.junit.rules.TestRule} needs to be stripped.
|
classMetadataUnsupported
|
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
|
@SuppressWarnings("TruthSelfEquals")
@Test
public void isEqualTo() {
// make sure this still works
assertThat(TEN).isEqualTo(TEN);
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEqualTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isEquivalentAccordingToCompareTo() {
// make sure this still works
assertThat(TEN).isEquivalentAccordingToCompareTo(TEN);
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEquivalentAccordingToCompareTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualToIgnoringScale_bigDecimal() {
assertThat(TEN).isEqualToIgnoringScale(TEN);
assertThat(TEN).isEqualToIgnoringScale(new BigDecimal(10));
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(TEN).isEqualToIgnoringScale(new BigDecimal(3)));
assertFailureKeys(e, "expected", "but was", "(scale is ignored)");
assertFailureValue(e, "expected", "3");
assertFailureValue(e, "but was", "10");
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEqualToIgnoringScale_bigDecimal
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualToIgnoringScale_int() {
assertThat(TEN).isEqualToIgnoringScale(10);
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(TEN).isEqualToIgnoringScale(3));
assertFailureKeys(e, "expected", "but was", "(scale is ignored)");
assertFailureValue(e, "expected", "3");
assertFailureValue(e, "but was", "10");
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEqualToIgnoringScale_int
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualToIgnoringScale_long() {
assertThat(TEN).isEqualToIgnoringScale(10L);
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(TEN).isEqualToIgnoringScale(3L));
assertFailureKeys(e, "expected", "but was", "(scale is ignored)");
assertFailureValue(e, "expected", "3");
assertFailureValue(e, "but was", "10");
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEqualToIgnoringScale_long
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualToIgnoringScale_string() {
assertThat(TEN).isEqualToIgnoringScale("10");
assertThat(TEN).isEqualToIgnoringScale("10.");
assertThat(TEN).isEqualToIgnoringScale("10.0");
assertThat(TEN).isEqualToIgnoringScale("10.00");
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(TEN).isEqualToIgnoringScale("3"));
assertFailureKeys(e, "expected", "but was", "(scale is ignored)");
assertFailureValue(e, "expected", "3");
assertFailureValue(e, "but was", "10");
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEqualToIgnoringScale_string
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualToIgnoringScale_stringWithDecimals() {
BigDecimal tenFour = new BigDecimal("10.4");
assertThat(tenFour).isEqualToIgnoringScale("10.4");
assertThat(tenFour).isEqualToIgnoringScale("10.4");
assertThat(tenFour).isEqualToIgnoringScale("10.40");
assertThat(tenFour).isEqualToIgnoringScale("10.400");
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(tenFour).isEqualToIgnoringScale("3.4"));
assertFailureKeys(e, "expected", "but was", "(scale is ignored)");
assertFailureValue(e, "expected", "3.4");
assertFailureValue(e, "but was", "10.4");
}
|
Tests for BigDecimal Subjects.
@author Kurt Alfred Kluever
|
isEqualToIgnoringScale_stringWithDecimals
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BigDecimalSubjectTest.java
|
Apache-2.0
|
@Test
public void isTrue() {
assertThat(true).isTrue();
}
|
Tests for Boolean Subjects.
@author Christian Gruber (cgruber@israfil.net)
|
isTrue
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
Apache-2.0
|
@Test
public void nullIsTrueFailing() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that((Boolean) null).isTrue());
assertFailureKeys(e, "expected", "but was");
assertFailureValue(e, "expected", "true");
assertFailureValue(e, "but was", "null");
}
|
Tests for Boolean Subjects.
@author Christian Gruber (cgruber@israfil.net)
|
nullIsTrueFailing
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
Apache-2.0
|
@Test
public void nullIsFalseFailing() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that((Boolean) null).isFalse());
assertFailureKeys(e, "expected", "but was");
assertFailureValue(e, "expected", "false");
assertFailureValue(e, "but was", "null");
}
|
Tests for Boolean Subjects.
@author Christian Gruber (cgruber@israfil.net)
|
nullIsFalseFailing
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
Apache-2.0
|
@Test
public void isTrueFailing() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(false).isTrue());
assertFailureKeys(e, "expected to be true");
}
|
Tests for Boolean Subjects.
@author Christian Gruber (cgruber@israfil.net)
|
isTrueFailing
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
Apache-2.0
|
@Test
public void isFalse() {
assertThat(false).isFalse();
}
|
Tests for Boolean Subjects.
@author Christian Gruber (cgruber@israfil.net)
|
isFalse
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
Apache-2.0
|
@Test
public void isFalseFailing() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(true).isFalse());
assertFailureKeys(e, "expected to be false");
}
|
Tests for Boolean Subjects.
@author Christian Gruber (cgruber@israfil.net)
|
isFalseFailing
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/BooleanSubjectTest.java
|
Apache-2.0
|
@Test
public void noChaining() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that("root").isThePresentKingOfFrance());
assertNoCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
noChaining
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void oneLevel() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that("root").delegatingTo("child").isThePresentKingOfFrance());
assertNoCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
oneLevel
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevels() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingTo("child")
.delegatingTo("grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevels
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void noChainingRootThrowable() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(throwable).isThePresentKingOfFrance());
assertHasCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
noChainingRootThrowable
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void oneLevelRootThrowable() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that(throwable).delegatingTo("child").isThePresentKingOfFrance());
assertHasCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
oneLevelRootThrowable
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsRootThrowable() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(throwable)
.delegatingTo("child")
.delegatingTo("grandchild")
.isThePresentKingOfFrance());
assertHasCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsRootThrowable
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void oneLevelDerivedThrowable() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that("root").delegatingTo(throwable).isThePresentKingOfFrance());
assertHasCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
oneLevelDerivedThrowable
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsDerivedThrowableMiddle() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingTo(throwable)
.delegatingTo("grandchild")
.isThePresentKingOfFrance());
assertHasCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsDerivedThrowableMiddle
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsDerivedThrowableLast() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingTo("child")
.delegatingTo(throwable)
.isThePresentKingOfFrance());
assertHasCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsDerivedThrowableLast
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void oneLevelNamed() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamed("child", "child")
.isThePresentKingOfFrance());
assertNoCause(e, "value of : myObject.child\nmessage\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
oneLevelNamed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsNamed() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamed("child", "child")
.delegatingToNamed("grandchild", "grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "value of : myObject.child.grandchild\nmessage\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsNamed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsOnlyFirstNamed() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamed("child", "child")
.delegatingTo("grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "message\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsOnlyFirstNamed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsOnlySecondNamed() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingTo("child")
.delegatingToNamed("grandchild", "grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "value of : myObject.grandchild\nmessage\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsOnlySecondNamed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void oneLevelNamedNoNeedToDisplayBoth() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamedNoNeedToDisplayBoth("child", "child")
.isThePresentKingOfFrance());
assertNoCause(e, "value of: myObject.child\nmessage");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
oneLevelNamedNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsNamedNoNeedToDisplayBoth() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamedNoNeedToDisplayBoth("child", "child")
.delegatingToNamedNoNeedToDisplayBoth("grandchild", "grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "value of: myObject.child.grandchild\nmessage");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsNamedNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsOnlyFirstNamedNoNeedToDisplayBoth() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamedNoNeedToDisplayBoth("child", "child")
.delegatingTo("grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsOnlyFirstNamedNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsOnlySecondNamedNoNeedToDisplayBoth() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingTo("child")
.delegatingToNamedNoNeedToDisplayBoth("grandchild", "grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "value of: myObject.grandchild\nmessage");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsOnlySecondNamedNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsNamedOnlyFirstNoNeedToDisplayBoth() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamedNoNeedToDisplayBoth("child", "child")
.delegatingToNamed("grandchild", "grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "value of : myObject.child.grandchild\nmessage\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsNamedOnlyFirstNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void twoLevelsNamedOnlySecondNoNeedToDisplayBoth() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that("root")
.delegatingToNamed("child", "child")
.delegatingToNamedNoNeedToDisplayBoth("grandchild", "grandchild")
.isThePresentKingOfFrance());
assertNoCause(e, "value of : myObject.child.grandchild\nmessage\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
twoLevelsNamedOnlySecondNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void namedAndMessage() {
AssertionError e =
ExpectFailure.expectFailure(
whenTesting ->
whenTesting
.withMessage("prefix")
.about(myObjects())
.that("root")
.delegatingToNamed("child", "child")
.isThePresentKingOfFrance());
assertNoCause(e, "prefix\nvalue of : myObject.child\nmessage\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
namedAndMessage
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void checkFail() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that("root").doCheckFail());
assertNoCause(e, "message");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
checkFail
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void checkFailWithName() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that("root").doCheckFail("child"));
assertNoCause(e, "message\nvalue of : myObject.child\nmyObject was: root");
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
checkFailWithName
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void badFormat() {
try {
@SuppressWarnings("LenientFormatStringValidation") // Intentional for testing.
Object unused = assertThat("root").check("%s %s", 1, 2, 3);
assert_().fail();
} catch (IllegalArgumentException expected) {
}
}
|
Tests for chained subjects (produced with {@link Subject#check(String, Object...)}, etc.).
|
badFormat
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
MyObjectSubject delegatingTo(Object actual) {
return check().about(myObjects()).that(actual);
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
delegatingTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
MyObjectSubject delegatingToNamed(Object actual, String name) {
return check(name).about(myObjects()).that(actual);
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
delegatingToNamed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
MyObjectSubject delegatingToNamedNoNeedToDisplayBoth(Object actual, String name) {
return checkNoNeedToDisplayBothValues(name).about(myObjects()).that(actual);
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
delegatingToNamedNoNeedToDisplayBoth
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
private static Subject.Factory<MyObjectSubject, Object> myObjects() {
return MyObjectSubject::new;
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
myObjects
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
private static AssertionError expectFailure(
ExpectFailure.SimpleSubjectBuilderCallback<MyObjectSubject, Object> assertionCallback) {
return ExpectFailure.expectFailureAbout(myObjects(), assertionCallback);
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
expectFailure
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
private static void assertNoCause(AssertionError failure, String message) {
assertThat(failure).hasMessageThat().isEqualTo(message);
assertThat(failure).hasCauseThat().isNull();
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
assertNoCause
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
private static void assertHasCause(AssertionError failure, String message) {
assertThat(failure).hasMessageThat().isEqualTo(message);
assertThat(failure).hasCauseThat().isEqualTo(throwable);
}
|
Returns a new {@code MyObjectSubject} for the given actual value, chaining it to the current
subject with {@link Subject#check}.
|
assertHasCause
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ChainingTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ChainingTest.java
|
Apache-2.0
|
@Test
public void testIsAssignableTo_same() {
assertThat(String.class).isAssignableTo(String.class);
}
|
Tests for introspective Subject behaviour.
@author Christian Gruber (cgruber@israfil.net)
|
testIsAssignableTo_same
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
Apache-2.0
|
@Test
public void testIsAssignableTo_parent() {
assertThat(String.class).isAssignableTo(Object.class);
assertThat(NullPointerException.class).isAssignableTo(Exception.class);
}
|
Tests for introspective Subject behaviour.
@author Christian Gruber (cgruber@israfil.net)
|
testIsAssignableTo_parent
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
Apache-2.0
|
@Test
public void testIsAssignableTo_reversed() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(Object.class).isAssignableTo(String.class));
assertFailureValue(e, "expected to be assignable to", "java.lang.String");
}
|
Tests for introspective Subject behaviour.
@author Christian Gruber (cgruber@israfil.net)
|
testIsAssignableTo_reversed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
Apache-2.0
|
@Test
public void testIsAssignableTo_differentTypes() {
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(String.class).isAssignableTo(Exception.class));
assertFailureValue(e, "expected to be assignable to", "java.lang.Exception");
}
|
Tests for introspective Subject behaviour.
@author Christian Gruber (cgruber@israfil.net)
|
testIsAssignableTo_differentTypes
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
Apache-2.0
|
@Test
public void testIsAssignableTo_forNullActual() {
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that((Class<?>) null).isAssignableTo(Exception.class));
assertFailureValue(e, "expected to be assignable to", "java.lang.Exception");
}
|
Tests for introspective Subject behaviour.
@author Christian Gruber (cgruber@israfil.net)
|
testIsAssignableTo_forNullActual
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ClassSubjectTest.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.