Add UTF-8 tests for BDF Reader and Writer

This commit is contained in:
Torsten Grote
2016-01-12 17:04:59 -02:00
parent 27cb64e936
commit 0dfa1b5254
2 changed files with 25 additions and 4 deletions

View File

@@ -273,6 +273,19 @@ public class BdfReaderImplTest extends BriarTestCase {
assertTrue(r.eof());
}
@Test
public void testReadUtf8String() throws Exception {
String str = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \uFDD0\uFDD1\uFDD2\uFDD3\uFDD1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
String strHex = StringUtils.toHexString(str.getBytes("UTF-8"));
// STRING_8 tag, "foo", the empty string, and the test string
setContents("41" + "03" + "666F6F" + "41" + "00" +
"41" + "35" + strHex);
assertEquals("foo", r.readString(Integer.MAX_VALUE));
assertEquals("", r.readString(Integer.MAX_VALUE));
assertEquals(str, r.readString(Integer.MAX_VALUE));
assertTrue(r.eof());
}
@Test
public void testReadRaw8() throws Exception {
byte[] longest = new byte[Byte.MAX_VALUE];