Add and rework isEmpty, isNotEmpty, isEmptyTrimmed, isNotEmptyTrimmed

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137417 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-07-14 22:26:22 +00:00
parent eadb45d1a7
commit 83dd0ea7b8
1 changed files with 25 additions and 7 deletions

View File

@ -63,7 +63,7 @@ import junit.textui.TestRunner;
* *
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a> * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a> * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
* @version $Id: StringUtilsTrimEmptyTest.java,v 1.7 2003/03/24 00:47:02 scolebourne Exp $ * @version $Id: StringUtilsTrimEmptyTest.java,v 1.8 2003/07/14 22:26:22 scolebourne Exp $
*/ */
public class StringUtilsTrimEmptyTest extends TestCase { public class StringUtilsTrimEmptyTest extends TestCase {
private static final String FOO = "foo"; private static final String FOO = "foo";
@ -132,18 +132,36 @@ public class StringUtilsTrimEmptyTest extends TestCase {
assertEquals("", StringUtils.trimToEmpty(null)); assertEquals("", StringUtils.trimToEmpty(null));
} }
public void testIsEmpty() {
assertEquals(false, StringUtils.isEmpty("foo"));
assertEquals(false, StringUtils.isEmpty(" foo "));
assertEquals(false, StringUtils.isEmpty(" "));
assertEquals(true, StringUtils.isEmpty(""));
assertEquals(true, StringUtils.isEmpty(null));
}
public void testIsNotEmpty() { public void testIsNotEmpty() {
assertEquals(true, StringUtils.isNotEmpty(FOO)); assertEquals(true, StringUtils.isNotEmpty("foo"));
assertEquals(true, StringUtils.isNotEmpty(" foo "));
assertEquals(true, StringUtils.isNotEmpty(" ")); assertEquals(true, StringUtils.isNotEmpty(" "));
assertEquals(false, StringUtils.isNotEmpty("")); assertEquals(false, StringUtils.isNotEmpty(""));
assertEquals(false, StringUtils.isNotEmpty(null)); assertEquals(false, StringUtils.isNotEmpty(null));
} }
public void testIsEmpty() { public void testIsEmptyTrimmed() {
assertEquals(false, StringUtils.isEmpty(FOO)); assertEquals(false, StringUtils.isEmptyTrimmed("foo"));
assertEquals(true, StringUtils.isEmpty(" ")); assertEquals(false, StringUtils.isEmptyTrimmed(" foo "));
assertEquals(true, StringUtils.isEmpty("")); assertEquals(true, StringUtils.isEmptyTrimmed(" "));
assertEquals(true, StringUtils.isEmpty(null)); assertEquals(true, StringUtils.isEmptyTrimmed(""));
assertEquals(true, StringUtils.isEmptyTrimmed(null));
}
public void testIsNotEmptyTrimmed() {
assertEquals(true, StringUtils.isNotEmptyTrimmed("foo"));
assertEquals(true, StringUtils.isNotEmptyTrimmed(" foo "));
assertEquals(false, StringUtils.isNotEmptyTrimmed(" "));
assertEquals(false, StringUtils.isNotEmptyTrimmed(""));
assertEquals(false, StringUtils.isNotEmptyTrimmed(null));
} }
public void testDeleteSpace() { public void testDeleteSpace() {