mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add test: StringHelper
This commit is contained in:
1 parent
99d7f94fec
commit
d7f063cbb9
3 files changed
+95
-12
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:47 2021/3/23
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class StringHelperTest {
|
||||
@Test
|
||||
public void testEscapeAndUnescape(){
|
||||
String s1="北京大学深圳研究生院";
|
||||
String s2=StringHelper.escape(s1);
|
||||
System.out.println(s2);
|
||||
String s3=StringHelper.unescape(s2);
|
||||
System.out.println(s3);
|
||||
assertEquals(s1,s3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEscape(){
|
||||
String s="-_~.a北京大学z深圳A研究生院Z";
|
||||
String encoded=StringHelper.escape(s);
|
||||
String want="-_~.a%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6z%E6%B7%B1%E5%9C%B3A%E7%A0%94%E7%A9%B6%E7%94%9F%E9%99%A2Z";
|
||||
String decoded=StringHelper.unescape(encoded);
|
||||
assertEquals(encoded,want);
|
||||
assertEquals(decoded,s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEscape2(){
|
||||
String s="-_~.azAZ09";
|
||||
String encoded=StringHelper.escape(s);
|
||||
String want="-_~.azAZ09";
|
||||
String decoded=StringHelper.unescape(encoded);
|
||||
assertEquals(encoded,want);
|
||||
assertEquals(decoded,s);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user