Skip to content

Commit

Permalink
report all failures
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Jan 7, 2024
1 parent 361a977 commit 0380b27
Showing 1 changed file with 47 additions and 72 deletions.
119 changes: 47 additions & 72 deletions unicodetools/src/test/java/org/unicode/propstest/TestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,49 @@ private void checkQuickCheckOnNormalizationTest(
String normalizationTest =
org.unicode.text.utility.Utility.getMostRecentUnicodeDataFile(
"NormalizationTest", GenerateEnums.ENUM_VERSION, true, false);
String partLine = null;
for (String line : FileUtilities.in("", normalizationTest)) {
line = line.trim();
if (line.startsWith("#") || line.startsWith("@Part")) {
if (line.startsWith("#")) {
continue;
}
if (line.startsWith("@Part")) {
partLine = line;
continue;
}
String[] parts = Arrays.copyOfRange(line.split(";"), 0, 5);
for (String part : parts) {
checkQuickCheck(
normalizer, isAllowed, org.unicode.text.utility.Utility.fromHex(part));
normalizer,
isAllowed,
org.unicode.text.utility.Utility.fromHex(part),
partLine);
}
}
}

private void checkQuickCheck(
Normalizer normalizer, UnicodeMap<String> isAllowed, String testCase) {
Normalizer normalizer, UnicodeMap<String> isAllowed, String testCase, String context) {
if (testCase.equals(normalizer.normalize(testCase))) {
assertNotEquals(
normalizer.getName()
+ " quickCheck returns NO for normalized string "
+ Default.ucd().getName(testCase),
quickCheck(isAllowed, testCase),
NO);
if (quickCheck(isAllowed, testCase) == NO) {
errln(
normalizer.getName()
+ " quickCheck returns NO for normalized string "
+ Default.ucd().getName(testCase)
+ " ("
+ context
+ ")");
}
} else {
assertNotEquals(
normalizer.getName()
+ " quickCheck returns YES for non-normalized string "
+ Default.ucd().getName(testCase),
quickCheck(isAllowed, testCase),
YES);
if (quickCheck(isAllowed, testCase) == YES) {
errln(
normalizer.getName()
+ " quickCheck returns YES for non-normalized string "
+ Default.ucd().getName(testCase)
+ " ("
+ context
+ ")");
}
}
}

Expand Down Expand Up @@ -290,79 +304,40 @@ public void TestNFCQuickCheckConsistency() {
UnicodeMap<String> nfcqc = iup.load(UcdProperty.NFC_Quick_Check);
UnicodeMap<String> dm = iup.load(UcdProperty.Decomposition_Mapping);
UnicodeMap<String> dt = iup.load(UcdProperty.Decomposition_Type);
UnicodeMap<String> age = iup.load(UcdProperty.Age);
for (String codepoint : nfcqc.getSet("Yes")) {
if (!dt.getValue(codepoint).equals("Canonical")
|| age.getValue(codepoint).equals("V16_0")) {
continue;
}
String decompositionFirst = Character.toString(dm.getValue(codepoint).codePointAt(0));
String decompositionFirstNFCQC = nfcqc.getValue(decompositionFirst);
assertEquals(
"Pre-16 U+"
+ getCodeAndName(codepoint)
+ "(Age="
+ age.getValue(codepoint)
+ ") has NFC_QC=Yes, but its (canonical) Decomposition_Mapping starts with U+"
+ getCodeAndName(decompositionFirst)
+ ", which has NFC_QC="
+ decompositionFirstNFCQC,
"Yes",
decompositionFirstNFCQC);
}
for (String codepoint : nfcqc.getSet("Yes")) {
if (!dt.getValue(codepoint).equals("Canonical")) {
continue;
}
String decompositionFirst = Character.toString(dm.getValue(codepoint).codePointAt(0));
String decompositionFirstNFCQC = nfcqc.getValue(decompositionFirst);
assertEquals(
"U+"
+ getCodeAndName(codepoint)
+ " has NFC_QC=Yes, but its (canonical) Decomposition_Mapping starts with U+"
+ getCodeAndName(decompositionFirst)
+ ", which has NFC_QC="
+ decompositionFirstNFCQC,
"Yes",
decompositionFirstNFCQC);
if (!decompositionFirstNFCQC.equals("Yes")) {
errln(
"U+"
+ getCodeAndName(codepoint)
+ " has NFC_QC=Yes, but its (canonical) Decomposition_Mapping starts with U+"
+ getCodeAndName(decompositionFirst)
+ ", which has NFC_QC="
+ decompositionFirstNFCQC);
}
}
}

@Test
public void TestNFKCQuickCheckConsistency() {
UnicodeMap<String> nfkcqc = iup.load(UcdProperty.NFKC_Quick_Check);
UnicodeMap<String> dm = iup.load(UcdProperty.Decomposition_Mapping);
UnicodeMap<String> age = iup.load(UcdProperty.Age);
for (String codepoint : nfkcqc.getSet("Yes")) {
if (age.getValue(codepoint).equals("V16_0")) {
continue;
}
String decompositionFirst = Character.toString(dm.getValue(codepoint).codePointAt(0));
String decompositionFirstNFKCQC = nfkcqc.getValue(decompositionFirst);
assertEquals(
"Pre-16 U+"
+ getCodeAndName(codepoint)
+ "(Age="
+ age.getValue(codepoint)
+ ") has NFKC_QC=Yes, but its Decomposition_Mapping starts with U+"
+ getCodeAndName(decompositionFirst)
+ ", which has NFKC_QC="
+ decompositionFirstNFKCQC,
"Yes",
decompositionFirstNFKCQC);
}
for (String codepoint : nfkcqc.getSet("Yes")) {
String decompositionFirst = Character.toString(dm.getValue(codepoint).codePointAt(0));
String decompositionFirstNFKCQC = nfkcqc.getValue(decompositionFirst);
assertEquals(
"U+"
+ getCodeAndName(codepoint)
+ " has NFKC_QC=Yes, but its Decomposition_Mapping starts with U+"
+ getCodeAndName(decompositionFirst)
+ ", which has NFKC_QC="
+ decompositionFirstNFKCQC,
"Yes",
decompositionFirstNFKCQC);
if (!decompositionFirstNFKCQC.equals("Yes")) {
errln(
"U+"
+ getCodeAndName(codepoint)
+ " has NFKC_QC=Yes, but its Decomposition_Mapping starts with U+"
+ getCodeAndName(decompositionFirst)
+ ", which has NFKC_QC="
+ decompositionFirstNFKCQC);
}
}
}

Expand Down

0 comments on commit 0380b27

Please sign in to comment.