Merge pull request #687 from DanielLyi/unstable

Enhanced the javadoc of StringUtil's method and added a test.
This commit is contained in:
Daniel Williams 2020-06-24 18:32:52 -04:00 committed by GitHub
commit 2685702b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View File

@ -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 ) {

View 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(" . "));
}
}