Merge branch 'metadata-encoder-parser-tests' into 'master'

Add tests for metadata encoder and parser as well as UTF-8 tests for BDF reader and writer

This also includes a commit to fix issues found in the metadata encoder and parser.

See merge request !58
This commit is contained in:
akwizgran
2016-01-13 17:25:34 +00:00
7 changed files with 223 additions and 62 deletions

View File

@@ -258,6 +258,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];