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 isEmpty() { assertThat(OptionalDouble.empty()).isEmpty(); }
Tests for {@link OptionalDouble} Subjects. @author Ben Douglass
isEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
Apache-2.0
@Test public void isEmptyFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalDouble.of(1337.0)).isEmpty()); assertThat(expected).factKeys().contains("expected to be empty"); assertThat(expected).factValue("but was present with value").isEqualTo("1337.0"); }
Tests for {@link OptionalDouble} Subjects. @author Ben Douglass
isEmptyFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
Apache-2.0
@Test public void isEmptyFailingNull() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((OptionalDouble) null).isEmpty()); assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder(); }
Tests for {@link OptionalDouble} Subjects. @author Ben Douglass
isEmptyFailingNull
java
google/truth
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
Apache-2.0
@Test public void hasValue() { assertThat(OptionalDouble.of(1337.0)).hasValue(1337.0); }
Tests for {@link OptionalDouble} Subjects. @author Ben Douglass
hasValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
Apache-2.0
@Test public void hasValue_FailingWithEmpty() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalDouble.empty()).hasValue(1337.0)); assertThat(expected) .factKeys() .containsExactly("expected to have value", "but was absent") .inOrder(); assertThat(expected).factValue("expected to have value").isEqualTo("1337.0"); }
Tests for {@link OptionalDouble} Subjects. @author Ben Douglass
hasValue_FailingWithEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
Apache-2.0
@Test public void hasValue_FailingWithWrongValue() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalDouble.of(1337.0)).hasValue(42.0)); assertThat(expected).factValue("value of").isEqualTo("optionalDouble.getAsDouble()"); }
Tests for {@link OptionalDouble} Subjects. @author Ben Douglass
hasValue_FailingWithWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
Apache-2.0
@Test public void failOnNullSubject() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((OptionalInt) null).isEmpty()); assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder(); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
failOnNullSubject
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void isPresent() { assertThat(OptionalInt.of(1337)).isPresent(); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
isPresent
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void isPresentFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalInt.empty()).isPresent()); assertThat(expected).factKeys().containsExactly("expected to be present"); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
isPresentFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void isEmpty() { assertThat(OptionalInt.empty()).isEmpty(); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
isEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void isEmptyFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalInt.of(1337)).isEmpty()); assertThat(expected).factKeys().contains("expected to be empty"); assertThat(expected).factValue("but was present with value").isEqualTo("1337"); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
isEmptyFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void isEmptyFailingNull() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((OptionalInt) null).isEmpty()); assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder(); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
isEmptyFailingNull
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void hasValue() { assertThat(OptionalInt.of(1337)).hasValue(1337); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
hasValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void hasValue_FailingWithEmpty() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalInt.empty()).hasValue(1337)); assertThat(expected) .factKeys() .containsExactly("expected to have value", "but was absent") .inOrder(); assertThat(expected).factValue("expected to have value").isEqualTo("1337"); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
hasValue_FailingWithEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void hasValue_FailingWithWrongValue() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalInt.of(1337)).hasValue(42)); assertThat(expected).factValue("value of").isEqualTo("optionalInt.getAsInt()"); }
Tests for {@link OptionalInt} Subjects. @author Ben Douglass
hasValue_FailingWithWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java
Apache-2.0
@Test public void failOnNullSubject() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((OptionalLong) null).isEmpty()); assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder(); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
failOnNullSubject
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void isPresent() { assertThat(OptionalLong.of(1337L)).isPresent(); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
isPresent
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void isPresentFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalLong.empty()).isPresent()); assertThat(expected).factKeys().containsExactly("expected to be present"); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
isPresentFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void isEmpty() { assertThat(OptionalLong.empty()).isEmpty(); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
isEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void isEmptyFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalLong.of(1337L)).isEmpty()); assertThat(expected).factKeys().contains("expected to be empty"); assertThat(expected).factValue("but was present with value").isEqualTo("1337"); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
isEmptyFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void isEmptyFailingNull() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((OptionalLong) null).isEmpty()); assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder(); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
isEmptyFailingNull
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void hasValue() { assertThat(OptionalLong.of(1337L)).hasValue(1337L); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
hasValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void hasValue_FailingWithEmpty() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalLong.empty()).hasValue(1337L)); assertThat(expected) .factKeys() .containsExactly("expected to have value", "but was absent") .inOrder(); assertThat(expected).factValue("expected to have value").isEqualTo("1337"); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
hasValue_FailingWithEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void hasValue_FailingWithWrongValue() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(OptionalLong.of(1337L)).hasValue(42L)); assertThat(expected).factValue("value of").isEqualTo("optionalLong.getAsLong()"); }
Tests for {@link OptionalLong} Subjects. @author Ben Douglass
hasValue_FailingWithWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java
Apache-2.0
@Test public void isPresent() { assertThat(Optional.of("foo")).isPresent(); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
isPresent
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void isPresentFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(Optional.empty()).isPresent()); assertThat(expected).factKeys().containsExactly("expected to be present"); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
isPresentFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void isPresentFailingNull() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((Optional<?>) null).isPresent()); assertThat(expected) .factKeys() .containsExactly("expected present optional", "but was") .inOrder(); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
isPresentFailingNull
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void isEmpty() { assertThat(Optional.empty()).isEmpty(); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
isEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void isEmptyFailing() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(Optional.of("foo")).isEmpty()); assertThat(expected).factKeys().contains("expected to be empty"); assertThat(expected).factValue("but was present with value").isEqualTo("foo"); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
isEmptyFailing
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void isEmptyFailingNull() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that((Optional<?>) null).isEmpty()); assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder(); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
isEmptyFailingNull
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void hasValue() { assertThat(Optional.of("foo")).hasValue("foo"); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
hasValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void hasValue_failingWithEmpty() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(Optional.empty()).hasValue("foo")); assertThat(expected) .factKeys() .containsExactly("expected to have value", "but was empty") .inOrder(); assertThat(expected).factValue("expected to have value").isEqualTo("foo"); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
hasValue_failingWithEmpty
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void hasValue_failingWithNullParameter() { AssertionError e = expectFailure( whenTesting -> whenTesting.that(com.google.common.base.Optional.of("foo")).hasValue(null)); assertFailureKeys(e, "expected an optional with a null value, but that is impossible", "was"); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
hasValue_failingWithNullParameter
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
@Test public void hasValue_failingWithWrongValue() { AssertionError expected = expectFailure(whenTesting -> whenTesting.that(Optional.of("foo")).hasValue("boo")); assertThat(expected).factValue("value of").isEqualTo("optional.get()"); }
Tests for {@link Optional} Subject. @author Christian Gruber (cgruber@israfil.net)
hasValue_failingWithWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalSubjectTest.java
Apache-2.0
public void testSimple() { try { assertThat(0).isEqualTo(1); throw new Error(); } catch (AssertionError failure) { assertThat(failure.getStackTrace()).hasLength(1); } }
JUnit3 tests for {@link StackTraceCleaner}. <p>The "main" tests are in {@link StackTraceCleanerTest}.
testSimple
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerJUnit3Test.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerJUnit3Test.java
Apache-2.0
@Test public void truthFrameWithOutSubject_shouldNotCleaned() { Throwable throwable = createThrowableWithStackTrace( "com.google.random.Package", // two or more truth frame will trigger string matching mechenism to got it collapsed "com.google.common.truth.FailureMetadata", "com.google.example.SomeClass"); StackTraceCleaner.cleanStackTrace(throwable); assertThat(throwable.getStackTrace()) .isEqualTo( new StackTraceElement[] { createStackTraceElement("com.google.random.Package"), createStackTraceElement("com.google.common.truth.FailureMetadata"), createStackTraceElement("com.google.example.SomeClass"), }); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
truthFrameWithOutSubject_shouldNotCleaned
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@Test public void causingThrowablesAreAlsoCleaned() { Throwable cause2 = createThrowableWithStackTrace("com.example.Foo", "org.junit.FilterMe"); Throwable cause1 = createThrowableWithStackTrace(cause2, "com.example.Bar", "org.junit.FilterMe"); Throwable rootThrowable = createThrowableWithStackTrace(cause1, "com.example.Car", "org.junit.FilterMe"); StackTraceCleaner.cleanStackTrace(rootThrowable); assertThat(rootThrowable.getStackTrace()).isEqualTo(createStackTrace("com.example.Car")); assertThat(cause1.getStackTrace()).isEqualTo(createStackTrace("com.example.Bar")); assertThat(cause2.getStackTrace()).isEqualTo(createStackTrace("com.example.Foo")); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
causingThrowablesAreAlsoCleaned
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@Test public void suppressedThrowablesAreAlsoCleaned() { if (Platform.isAndroid()) { return; // suppressed exceptions aren't supported under Ice Cream Sandwich, where we test } Throwable throwable = createThrowableWithStackTrace("com.example.Foo", "org.junit.FilterMe"); Throwable suppressed1 = createThrowableWithStackTrace("com.example.Bar", "org.junit.FilterMe"); Throwable suppressed2 = createThrowableWithStackTrace("com.example.Car", "org.junit.FilterMe"); throwable.addSuppressed(suppressed1); throwable.addSuppressed(suppressed2); StackTraceCleaner.cleanStackTrace(throwable); assertThat(throwable.getStackTrace()).isEqualTo(createStackTrace("com.example.Foo")); assertThat(suppressed1.getStackTrace()).isEqualTo(createStackTrace("com.example.Bar")); assertThat(suppressed2.getStackTrace()).isEqualTo(createStackTrace("com.example.Car")); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
suppressedThrowablesAreAlsoCleaned
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@Test public void mixedCausingAndSuppressThrowablesAreCleaned() { if (Platform.isAndroid()) { return; // suppressed exceptions aren't supported under Ice Cream Sandwich, where we test } Throwable suppressed1 = createThrowableWithStackTrace("com.example.Foo", "org.junit.FilterMe"); Throwable cause2 = createThrowableWithStackTrace("com.example.Bar", "org.junit.FilterMe"); Throwable cause1 = createThrowableWithStackTrace(cause2, "com.example.Car", "org.junit.FilterMe"); Throwable suppressed2 = createThrowableWithStackTrace(cause1, "com.example.Dar", "org.junit.FilterMe"); Throwable throwable = createThrowableWithStackTrace("com.example.Far", "org.junit.FilterMe"); throwable.addSuppressed(suppressed1); throwable.addSuppressed(suppressed2); StackTraceCleaner.cleanStackTrace(throwable); assertThat(throwable.getStackTrace()).isEqualTo(createStackTrace("com.example.Far")); assertThat(suppressed1.getStackTrace()).isEqualTo(createStackTrace("com.example.Foo")); assertThat(suppressed2.getStackTrace()).isEqualTo(createStackTrace("com.example.Dar")); assertThat(cause1.getStackTrace()).isEqualTo(createStackTrace("com.example.Car")); assertThat(cause2.getStackTrace()).isEqualTo(createStackTrace("com.example.Bar")); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
mixedCausingAndSuppressThrowablesAreCleaned
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@Test public void cleaningTraceIsIdempotent() { Throwable throwable = createThrowableWithStackTrace("com.example.Foo", "org.junit.FilterMe"); StackTraceCleaner.cleanStackTrace(throwable); StackTraceCleaner.cleanStackTrace(throwable); assertThat(throwable.getStackTrace()).isEqualTo(createStackTrace("com.example.Foo")); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
cleaningTraceIsIdempotent
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@Test public void cyclesAreHandled() { SelfReferencingThrowable selfReferencingThrowable = new SelfReferencingThrowable("com.example.Foo", "org.junit.FilterMe"); StackTraceCleaner.cleanStackTrace(selfReferencingThrowable); assertThat(selfReferencingThrowable.getStackTrace()) .isEqualTo(createStackTrace("com.example.Foo")); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
cyclesAreHandled
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
private static Throwable createThrowableWithStackTrace(String... classNames) { return createThrowableWithStackTrace(null, classNames); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
createThrowableWithStackTrace
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
private static Throwable createThrowableWithStackTrace(Throwable cause, String... classNames) { Throwable throwable = new RuntimeException(cause); StackTraceElement[] stackTrace = createStackTrace(classNames); throwable.setStackTrace(stackTrace); return throwable; }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
createThrowableWithStackTrace
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
private static StackTraceElement[] createStackTrace(String... classNames) { StackTraceElement[] stackTrace = new StackTraceElement[classNames.length]; for (int i = 0; i < classNames.length; i++) { stackTrace[i] = createStackTraceElement(classNames[i]); } return stackTrace; }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
createStackTrace
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
private static StackTraceElement createStackTraceElement(String className) { return new StackTraceElement(className, "", "", -1); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
createStackTraceElement
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
private static StackTraceElement createCollapsedStackTraceElement( String frameworkName, int collapsed) { return new StackTraceElement( "[[" + frameworkName + ": " + collapsed + " frames collapsed (" + StackTraceCleaner.CLEANER_LINK + ")]]", "", "", 0); }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
createCollapsedStackTraceElement
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@Override public synchronized Throwable getCause() { return this; }
This scenario where truth class is called directly without any subject's subclass or {@link StandardSubjectBuilder} in the call stack should not happen in practical, testing anyway to make sure even if it does, the behavior should match expectation.
getCause
java
google/truth
core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StackTraceCleanerTest.java
Apache-2.0
@SuppressWarnings({"deprecation", "TruthSelfEquals"}) // test of a possibly mistaken call @Test public void testIsEqualToSameInstancePreviouslyConsumed() { Stream<String> stream = Stream.of("hello"); stream.forEach(e -> {}); // Consume it so that we can verify that isEqualTo still works assertThat(stream).isEqualTo(stream); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsEqualToSameInstancePreviouslyConsumed
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@SuppressWarnings({"deprecation", "TruthSelfEquals"}) // test of a possibly mistaken call @Test public void testIsEqualToSameInstanceDoesNotConsume() { Stream<String> stream = Stream.of("hello"); assertThat(stream).isEqualTo(stream); assertThat(stream).containsExactly("hello"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsEqualToSameInstanceDoesNotConsume
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@SuppressWarnings({ "deprecation", // test of a possibly mistaken call "StreamToString", // not very useful but the best we can do }) @Test public void testIsEqualToFailurePreviouslyConsumed() { Stream<String> stream = Stream.of("hello"); stream.forEach(e -> {}); // Consume it so that we can verify that isEqualTo still works AssertionError failure = expectFailure(whenTesting -> whenTesting.that(stream).isEqualTo(Stream.of("hello"))); assertThat(failure) .factValue("but was") .isEqualTo("Stream that has already been operated upon or closed: " + stream); assertThat(failure) .hasMessageThat() .contains("Warning: Stream equality is based on object identity."); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsEqualToFailurePreviouslyConsumed
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@SuppressWarnings("deprecation") // test of a possibly mistaken call @Test public void testIsEqualToFailureNotPreviouslyConsumed() { Stream<String> stream = Stream.of("hello"); AssertionError failure = expectFailure(whenTesting -> whenTesting.that(stream).isEqualTo(Stream.of("hello"))); assertThat(failure).factValue("but was").isEqualTo("[hello]"); assertThat(failure) .hasMessageThat() .contains("Warning: Stream equality is based on object identity."); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsEqualToFailureNotPreviouslyConsumed
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@SuppressWarnings({ "SelfAssertion", // test of a possibly mistaken call "deprecation", // test of a possibly mistaken call "StreamToString", // not very useful but the best we can do }) @Test public void testIsNotEqualToSameInstance() { Stream<String> stream = Stream.of("hello"); stream.forEach(e -> {}); // Consume it so that we can verify that isNotEqualTo still works AssertionError failure = expectFailure(whenTesting -> whenTesting.that(stream).isNotEqualTo(stream)); assertThat(failure).factKeys().containsExactly("expected not to be"); assertThat(failure) .factValue("expected not to be") .isEqualTo("Stream that has already been operated upon or closed: " + stream); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsNotEqualToSameInstance
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@SuppressWarnings("deprecation") // test of a possibly mistaken call @Test public void testIsNotEqualToOtherInstance() { Stream<String> stream = Stream.of("hello"); stream.forEach(e -> {}); // Consume it so that we can verify that isNotEqualTo still works assertThat(stream).isNotEqualTo(Stream.of("hello")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsNotEqualToOtherInstance
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testNullStream_fails() { Stream<String> nullStream = null; assertThrows(NullPointerException.class, () -> assertThat(nullStream).isEmpty()); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testNullStream_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testNullStreamIsNull() { Stream<String> nullStream = null; assertThat(nullStream).isNull(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testNullStreamIsNull
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test @SuppressWarnings("TruthSelfEquals") public void testIsSameInstanceAs() { Stream<String> stream = Stream.of("hello"); assertThat(stream).isSameInstanceAs(stream); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsSameInstanceAs
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsEmpty() { assertThat(Stream.of()).isEmpty(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsEmpty
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsEmpty_fails() { AssertionError unused = expectFailure(whenTesting -> whenTesting.that(Stream.of("hello")).isEmpty()); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsEmpty_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsNotEmpty() { assertThat(Stream.of("hello")).isNotEmpty(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsNotEmpty
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsNotEmpty_fails() { AssertionError unused = expectFailure(whenTesting -> whenTesting.that(Stream.of()).isNotEmpty()); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsNotEmpty_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testHasSize() { assertThat(Stream.of("hello")).hasSize(1); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testHasSize
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testHasSize_fails() { AssertionError failure = expectFailure(whenTesting -> whenTesting.that(Stream.of("hello")).hasSize(2)); assertThat(failure).factValue("value of").isEqualTo("stream.size()"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testHasSize_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsNoDuplicates() { assertThat(Stream.of("hello")).containsNoDuplicates(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsNoDuplicates
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsNoDuplicates_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting.that(Stream.of("hello", "hello")).containsNoDuplicates()); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsNoDuplicates_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContains() { assertThat(Stream.of("hello")).contains("hello"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContains
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContains_fails() { AssertionError unused = expectFailure(whenTesting -> whenTesting.that(Stream.of("hello")).contains("goodbye")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContains_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAnyOf() { assertThat(Stream.of("hello")).containsAnyOf("hello", "hell"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAnyOf
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAnyOf_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting.that(Stream.of("hello")).containsAnyOf("goodbye", "good")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAnyOf_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAnyIn() { assertThat(Stream.of("hello")).containsAnyIn(asList("hello", "hell")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAnyIn
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAnyIn_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting.that(Stream.of("hello")).containsAnyIn(asList("goodbye", "good"))); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAnyIn_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testDoesNotContain() { assertThat(Stream.of("hello")).doesNotContain("goodbye"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testDoesNotContain
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testDoesNotContain_fails() { AssertionError unused = expectFailure(whenTesting -> whenTesting.that(Stream.of("hello")).doesNotContain("hello")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testDoesNotContain_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsNoneOf() { assertThat(Stream.of("hello")).containsNoneOf("goodbye", "good"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsNoneOf
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsNoneOf_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting.that(Stream.of("hello")).containsNoneOf("hello", "hell")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsNoneOf_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsNoneIn() { assertThat(Stream.of("hello")).containsNoneIn(asList("goodbye", "good")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsNoneIn
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsNoneIn_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting.that(Stream.of("hello")).containsNoneIn(asList("hello", "hell"))); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsNoneIn_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeast() { assertThat(Stream.of("hell", "hello")).containsAtLeast("hell", "hello"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeast
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeast_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsAtLeast("hell", "hello", "goodbye")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeast_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeast_inOrder() { assertThat(Stream.of("hell", "hello")).containsAtLeast("hell", "hello").inOrder(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeast_inOrder
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeast_inOrder_fails() { AssertionError expected = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsAtLeast("hello", "hell") .inOrder()); assertFailureKeys( expected, "required elements were all found, but order was wrong", "expected order for required elements", "but was"); assertFailureValue(expected, "expected order for required elements", "[hello, hell]"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeast_inOrder_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeastElementsIn() { assertThat(Stream.of("hell", "hello")).containsAtLeastElementsIn(asList("hell", "hello")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeastElementsIn
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeastElementsIn_fails() { AssertionError unused = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsAtLeastElementsIn(asList("hell", "hello", "goodbye"))); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeastElementsIn_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeastElementsIn_inOrder() { assertThat(Stream.of("hell", "hello")) .containsAtLeastElementsIn(asList("hell", "hello")) .inOrder(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeastElementsIn_inOrder
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsAtLeastElementsIn_inOrder_fails() { AssertionError expected = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsAtLeastElementsIn(asList("hello", "hell")) .inOrder()); assertFailureKeys( expected, "required elements were all found, but order was wrong", "expected order for required elements", "but was"); assertFailureValue(expected, "expected order for required elements", "[hello, hell]"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsAtLeastElementsIn_inOrder_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactly() { assertThat(Stream.of("hell", "hello")).containsExactly("hell", "hello"); assertThat(Stream.of("hell", "hello")).containsExactly("hello", "hell"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactly
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactly_null() { assertThat(Stream.of((Object) null)).containsExactly((Object) null); assertThat(Stream.of((Object) null)).containsExactly((Object[]) null); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactly_null
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactly_fails() { AssertionError expected = expectFailure( whenTesting -> whenTesting.that(Stream.of("hell", "hello")).containsExactly("hell")); assertFailureKeys(expected, "unexpected (1)", "---", "expected", "but was"); assertFailureValue(expected, "expected", "[hell]"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactly_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactly_inOrder() { assertThat(Stream.of("hell", "hello")).containsExactly("hell", "hello").inOrder(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactly_inOrder
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactly_inOrder_fails() { AssertionError expected = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsExactly("hello", "hell") .inOrder()); assertFailureKeys(expected, "contents match, but order was wrong", "expected", "but was"); assertFailureValue(expected, "expected", "[hello, hell]"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactly_inOrder_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactlyElementsIn() { assertThat(Stream.of("hell", "hello")).containsExactlyElementsIn(asList("hell", "hello")); assertThat(Stream.of("hell", "hello")).containsExactlyElementsIn(asList("hello", "hell")); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactlyElementsIn
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactlyElementsIn_fails() { AssertionError expected = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsExactlyElementsIn(asList("hell"))); assertFailureKeys(expected, "unexpected (1)", "---", "expected", "but was"); assertFailureValue(expected, "expected", "[hell]"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactlyElementsIn_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactlyElementsIn_inOrder() { assertThat(Stream.of("hell", "hello")) .containsExactlyElementsIn(asList("hell", "hello")) .inOrder(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactlyElementsIn_inOrder
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testContainsExactlyElementsIn_inOrder_fails() { AssertionError expected = expectFailure( whenTesting -> whenTesting .that(Stream.of("hell", "hello")) .containsExactlyElementsIn(asList("hello", "hell")) .inOrder()); assertFailureKeys(expected, "contents match, but order was wrong", "expected", "but was"); assertFailureValue(expected, "expected", "[hello, hell]"); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testContainsExactlyElementsIn_inOrder_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsInOrder() { assertThat(Stream.of()).isInOrder(); assertThat(Stream.of(1)).isInOrder(); assertThat(Stream.of(1, 1, 2, 3, 3, 3, 4)).isInOrder(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsInOrder
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsInOrder_fails() { AssertionError unused = expectFailure(whenTesting -> whenTesting.that(Stream.of(1, 3, 2, 4)).isInOrder()); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsInOrder_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsInStrictOrder() { assertThat(Stream.of()).isInStrictOrder(); assertThat(Stream.of(1)).isInStrictOrder(); assertThat(Stream.of(1, 2, 3, 4)).isInStrictOrder(); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsInStrictOrder
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void testIsInStrictOrder_fails() { AssertionError unused = expectFailure(whenTesting -> whenTesting.that(Stream.of(1, 2, 2, 4)).isInStrictOrder()); }
Tests for {@link Stream} Subjects. @author Kurt Alfred Kluever
testIsInStrictOrder_fails
java
google/truth
core/src/test/java/com/google/common/truth/StreamSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StreamSubjectTest.java
Apache-2.0
@Test public void hasLength() { assertThat("kurt").hasLength(4); }
Tests for String Subjects. @author David Saff @author Christian Gruber (cgruber@israfil.net)
hasLength
java
google/truth
core/src/test/java/com/google/common/truth/StringSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StringSubjectTest.java
Apache-2.0
@Test public void hasLengthZero() { assertThat("").hasLength(0); }
Tests for String Subjects. @author David Saff @author Christian Gruber (cgruber@israfil.net)
hasLengthZero
java
google/truth
core/src/test/java/com/google/common/truth/StringSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StringSubjectTest.java
Apache-2.0
@Test public void hasLengthFails() { AssertionError e = expectFailure(whenTesting -> whenTesting.that("kurt").hasLength(5)); assertFailureValue(e, "value of", "string.length()"); }
Tests for String Subjects. @author David Saff @author Christian Gruber (cgruber@israfil.net)
hasLengthFails
java
google/truth
core/src/test/java/com/google/common/truth/StringSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/StringSubjectTest.java
Apache-2.0