Skip to content

Commit

Permalink
Update ASCIICharacterCheckerTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyan-z authored Nov 21, 2023
1 parent df03a01 commit a587359
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ public class ASCIICharacterCheckerTest {
@Test
void fieldAcceptsAsciiCharacters() {
entry.setField(StandardField.TITLE, "Only ascii characters!'@12");
assertEquals(Collections.emptyList(), checker.check(entry));
assertEquals(Collections.emptyList(),
new FieldChecker(StandardField.TITLE, checker).check(entry));
}

@Test
void fieldDoesNotAcceptUmlauts() {
entry.setField(StandardField.MONTH, "Umlauts are nöt ällowed");
assertEquals(List.of(new IntegrityMessage("Non-ASCII encoded character found", entry, StandardField.MONTH)), checker.check(entry));
assertEquals(List.of(new IntegrityMessage("Non-ASCII encoded character found", entry, StandardField.MONTH)),
new FieldChecker(StandardField.MONTH, checker).check(entry));
}

@Test
void fieldDoesNotAcceptUnicode() {
entry.setField(StandardField.AUTHOR, "Some unicode ⊕");
assertEquals(List.of(new IntegrityMessage("Non-ASCII encoded character found", entry, StandardField.AUTHOR)), checker.check(entry));
assertEquals(List.of(new IntegrityMessage("Non-ASCII encoded character found", entry, StandardField.AUTHOR)),
new FieldChecker(StandardField.AUTHOR, checker).check(entry));
}

@Test
Expand All @@ -40,13 +43,15 @@ void fieldAcceptsOnlyAsciiCharacters() {
field += Character.toString(i);
}
entry.setField(StandardField.TITLE, field);
assertEquals(Collections.emptyList(), checker.check(entry));
assertEquals(Collections.emptyList(),
new FieldChecker(StandardField.TITLE, checker).check(entry));
}

@Test
void fieldDoesNotAcceptNonAsciiCharacters() {
String field = Character.toString(31) + Character.toString(128);
entry.setField(StandardField.TITLE, field);
assertEquals(List.of(new IntegrityMessage("Non-ASCII encoded character found", entry, StandardField.TITLE)), checker.check(entry));
assertEquals(List.of(new IntegrityMessage("Non-ASCII encoded character found", entry, StandardField.TITLE)),
new FieldChecker(StandardField.TITLE, checker).check(entry));
}
}

0 comments on commit a587359

Please sign in to comment.