add methods

This commit is contained in:
Looly
2021-03-26 21:50:21 +08:00
parent 6a8e5d8b6c
commit 2484c82584
8 changed files with 163 additions and 172 deletions

View File

@@ -4,7 +4,7 @@ import org.junit.Assert;
import org.junit.Test;
public class CharUtilTest {
@Test
public void trimTest() {
//此字符串中的第一个字符为不可见字符: '\u202a'
@@ -12,13 +12,13 @@ public class CharUtilTest {
Assert.assertEquals('\u202a', str.charAt(0));
Assert.assertTrue(CharUtil.isBlankChar(str.charAt(0)));
}
@Test
public void isEmojiTest() {
String a = "莉🌹";
Assert.assertFalse(CharUtil.isEmoji(a.charAt(0)));
Assert.assertTrue(CharUtil.isEmoji(a.charAt(1)));
}
@Test
@@ -38,4 +38,18 @@ public class CharUtilTest {
char a3 = '\u3000';
Assert.assertTrue(CharUtil.isBlankChar(a3));
}
@Test
public void toCloseCharTest(){
Assert.assertEquals('②', CharUtil.toCloseChar('2'));
Assert.assertEquals('Ⓜ', CharUtil.toCloseChar('M'));
Assert.assertEquals('ⓡ', CharUtil.toCloseChar('r'));
}
@Test
public void toCloseByNumberTest(){
Assert.assertEquals('②', CharUtil.toCloseByNumber(2));
Assert.assertEquals('⑫', CharUtil.toCloseByNumber(12));
Assert.assertEquals('⑳', CharUtil.toCloseByNumber(20));
}
}

View File

@@ -9,26 +9,26 @@ import org.junit.Test;
*
*/
public class HexUtilTest {
@Test
public void hexStrTest(){
String str = "我是一个字符串";
String hex = HexUtil.encodeHexStr(str, CharsetUtil.CHARSET_UTF_8);
String decodedStr = HexUtil.decodeHexStr(hex);
Assert.assertEquals(str, decodedStr);
}
@Test
public void toUnicodeHexTest() {
String unicodeHex = HexUtil.toUnicodeHex('\u2001');
Assert.assertEquals("\\u2001", unicodeHex);
unicodeHex = HexUtil.toUnicodeHex('你');
Assert.assertEquals("\\u4f60", unicodeHex);
}
@Test
public void isHexNumberTest() {
String a = "0x3544534F444";