add FileUtilTest case

pull/669/head
liulinfei121 3 years ago
parent 43fc754f4d
commit d1bce3f9c3

@ -19,6 +19,8 @@ package cn.hippo4j.common.toolkit;
import org.junit.Test; import org.junit.Test;
import java.io.UnsupportedEncodingException;
public class FileUtilTest { public class FileUtilTest {
@Test @Test
@ -27,4 +29,13 @@ public class FileUtilTest {
String contentByFileUtil = FileUtil.readUtf8String(testFilePath); String contentByFileUtil = FileUtil.readUtf8String(testFilePath);
Assert.notEmpty(contentByFileUtil); Assert.notEmpty(contentByFileUtil);
} }
}
@Test
public void assertReadUtf8String2() throws UnsupportedEncodingException {
String testText = new String(("abcd简体繁体\uD83D\uDE04\uD83D\uDD25& *\r\nsecond line\r\n" +
"empty line next\r\n").getBytes(),"utf-8");
String testFilePath = "test/test_utf8.txt";
String contentByFileUtil = FileUtil.readUtf8String(testFilePath);
Assert.isTrue(testText.equals(contentByFileUtil));
}
}
Loading…
Cancel
Save