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