Test isEmpty() and isNotEmpty() with null inputs.
RELNOTES=n/a
@@ -74,6 +74,15 @@ public class StringSubjectTest extends BaseSubjectTestCase {
.isEqualTo("Not true that <\"abc\"> is empty");
}
+ @Test
+ public void stringIsEmptyFailNull() {
+ String s = null;
+ expectFailure.whenTesting().that(s).isEmpty();
+ assertThat(expectFailure.getFailure())
+ .hasMessageThat()
+ .isEqualTo("Not true that null reference is empty");
+ }
+
@Test
public void stringIsNotEmpty() {
assertThat("abc").isNotEmpty();
@@ -87,6 +96,15 @@ public class StringSubjectTest extends BaseSubjectTestCase {
.isEqualTo("Not true that <\"\"> is not empty");
}
+ @Test
+ public void stringIsNotEmptyFailNull() {
+ String s = null;
+ expectFailure.whenTesting().that(s).isNotEmpty();
+ assertThat(expectFailure.getFailure())
+ .hasMessageThat()
+ .isEqualTo("Not true that null reference is not empty");
+ }
+
@Test
public void stringContains() {
assertThat("abc").contains("c");
