Skip to content

Commit

Permalink
CLDR-15817 Modify test to check only paths shown to users
Browse files Browse the repository at this point in the history
  • Loading branch information
haytenf committed Sep 9, 2024
1 parent 32b8c02 commit 7fc5946
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ private void handleDateFormatItem(
cldrFile.getWinningPath(xpath.replaceAll("dateTimeFormat", "timeFormat"));
int tfLengthOffset = timeFormatXPathForPrefix.indexOf("timeFormatLength");
if (tfLengthOffset < 0) {
examples.add("");
// examples.add("");
return;
}
String timeFormatXPathPrefix = timeFormatXPathForPrefix.substring(0, tfLengthOffset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,28 @@ public String sampleAttrAndValue(PathStarrer ps, final String separator, String
return ps.getAttributesString(separator) + "➔«" + value + "»";
}

PathHeader.Factory phf = PathHeader.getFactory(null);

private boolean isValidPath(String xpath, ULocale locale) {
PathHeader ph = phf.fromPath(xpath);
if (ph == null) {
return false;
}
if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.DEPRECATED) {
return false;
}
if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.HIDE
|| ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.READ_ONLY) {
return false;
}

if (SDI.getCoverageValue(xpath, locale.getBaseName())
> org.unicode.cldr.util.Level.COMPREHENSIVE.getLevel()) {
return false;
}
return true;
}

public void TestRefactoring() {
for (ULocale locale : ULocale.getAvailableLocales()) {
String loc = locale.toString();
Expand All @@ -2089,16 +2111,18 @@ public void TestRefactoring() {
ExampleGeneratorOld exampleGeneratorOld =
new ExampleGeneratorOld(resolvedCldrFile, info.getEnglish());
for (String path : unresolvedCldrFile) {
String value = unresolvedCldrFile.getStringValue(path);
String oldExample = exampleGeneratorOld.getExampleHtml(path, value);
String newExample = exampleGenerator.getExampleHtml(path, value);
assertEquals(
"Ensure same example pre/post refactoring for locale: "
+ loc
+ "and path: "
+ path,
oldExample,
newExample);
if (isValidPath(path, locale)) {
String value = unresolvedCldrFile.getStringValue(path);
String oldExample = exampleGeneratorOld.getExampleHtml(path, value);
String newExample = exampleGenerator.getExampleHtml(path, value);
assertEquals(
"Ensure same example pre/post refactoring for locale: "
+ loc
+ "and path: "
+ path,
oldExample,
newExample);
}
}
}
}
Expand Down

0 comments on commit 7fc5946

Please sign in to comment.