add testr

This commit is contained in:
Looly 2022-09-21 18:23:49 +08:00
parent 5f68c73938
commit dbf87f452f

View File

@ -7,8 +7,8 @@ public class PunyCodeTest {
@Test @Test
public void encodeDecodeTest(){ public void encodeDecodeTest(){
String text = "Hutool编码器"; final String text = "Hutool编码器";
String strPunyCode = PunyCode.encode(text); final String strPunyCode = PunyCode.encode(text);
Assert.assertEquals("Hutool-ux9js33tgln", strPunyCode); Assert.assertEquals("Hutool-ux9js33tgln", strPunyCode);
String decode = PunyCode.decode("Hutool-ux9js33tgln"); String decode = PunyCode.decode("Hutool-ux9js33tgln");
Assert.assertEquals(text, decode); Assert.assertEquals(text, decode);
@ -19,25 +19,34 @@ public class PunyCodeTest {
@Test @Test
public void encodeDecodeTest2(){ public void encodeDecodeTest2(){
// 无需编码和解码 // 无需编码和解码
String text = "Hutool"; final String text = "Hutool";
String strPunyCode = PunyCode.encode(text); final String strPunyCode = PunyCode.encode(text);
Assert.assertEquals("Hutool", strPunyCode); Assert.assertEquals("Hutool", strPunyCode);
} }
@Test @Test
public void encodeEncodeDomainTest(){ public void encodeEncodeDomainTest(){
String domain = "赵新虎.中国"; final String domain = "赵新虎.中国";
String strPunyCode = PunyCode.encodeDomain(domain); final String strPunyCode = PunyCode.encodeDomain(domain);
String decode = PunyCode.decodeDomain(strPunyCode); final String decode = PunyCode.decodeDomain(strPunyCode);
Assert.assertEquals(decode, domain); Assert.assertEquals(decode, domain);
} }
@Test @Test
public void encodeEncodeDomainTest2(){ public void encodeEncodeDomainTest2(){
String domain = "赵新虎.com"; final String domain = "赵新虎.com";
String strPunyCode = PunyCode.encodeDomain(domain); final String strPunyCode = PunyCode.encodeDomain(domain);
Assert.assertEquals("xn--efvz93e52e.com", strPunyCode); Assert.assertEquals("xn--efvz93e52e.com", strPunyCode);
String decode = PunyCode.decodeDomain(strPunyCode); final String decode = PunyCode.decodeDomain(strPunyCode);
Assert.assertEquals(domain, decode);
}
@Test
public void encodeEncodeDomainTest3(){
final String domain = "赵新虎.COM";
final String strPunyCode = PunyCode.encodeDomain(domain);
Assert.assertEquals("xn--efvz93e52e.COM", strPunyCode);
final String decode = PunyCode.decodeDomain(strPunyCode);
Assert.assertEquals(domain, decode); Assert.assertEquals(domain, decode);
} }
} }