Enhanced the javadoc of StringUtil's method and added a test.
I added parameter and return value desriptions for the method StringUtil.isEmpty(String s). Also, I added a test class StringUtilTest to test this method (this method didn't have a test before).
This commit is contained in:
parent
43d6779e12
commit
ce2d29cee0
@ -8,8 +8,10 @@ public class StringUtil {
|
||||
* This is implemented without using String.isEmpty() because that method
|
||||
* is not available in Froyo.
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
* @param s string to check
|
||||
* @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 ) {
|
||||
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