Browse Source

feat:对stringkit进行方法的补充,增加相应的单测

pull/11/head
zjz1993 5 years ago
parent
commit
aec68abc8a
  1. 9
      src/main/java/com/fanruan/api/util/StringKit.java
  2. 10
      src/test/java/com/fanruan/api/util/StringKitTest.java

9
src/main/java/com/fanruan/api/util/StringKit.java

@ -85,5 +85,14 @@ public class StringKit {
public static boolean isNotBlank(String text) { public static boolean isNotBlank(String text) {
return StringUtils.isNotBlank(text); return StringUtils.isNotBlank(text);
} }
/**
* 对字符串做trim操作
*
* @param string 源字符串
* @return 返回操作后的字符串
*/
public static String trim(String string) {
return StringUtils.trim(string);
}
} }

10
src/test/java/com/fanruan/api/util/StringKitTest.java

@ -1,5 +1,6 @@
package com.fanruan.api.util; package com.fanruan.api.util;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -26,4 +27,13 @@ public class StringKitTest {
@Test @Test
public void isNotBlank() { public void isNotBlank() {
} }
@Test
public void trim(){
String stringHaveBlank = " abc ";
String stringWithoutBlank = "abc";
String blankString = " ";
Assert.assertEquals(StringKit.trim(stringHaveBlank), "abc");
Assert.assertEquals(StringKit.trim(stringWithoutBlank), "abc");
Assert.assertEquals(StringKit.trim(blankString), "");
}
} }
Loading…
Cancel
Save