mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package cn.hutool.core.net;
|
||||
|
||||
import cn.hutool.core.codec.PercentCodec;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class RFC3986Test {
|
||||
|
||||
@Test
|
||||
@@ -26,4 +30,12 @@ public class RFC3986Test {
|
||||
String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=%25", CharsetUtil.CHARSET_UTF_8, '%');
|
||||
Assert.assertEquals("a=%25", encode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeAllTest() throws UnsupportedEncodingException {
|
||||
String toVerifyText = "行吧行吧 cargo:1.0,\"Deta-ils:[{";
|
||||
final String encode = PercentCodec.of(RFC3986.UNRESERVED).setEncodeSpaceAsPlus(true).encode(toVerifyText, CharsetUtil.CHARSET_UTF_8);
|
||||
final String encodeJdk = URLEncoder.encode(toVerifyText, "UTF-8");
|
||||
Assert.assertEquals(encode, encodeJdk);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user