// Check passing in a string with broken surrogate pairs
// and with correct surrogate pairs
public void testSurrogates() {
String goodString = "test: \uD8F5\uDF80 ";
Comment c = new Comment(goodString);
assertEquals(goodString, c.getValue());
// Two high-halves
try {
new Comment("test: \uD8F5\uDBF0 ");
fail("Should raise an IllegalCharacterDataException");
}
catch (IllegalCharacterDataException success) {
assertEquals("test: \uD8F5\uDBF0 ", success.getData());
assertNotNull(success.getMessage());
}
// Two high-halves
try {
new Comment("test: \uD8F5\uD8F5 ");
fail("Should raise an IllegalCharacterDataException");
}
catch (IllegalCharacterDataException success) {
assertEquals("test: \uD8F5\uD8F5 ", success.getData());
assertNotNull(success.getMessage());
}
// One high-half
try {
new Comment("test: \uD8F5 ");
fail("Should raise an IllegalCharacterDataException");
}
catch (IllegalCharacterDataException success) {
assertEquals("test: \uD8F5 ", success.getData());
assertNotNull(success.getMessage());
}
// One low half
try {
new Comment("test: \uDF80 ");
fail("Should raise an IllegalCharacterDataException");
}
catch (IllegalCharacterDataException success) {
assertEquals("test: \uDF80 ", success.getData());
assertNotNull(success.getMessage());
}
// Low half before high half
try {
new Comment("test: \uDCF5\uD8F5 ");
fail("Should raise an IllegalCharacterDataException");
}
catch (IllegalCharacterDataException success) {
assertEquals("test: \uDCF5\uD8F5 ", success.getData());
assertNotNull(success.getMessage());