diff --git a/core/src/test/java/com/google/common/truth/IterableSubjectTest.java b/core/src/test/java/com/google/common/truth/IterableSubjectTest.java index 71254721c..8f012a2f1 100644 --- a/core/src/test/java/com/google/common/truth/IterableSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/IterableSubjectTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat; import static java.lang.String.CASE_INSENSITIVE_ORDER; import static java.util.Arrays.asList; +import static java.util.Collections.singleton; import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableList; @@ -814,10 +815,12 @@ public void containsExactlyWithDuplicatesOutOfOrder() { } @Test + // We intentionally test the behavior of the method under a call that will soon fail. + @SuppressWarnings("NullNeedsCastForVarargs") @J2ktIncompatible // Kotlin can't pass a null array for a varargs parameter public void containsExactlyWithOnlyNullPassedAsNullArray() { - // Truth is tolerant of this erroneous varargs call. - Iterable actual = asList((Object) null); + Iterable actual = singleton(null); + // We are changing Truth from tolerating this erroneous varargs call to not tolerating it. try { assertThat(actual).containsExactly((Object[]) null); } catch (NullPointerException e) { diff --git a/core/src/test/java/com/google/common/truth/StreamSubjectTest.java b/core/src/test/java/com/google/common/truth/StreamSubjectTest.java index 9ce30bcce..d2b1c260d 100644 --- a/core/src/test/java/com/google/common/truth/StreamSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/StreamSubjectTest.java @@ -21,6 +21,7 @@ import static com.google.common.truth.FailureAssertions.assertFailureValue; import static com.google.common.truth.Truth.assertThat; import static java.util.Arrays.asList; +import static java.util.Collections.singleton; import java.util.stream.Stream; import org.junit.Test; @@ -316,8 +317,11 @@ public void containsExactly_nullObject() { @Test @J2ktIncompatible // Kotlin can't pass a null array for a varargs parameter + // We intentionally test the behavior of the method under a call that will soon fail. + @SuppressWarnings("NullNeedsCastForVarargs") public void containsExactly_nullObjectArray() { - StreamSubject subject = assertThat(Stream.of((Object) null)); + StreamSubject subject = assertThat(singleton(null).stream()); + // We are changing Truth from tolerating this erroneous varargs call to not tolerating it. try { subject.containsExactly((Object[]) null); } catch (NullPointerException e) {