mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add test
This commit is contained in:
parent
c9064c2334
commit
8b98cb3e90
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user