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:
Danylo 2020-06-24 11:09:54 +03:00
parent 43d6779e12
commit ce2d29cee0
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(" . "));
}
}