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 |
|---|---|---|---|---|---|---|---|
@Test
public void isEqualToFailureWithNulls() {
Object o = null;
AssertionError e = expectFailure(whenTesting -> whenTesting.that(o).isEqualTo("a"));
assertFailureKeys(e, "expected", "but was");
assertFailureValue(e, "expected", "a");
assertFailureValue(e, "but was", "null");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToFailureWithNulls | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isEqualToStringWithNullVsNull() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that("null").isEqualTo(null));
assertFailureKeys(e, "expected", "an instance of", "but was", "an instance of");
assertFailureValue(e, "expected", "null");
assertFailureValueIndexed(e, "an in... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToStringWithNullVsNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("SelfAssertion")
@Test
public void isEqualToWithSameObject() {
Object a = new Object();
assertThat(a).isEqualTo(a);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToWithSameObject | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isEqualToFailureWithObjects() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(OBJECT_1).isEqualTo(OBJECT_2));
assertFailureKeys(e, "expected", "but was");
assertFailureValue(e, "expected", "Object 2");
assertFailureValue(e, "but was", "Object 1");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToFailureWithObjects | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("TruthIncompatibleType")
@Test
public void isEqualToFailureWithDifferentTypesAndSameToString() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that("true").isEqualTo(true));
assertFailureKeys(e, "expected", "an instance of", "but was", "an instance of");
assertFailureValu... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToFailureWithDifferentTypesAndSameToString | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isEqualToNullBadEqualsImplementation() {
expectFailure(whenTesting -> whenTesting.that(new ThrowsOnEqualsNull()).isEqualTo(null));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToNullBadEqualsImplementation | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("TruthSelfEquals")
@Test
public void isEqualToSameInstanceBadEqualsImplementation() {
Object o = new ThrowsOnEquals();
assertThat(o).isEqualTo(o);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualToSameInstanceBadEqualsImplementation | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotEqualToWithNulls() {
Object o = null;
assertThat(o).isNotEqualTo("a");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToWithNulls | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotEqualToFailureWithNulls() {
Object o = null;
AssertionError e = expectFailure(whenTesting -> whenTesting.that(o).isNotEqualTo(null));
assertFailureKeys(e, "expected not to be");
assertFailureValue(e, "expected not to be", "null");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToFailureWithNulls | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotEqualToWithObjects() {
assertThat(new Object()).isNotEqualTo(new Object());
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToWithObjects | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotEqualToFailureWithObjects() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(new IntId(1)).isNotEqualTo(new IntId(1)));
assertFailureKeys(e, "expected not to be");
assertFailureValue(e, "expected not to be", "1");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToFailureWithObjects | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public boolean equals(Object o) {
return o instanceof IntId && id == ((IntId) o).id;
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | equals | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public int hashCode() {
return id;
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | hashCode | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public String toString() {
return String.valueOf(id);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | toString | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("SelfAssertion")
@Test
public void isNotEqualToFailureWithSameObject() {
expectFailure(whenTesting -> whenTesting.that(OBJECT_1).isNotEqualTo(OBJECT_1));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToFailureWithSameObject | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("TruthIncompatibleType")
@Test
public void isNotEqualToWithDifferentTypesAndSameToString() {
assertThat("true").isNotEqualTo(true);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToWithDifferentTypesAndSameToString | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotEqualToNullBadEqualsImplementation() {
assertThat(new ThrowsOnEqualsNull()).isNotEqualTo(null);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToNullBadEqualsImplementation | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("TruthSelfEquals")
@Test
public void isNotEqualToSameInstanceBadEqualsImplementation() {
Object o = new ThrowsOnEquals();
expectFailure(whenTesting -> whenTesting.that(o).isNotEqualTo(o));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualToSameInstanceBadEqualsImplementation | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("IsInstanceString") // test is an intentional trivially true check
@Test
public void isInstanceOfExactType() {
assertThat("a").isInstanceOf(String.class);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfExactType | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("IsInstanceInteger") // test is an intentional trivially true check
@Test
public void isInstanceOfSuperclass() {
assertThat(3).isInstanceOf(Number.class);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfSuperclass | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("IsInstanceString") // test is an intentional trivially true check
@Test
public void isInstanceOfImplementedInterface() {
if (isGwt()) {
assertThrows(
UnsupportedOperationException.class,
() -> assertThat("a").isInstanceOf(CharSequence.class));
return;
}
... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfImplementedInterface | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInstanceOfUnrelatedClass() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(4.5).isInstanceOf(Long.class));
assertFailureKeys(e, "expected instance of", "but was instance of", "with value");
assertFailureValue(e, "expected instance of", "java.lang.Long");
assertFa... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfUnrelatedClass | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInstanceOfUnrelatedInterface() {
if (isGwt()) {
assertThrows(
UnsupportedOperationException.class,
() -> assertThat(4.5).isInstanceOf(CharSequence.class));
return;
}
expectFailure(whenTesting -> whenTesting.that(4.5).isInstanceOf(CharSequence.class));
... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfUnrelatedInterface | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInstanceOfClassForNull() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that((Object) null).isInstanceOf(Long.class));
assertFailureKeys(e, "expected instance of", "but was");
assertFailureValue(e, "expected instance of", "java.lang.Long");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfClassForNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInstanceOfInterfaceForNull() {
expectFailure(whenTesting -> whenTesting.that((Object) null).isInstanceOf(CharSequence.class));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfInterfaceForNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("IsInstanceInteger")
@Test
public void isInstanceOfPrimitiveType() {
assertThrows(IllegalArgumentException.class, () -> assertThat(1).isInstanceOf(int.class));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInstanceOfPrimitiveType | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInstanceOfUnrelatedClass() {
assertThat("a").isNotInstanceOf(Long.class);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInstanceOfUnrelatedClass | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInstanceOfUnrelatedInterface() {
if (isGwt()) {
assertThrows(
UnsupportedOperationException.class,
() -> assertThat(5).isNotInstanceOf(CharSequence.class));
return;
}
assertThat(5).isNotInstanceOf(CharSequence.class);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInstanceOfUnrelatedInterface | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInstanceOfExactType() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(5).isNotInstanceOf(Integer.class));
assertFailureKeys(e, "expected not to be an instance of", "but was");
assertFailureValue(e, "expected not to be an instance of", "java.lang.Integer");... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInstanceOfExactType | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInstanceOfSuperclass() {
expectFailure(whenTesting -> whenTesting.that(5).isNotInstanceOf(Number.class));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInstanceOfSuperclass | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInstanceOfImplementedInterface() {
if (isGwt()) {
assertThrows(
UnsupportedOperationException.class,
() -> assertThat("a").isNotInstanceOf(CharSequence.class));
return;
}
expectFailure(whenTesting -> whenTesting.that("a").isNotInstanceOf(CharSequence... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInstanceOfImplementedInterface | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInstanceOfPrimitiveType() {
assertThrows(IllegalArgumentException.class, () -> assertThat(1).isNotInstanceOf(int.class));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInstanceOfPrimitiveType | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isIn() {
assertThat("b").isIn(oneShotIterable("a", "b", "c"));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isIn | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInJustTwo() {
assertThat("b").isIn(oneShotIterable("a", "b"));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInJustTwo | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInFailure() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that("x").isIn(oneShotIterable("a", "b", "c")));
assertFailureKeys(e, "expected any of", "but was");
assertFailureValue(e, "expected any of", "[a, b, c]");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInNullInListWithNull() {
assertThat((String) null).isIn(oneShotIterable("a", "b", null));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInNullInListWithNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInNonnullInListWithNull() {
assertThat("b").isIn(oneShotIterable("a", "b", null));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInNonnullInListWithNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInNullFailure() {
expectFailure(
whenTesting -> whenTesting.that((String) null).isIn(oneShotIterable("a", "b", "c")));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInNullFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isInEmptyFailure() {
expectFailure(whenTesting -> whenTesting.that("b").isIn(ImmutableList.<String>of()));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isInEmptyFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isAnyOf() {
assertThat("b").isAnyOf("a", "b", "c");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAnyOf | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isAnyOfJustTwo() {
assertThat("b").isAnyOf("a", "b");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAnyOfJustTwo | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isAnyOfFailure() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that("x").isAnyOf("a", "b", "c"));
assertFailureKeys(e, "expected any of", "but was");
assertFailureValue(e, "expected any of", "[a, b, c]");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAnyOfFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isAnyOfNullInListWithNull() {
assertThat((String) null).isAnyOf("a", "b", (String) null);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAnyOfNullInListWithNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isAnyOfNonnullInListWithNull() {
assertThat("b").isAnyOf("a", "b", (String) null);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAnyOfNonnullInListWithNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isAnyOfNullFailure() {
expectFailure(whenTesting -> whenTesting.that((String) null).isAnyOf("a", "b", "c"));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAnyOfNullFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotIn() {
assertThat("x").isNotIn(oneShotIterable("a", "b", "c"));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotIn | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInFailure() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that("b").isNotIn(oneShotIterable("a", "b", "c")));
assertFailureKeys(e, "expected not to be any of", "but was");
assertFailureValue(e, "expected not to be any of", "[a, b, c]");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInNull() {
assertThat((String) null).isNotIn(oneShotIterable("a", "b", "c"));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInNullFailure() {
expectFailure(
whenTesting -> whenTesting.that((String) null).isNotIn(oneShotIterable("a", "b", null)));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInNullFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNotInEmpty() {
assertThat("b").isNotIn(ImmutableList.<String>of());
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotInEmpty | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNoneOf() {
assertThat("x").isNoneOf("a", "b", "c");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNoneOf | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNoneOfFailure() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that("b").isNoneOf("a", "b", "c"));
assertFailureKeys(e, "expected not to be any of", "but was");
assertFailureValue(e, "expected not to be any of", "[a, b, c]");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNoneOfFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNoneOfNull() {
assertThat((String) null).isNoneOf("a", "b", "c");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNoneOfNull | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void isNoneOfNullFailure() {
expectFailure(whenTesting -> whenTesting.that((String) null).isNoneOf("a", "b", (String) null));
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNoneOfNullFailure | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
// test of a mistaken call
@SuppressWarnings({"EqualsIncompatibleType", "DoNotCall", "deprecation"})
public void equalsThrowsUSOE() {
UnsupportedOperationException expected =
assertThrows(UnsupportedOperationException.class, () -> assertThat(5).equals(5));
assertThat(expected)
.hasMe... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | equalsThrowsUSOE | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
// test of a mistaken call
@SuppressWarnings({"DoNotCall", "deprecation"})
public void hashCodeThrowsUSOE() {
UnsupportedOperationException expected =
assertThrows(UnsupportedOperationException.class, () -> assertThat(5).hashCode());
assertThat(expected).hasMessageThat().isEqualTo("Subject.h... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | hashCodeThrowsUSOE | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void ignoreCheckDiscardsFailures() {
assertThat((Object) null).ignoreCheck().that("foo").isNull();
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | ignoreCheckDiscardsFailures | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
private static <T> Iterable<T> oneShotIterable(T... values) {
Iterator<T> iterator = Iterators.forArray(values);
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return iterator;
}
@Override
public String toString() {
return Arrays.toString(valu... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | oneShotIterable | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public Iterator<T> iterator() {
return iterator;
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | iterator | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public String toString() {
return Arrays.toString(values);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | toString | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
@SuppressWarnings({
"TruthIncompatibleType", // test of a mistaken call
"UnnecessaryStringBuilder", // We need a type that doesn't implement value-based equals().
})
public void disambiguationWithSameToString() {
/*
* We use `Object` instead of `StringBuilder` to force the compiler to choos... | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | disambiguationWithSameToString | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings({"EqualsHashCode", "SuperCallToObjectMethod"})
@Override
public boolean equals(Object obj) {
checkNotNull(obj); // buggy implementation but one that we're working around, at least for now
return super.equals(obj);
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | equals | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@SuppressWarnings("EqualsHashCode")
@Override
public boolean equals(Object obj) {
throw new UnsupportedOperationException();
// buggy implementation but one that we're working around, at least for now
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | equals | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
static Factory<ForbidsEqualityChecksSubject, Object> objectsForbiddingEqualityCheck() {
return ForbidsEqualityChecksSubject::new;
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | objectsForbiddingEqualityCheck | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public void isEqualTo(@Nullable Object expected) {
throw new UnsupportedOperationException();
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isEqualTo | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Override
public void isNotEqualTo(@Nullable Object unexpected) {
throw new UnsupportedOperationException();
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isNotEqualTo | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
private static boolean isAndroid() {
return System.getProperty("java.runtime.name").contains("Android");
} | Tests for generic Subject behavior.
@author David Saff
@author Christian Gruber | isAndroid | java | google/truth | core/src/test/java/com/google/common/truth/SubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/SubjectTest.java | Apache-2.0 |
@Test
public void tableIsEmpty() {
ImmutableTable<String, String, String> table = ImmutableTable.of();
assertThat(table).isEmpty();
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | tableIsEmpty | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void tableIsEmptyWithFailure() {
ImmutableTable<Integer, Integer, Integer> table = ImmutableTable.of(1, 5, 7);
AssertionError e = expectFailure(whenTesting -> whenTesting.that(table).isEmpty());
assertFailureKeys(e, "expected to be empty", "but was");
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | tableIsEmptyWithFailure | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void tableIsNotEmpty() {
ImmutableTable<Integer, Integer, Integer> table = ImmutableTable.of(1, 5, 7);
assertThat(table).isNotEmpty();
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | tableIsNotEmpty | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void tableIsNotEmptyWithFailure() {
ImmutableTable<Integer, Integer, Integer> table = ImmutableTable.of();
AssertionError e = expectFailure(whenTesting -> whenTesting.that(table).isNotEmpty());
assertFailureKeys(e, "expected not to be empty");
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | tableIsNotEmptyWithFailure | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void hasSize() {
assertThat(ImmutableTable.of(1, 2, 3)).hasSize(1);
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | hasSize | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void hasSizeZero() {
assertThat(ImmutableTable.of()).hasSize(0);
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | hasSizeZero | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void hasSizeNegative() {
assertThrows(
IllegalArgumentException.class, () -> assertThat(ImmutableTable.of(1, 2, 3)).hasSize(-1));
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | hasSizeNegative | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void contains() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
assertThat(table).contains("row", "col");
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | contains | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void containsFailure() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(table).contains("row", "otherCol"));
assertThat(e)
.factKeys()
.containsExactly(
... | Tests for Table Subjects.
@author Kurt Alfred Kluever | containsFailure | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void doesNotContain() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
assertThat(table).doesNotContain("row", "row");
assertThat(table).doesNotContain("col", "row");
assertThat(table).doesNotContain("col", "col");
assertThat(table).doesNotConta... | Tests for Table Subjects.
@author Kurt Alfred Kluever | doesNotContain | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void doesNotContainFailure() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(table).doesNotContain("row", "col"));
assertThat(e)
.factKeys()
.containsExactly(
... | Tests for Table Subjects.
@author Kurt Alfred Kluever | doesNotContainFailure | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void containsCell() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
assertThat(table).containsCell("row", "col", "val");
assertThat(table).containsCell(cell("row", "col", "val"));
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | containsCell | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void containsCellFailure() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(table).containsCell("row", "row", "val"));
assertFailureKeys(e, "value of", "expected to contain", "but ... | Tests for Table Subjects.
@author Kurt Alfred Kluever | containsCellFailure | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void doesNotContainCell() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
assertThat(table).doesNotContainCell("row", "row", "val");
assertThat(table).doesNotContainCell("col", "row", "val");
assertThat(table).doesNotContainCell("col", "col", "val"... | Tests for Table Subjects.
@author Kurt Alfred Kluever | doesNotContainCell | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
@Test
public void doesNotContainCellFailure() {
ImmutableTable<String, String, String> table = ImmutableTable.of("row", "col", "val");
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(table).doesNotContainCell("row", "col", "val"));
assertFailureKeys(e, "value of", "ex... | Tests for Table Subjects.
@author Kurt Alfred Kluever | doesNotContainCellFailure | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.java | Apache-2.0 |
private static <R, C, V> Cell<R, C, V> cell(R row, C col, V val) {
return Tables.immutableCell(row, col, val);
} | Tests for Table Subjects.
@author Kurt Alfred Kluever | cell | java | google/truth | core/src/test/java/com/google/common/truth/TableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TableSubjectTest.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 |
static MyRecord create(int id, int score) {
checkState(id >= 0);
checkState(score > 0);
return new MyRecord(id, score);
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | create | 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 MyRecord createWithoutId(int score) {
checkState(score >= 0);
return new MyRecord(-1, score);
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | createWithoutId | 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 |
boolean hasId() {
return id >= 0;
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | hasId | 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 |
int getId() {
checkState(hasId());
return id;
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | getId | 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 |
int getScore() {
return score;
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | getScore | 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 |
boolean hasSameId(MyRecord that) {
return this.id == that.id;
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | hasSameId | 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 boolean equals(@Nullable Object o) {
if (o instanceof MyRecord) {
MyRecord that = (MyRecord) o;
return this.id == that.id && this.score == that.score;
}
return false;
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | equals | 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 int hashCode() {
return Objects.hashCode(id, score);
} | An example value object. It has an optional {@code id} field and a required {@code score}
field, both positive integers. | hashCode | 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 |
private static boolean recordsAreCloseEnough(
@Nullable MyRecord actual, @Nullable MyRecord expected) {
if (actual == null) {
return expected == null;
}
if (expected == null) {
return false;
}
return actual.hasSameId(expected) && Math.abs(actual.getScore() - expected.getScore()) <=... | A correspondence like {@link #RECORDS_EQUAL_WITH_SCORE_TOLERANCE_10} except that the actual
values are strings which will be parsed before comparing. If the string does not parse to a
record then it does not correspond and is not diffed. Does not support null strings or records. | recordsAreCloseEnough | 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 |
private static @Nullable String formatRecordDiff(MyRecord actual, MyRecord expected) {
if (actual.hasId() && expected.hasId() && actual.getId() == expected.getId()) {
return "score:" + (actual.getScore() - expected.getScore());
} else {
return null;
}
} | A correspondence like {@link #RECORDS_EQUAL_WITH_SCORE_TOLERANCE_10} except that the actual
values are strings which will be parsed before comparing. If the string does not parse to a
record then it does not correspond and is not diffed. Does not support null strings or records. | formatRecordDiff | 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 |
@Test
public void hasMessageThat() {
NullPointerException npe = new NullPointerException("message");
assertThat(npe).hasMessageThat().isEqualTo("message");
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasMessageThat_null() {
assertThat(new NullPointerException()).hasMessageThat().isNull();
assertThat(new NullPointerException(null)).hasMessageThat().isNull();
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat_null | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasMessageThat_failure() {
NullPointerException actual = new NullPointerException("message");
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(actual).hasMessageThat().isEqualTo("foobar"));
assertFailureValue(e, "value of", "throwable.getMessage()");
assertErr... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.