Skip to content
Snippets Groups Projects
Unverified Commit 58b60379 authored by akwizgran's avatar akwizgran
Browse files

Remove unescaped Unicode from tests. #218

parent ea02caf5
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,6 @@ import static org.junit.Assert.assertArrayEquals; ...@@ -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 { ...@@ -260,14 +259,13 @@ public class BdfReaderImplTest extends BriarTestCase {
@Test @Test
public void testReadUtf8String() throws Exception { public void testReadUtf8String() throws Exception {
String str = "������ \uFDD0\uFDD1\uFDD2\uFDD3\uFDD1 ������"; 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 { ...@@ -114,11 +114,11 @@ public class BdfWriterImplTest extends BriarTestCase {
@Test @Test
public void testWriteUtf8String() throws IOException { public void testWriteUtf8String() throws IOException {
String str = "������ \uFDD0\uFDD1\uFDD2\uFDD3\uFDD1 ������"; 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 { ...@@ -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 ������ \uFDD0\uFDD1\uFDD2\uFDD3"); d.put("test", "abcdefghilkmnopqrst \uFDD0\uFDD1\uFDD2\uFDD3");
Metadata metadata = e.encode(d); Metadata metadata = e.encode(d);
assertEquals("abcdefghilkmnopqrst ������ \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 { ...@@ -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("����"); one.add("\uFDD0");
one.add("������"); one.add("\uFDD1");
one.add("����"); 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 { ...@@ -140,11 +140,11 @@ public class MetadataEncoderParserImplTest extends BriarTestCase {
Metadata metadata = e.encode(d); Metadata metadata = e.encode(d);
assertEquals("����", 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("������", 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("����", 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 { ...@@ -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));
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment