mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
c9064c2334
commit
8b98cb3e90
@ -1,9 +1,13 @@
|
|||||||
package cn.hutool.core.net;
|
package cn.hutool.core.net;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.PercentCodec;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
public class RFC3986Test {
|
public class RFC3986Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -26,4 +30,12 @@ public class RFC3986Test {
|
|||||||
String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=%25", CharsetUtil.CHARSET_UTF_8, '%');
|
String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=%25", CharsetUtil.CHARSET_UTF_8, '%');
|
||||||
Assert.assertEquals("a=%25", encode);
|
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…
x
Reference in New Issue
Block a user