mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-16 04:59:35 +08:00
add test
This commit is contained in:
parent
e7fb9759f3
commit
f441b319da
@ -132,7 +132,7 @@ public class Base64Encoder {
|
|||||||
*
|
*
|
||||||
* @param arr 被编码的数组
|
* @param arr 被编码的数组
|
||||||
* @param isMultiLine 在76个char之后是CRLF还是EOF
|
* @param isMultiLine 在76个char之后是CRLF还是EOF
|
||||||
* @param isUrlSafe 是否使用URL安全字符,一般为{@code false}
|
* @param isUrlSafe 是否使用URL安全字符,在URL Safe模式下,=为URL中的关键字符,不需要补充。空余的byte位要去掉,一般为{@code false}
|
||||||
* @return 编码后的bytes
|
* @return 编码后的bytes
|
||||||
*/
|
*/
|
||||||
public static byte[] encode(byte[] arr, boolean isMultiLine, boolean isUrlSafe) {
|
public static byte[] encode(byte[] arr, boolean isMultiLine, boolean isUrlSafe) {
|
||||||
|
@ -23,6 +23,16 @@ public class Base64Test {
|
|||||||
Assert.assertEquals(a, decodeStr);
|
Assert.assertEquals(a, decodeStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void encodeAndDecodeWithoutPaddingTest() {
|
||||||
|
String a = "伦家是一个非常长的字符串66";
|
||||||
|
String encode = Base64.encodeWithoutPadding(StrUtil.utf8Bytes(a));
|
||||||
|
Assert.assertEquals("5Lym5a625piv5LiA5Liq6Z2e5bi46ZW/55qE5a2X56ym5LiyNjY", encode);
|
||||||
|
|
||||||
|
String decodeStr = Base64.decodeStr(encode);
|
||||||
|
Assert.assertEquals(a, decodeStr);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeAndDecodeTest2() {
|
public void encodeAndDecodeTest2() {
|
||||||
String a = "a61a5db5a67c01445ca2-HZ20181120172058/pdf/中国电信影像云单体网关Docker版-V1.2.pdf";
|
String a = "a61a5db5a67c01445ca2-HZ20181120172058/pdf/中国电信影像云单体网关Docker版-V1.2.pdf";
|
||||||
|
Loading…
Reference in New Issue
Block a user