BAEL-7178: StringUtils.isBlank() vs String.isEmpty() (#15213)

* adding first test cases

* final code
This commit is contained in:
Pedro Lopes 2023-11-21 11:39:23 -03:00 committed by GitHub
parent 923556ea27
commit ea7466682b
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.baeldung.isemptyvsisblank;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class StringIsEmptyVsIsBlankUnitTest {
@Test
public void givenString_whenCallIsEmpty_thenReturnCorrectValues() {
assertFalse("Example text".isEmpty());
assertTrue("".isEmpty());
assertFalse(" ".isEmpty());
assertFalse("\t\n\r\f".isEmpty());
}
@Test
public void givenString_whenCallStringIsBlank_thenReturnCorrectValues() {
assertFalse("Example text".isBlank());
assertTrue("".isBlank());
assertTrue(" ".isBlank());
assertTrue("\t\n\r\f ".isBlank());
}
}