Merge pull request #687 from DanielLyi/unstable
Enhanced the javadoc of StringUtil's method and added a test.
This commit is contained in:
commit
2685702b66
@ -8,8 +8,10 @@ public class StringUtil {
|
|||||||
* This is implemented without using String.isEmpty() because that method
|
* This is implemented without using String.isEmpty() because that method
|
||||||
* is not available in Froyo.
|
* is not available in Froyo.
|
||||||
*
|
*
|
||||||
* @param s
|
* @param s string to check
|
||||||
* @return
|
* @return true iff s is null or trims to
|
||||||
|
* an empty string, where trim is defined
|
||||||
|
* by {@link java.lang.String#trim}
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty( String s ) {
|
public static boolean isEmpty( String s ) {
|
||||||
if ( s == null ) {
|
if ( s == null ) {
|
||||||
|
25
core/test/net/sf/openrocket/util/StringUtilTest.java
Normal file
25
core/test/net/sf/openrocket/util/StringUtilTest.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package net.sf.openrocket.util;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class that tests
|
||||||
|
* {@link net.sf.openrocket.util.StringUtil}.
|
||||||
|
*/
|
||||||
|
public class StringUtilTest {
|
||||||
|
@Test
|
||||||
|
public void testStrings() {
|
||||||
|
assertTrue(StringUtil.isEmpty(""));
|
||||||
|
assertTrue(StringUtil.isEmpty(new StringBuilder().toString())); // ""
|
||||||
|
assertTrue(StringUtil.isEmpty(" "));
|
||||||
|
assertTrue(StringUtil.isEmpty(" "));
|
||||||
|
assertTrue(StringUtil.isEmpty(" "));
|
||||||
|
assertTrue(StringUtil.isEmpty(null));
|
||||||
|
|
||||||
|
assertFalse(StringUtil.isEmpty("A"));
|
||||||
|
assertFalse(StringUtil.isEmpty(" . "));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user