mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Remove unescaped Unicode from tests. #218
This commit is contained in:
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class BdfReaderImplTest extends BriarTestCase {
|
||||
|
||||
@@ -260,14 +259,13 @@ public class BdfReaderImplTest extends BriarTestCase {
|
||||
|
||||
@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 unicode = "\uFDD0\uFDD1\uFDD2\uFDD3";
|
||||
String hex = StringUtils.toHexString(unicode.getBytes("UTF-8"));
|
||||
// STRING_8 tag, "foo", the empty string, and the test string
|
||||
setContents("41" + "03" + "666F6F" + "41" + "00" +
|
||||
"41" + "35" + strHex);
|
||||
setContents("41" + "03" + "666F6F" +"41" + "00" + "41" + "0C" + hex);
|
||||
assertEquals("foo", r.readString(Integer.MAX_VALUE));
|
||||
assertEquals("", r.readString(Integer.MAX_VALUE));
|
||||
assertEquals(str, r.readString(Integer.MAX_VALUE));
|
||||
assertEquals(unicode, r.readString(Integer.MAX_VALUE));
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
|
||||
@@ -114,11 +114,11 @@ public class BdfWriterImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteUtf8String() throws IOException {
|
||||
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"));
|
||||
w.writeString(str);
|
||||
// STRING_8 tag, length 53, UTF-8 bytes
|
||||
checkContents("41" + "35" + strHex);
|
||||
String unicode = "\uFDD0\uFDD1\uFDD2\uFDD3";
|
||||
String hex = StringUtils.toHexString(unicode.getBytes("UTF-8"));
|
||||
w.writeString(unicode);
|
||||
// STRING_8 tag, length 12, UTF-8 bytes
|
||||
checkContents("41" + "0C" + hex);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -73,10 +73,10 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testUtf8String() throws FormatException {
|
||||
d.put("test", "abcdefghilkmnopqrst <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \uFDD0\uFDD1\uFDD2\uFDD3");
|
||||
d.put("test", "abcdefghilkmnopqrst \uFDD0\uFDD1\uFDD2\uFDD3");
|
||||
Metadata metadata = e.encode(d);
|
||||
|
||||
assertEquals("abcdefghilkmnopqrst <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \uFDD0\uFDD1\uFDD2\uFDD3",
|
||||
assertEquals("abcdefghilkmnopqrst \uFDD0\uFDD1\uFDD2\uFDD3",
|
||||
p.parse(metadata).getString("test", null));
|
||||
}
|
||||
|
||||
@@ -124,9 +124,9 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
||||
public void testComplexDictionary() throws FormatException {
|
||||
Map<String, List> m = new HashMap<String, List>();
|
||||
List<String> one = new ArrayList<String>(3);
|
||||
one.add("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
one.add("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
one.add("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
one.add("\uFDD0");
|
||||
one.add("\uFDD1");
|
||||
one.add("\uFDD2");
|
||||
m.put("One", one);
|
||||
List<String> two = new ArrayList<String>(2);
|
||||
two.add("\u0080");
|
||||
@@ -140,11 +140,11 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
||||
|
||||
Metadata metadata = e.encode(d);
|
||||
|
||||
assertEquals("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", p.parse(metadata).getDictionary("test", null)
|
||||
assertEquals("\uFDD0", p.parse(metadata).getDictionary("test", null)
|
||||
.getList("One", null).get(0));
|
||||
assertEquals("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", p.parse(metadata).getDictionary("test", null)
|
||||
assertEquals("\uFDD1", p.parse(metadata).getDictionary("test", null)
|
||||
.getList("One", null).get(1));
|
||||
assertEquals("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", p.parse(metadata).getDictionary("test", null)
|
||||
assertEquals("\uFDD2", p.parse(metadata).getDictionary("test", null)
|
||||
.getList("One", null).get(2));
|
||||
assertEquals("\u0080", p.parse(metadata).getDictionary("test", null)
|
||||
.getList("Two", null).get(0));
|
||||
@@ -154,5 +154,4 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
|
||||
assertEquals(true, p.parse(metadata).getDictionary("another test", null)
|
||||
.getBoolean("should be true", false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user