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