Skip to content

Commit

Permalink
CLDR-11155 Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
macchiati committed Feb 24, 2024
1 parent b7f2417 commit d8bfd09
Showing 1 changed file with 79 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package org.unicode.cldr.unittest;

import com.google.common.base.Joiner;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
import com.ibm.icu.impl.Relation;
import com.ibm.icu.impl.Row;
import com.ibm.icu.impl.Row.R2;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -19,7 +29,6 @@
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.stream.Collectors;

import org.unicode.cldr.test.CoverageLevel2;
import org.unicode.cldr.test.ExampleGenerator;
import org.unicode.cldr.util.CLDRConfig;
Expand Down Expand Up @@ -63,17 +72,6 @@
import org.unicode.cldr.util.XMLFileReader;
import org.unicode.cldr.util.XPathParts;

import com.google.common.base.Joiner;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
import com.ibm.icu.impl.Relation;
import com.ibm.icu.impl.Row;
import com.ibm.icu.impl.Row.R2;

public class TestPathHeader extends TestFmwkPlus {
private static final DtdType DEBUG_DTD_TYPE = null; // DtdType.supplementalData;
private static final String COMMON_DIR = CLDRPaths.BASE_DIRECTORY + "common/";
Expand Down Expand Up @@ -1685,68 +1683,79 @@ public void TestUnitOrder() {
}

static Comparator<Pair<SectionId, PageId>> comparator =
new Comparator<>() {
@Override
public int compare(Pair<SectionId, PageId> o1, Pair<SectionId, PageId> o2) {
return ComparisonChain.start()
.compare(o1.getFirst(), o2.getFirst())
.compare(o1.getSecond(), o2.getSecond())
.result();
}
};
new Comparator<>() {
@Override
public int compare(Pair<SectionId, PageId> o1, Pair<SectionId, PageId> o2) {
return ComparisonChain.start()
.compare(o1.getFirst(), o2.getFirst())
.compare(o1.getSecond(), o2.getSecond())
.result();
}
};

public void testPageSize() {
final long minError = 600; // above this, emit error
final long minLog = 500; // otherwise above this, emit warning
Factory factory = CLDRConfig.getInstance().getCommonAndSeedAndMainAndAnnotationsFactory();
// "en", "cs", "ar", "pl"
List<String> locales =
StandardCodes.make()
.getLocaleCoverageLocales(Organization.cldr, ImmutableSet.of(Level.MODERN))
.stream()
.filter(x -> CLDRLocale.getInstance(x).getCountry().isEmpty())
.collect(Collectors.toUnmodifiableList());
List<Counter<PageId>> counters = new ArrayList<>();
for (String locale : locales) {
CLDRFile cldrFile = factory.make(locale, false);
PathHeader.Factory phf = PathHeader.getFactory();
Counter<PageId> c = new Counter<>();
counters.add(c);
for (String path : cldrFile) {
PathHeader ph = phf.fromPath(path);
c.add(ph.getPageId(), 1);
}
for (PageId entry : c.getKeysetSortedByKey()) {
long count = c.getCount(entry);
if (count > minError) {
errln(locale + "\t" + entry.getSectionId() + "\t" + entry + "\thas too many entries:\t" + count);
} else if (count > minLog) {
logln(locale + "\t" + entry.getSectionId() + "\t" + "\thas too many entries:\t" + count);
public void testPageSize() {
final long minError = 600; // above this, emit error
final long minLog = 500; // otherwise above this, emit warning
Factory factory = CLDRConfig.getInstance().getCommonAndSeedAndMainAndAnnotationsFactory();
// "en", "cs", "ar", "pl"
List<String> locales =
StandardCodes.make()
.getLocaleCoverageLocales(Organization.cldr, ImmutableSet.of(Level.MODERN))
.stream()
.filter(x -> CLDRLocale.getInstance(x).getCountry().isEmpty())
.collect(Collectors.toUnmodifiableList());
List<Counter<PageId>> counters = new ArrayList<>();
for (String locale : locales) {
CLDRFile cldrFile = factory.make(locale, false);
PathHeader.Factory phf = PathHeader.getFactory();
Counter<PageId> c = new Counter<>();
counters.add(c);
for (String path : cldrFile) {
PathHeader ph = phf.fromPath(path);
c.add(ph.getPageId(), 1);
}
for (PageId entry : c.getKeysetSortedByKey()) {
long count = c.getCount(entry);
if (count > minError) {
errln(

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: af Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: am Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: ar Date & Time Fields has too many entries: 705

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: ar Units Volume has too many entries: 740

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: ar Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: as Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: az Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: be Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: bg Characters Symbols3 has too many entries: 684

Check failure on line 1720 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestPathHeader.java

View workflow job for this annotation

GitHub Actions / build

(TestPathHeader.java:1720) Error: bn Characters Symbols3 has too many entries: 684
locale
+ "\t"
+ entry.getSectionId()
+ "\t"
+ entry
+ "\thas too many entries:\t"
+ count);
} else if (count > minLog) {
logln(
locale
+ "\t"
+ entry.getSectionId()
+ "\t"
+ "\thas too many entries:\t"
+ count);
}
}
}
}
if (isVerbose()) {
System.out.println();
Set<PageId> sorted = new TreeSet<>();
for (Counter<PageId> counter : counters) {
sorted.addAll(counter.keySet());
}
int i = 0;
System.out.print("Order" + "\t" + "Section" + "\t" + "Page");
for (String c : locales) {
System.out.print("\t" + c);
}
System.out.println();
if (isVerbose()) {
System.out.println();
Set<PageId> sorted = new TreeSet<>();
for (Counter<PageId> counter : counters) {
sorted.addAll(counter.keySet());
}
int i = 0;
System.out.print("Order" + "\t" + "Section" + "\t" + "Page");
for (String c : locales) {
System.out.print("\t" + c);
}
System.out.println();

for (PageId entry : sorted) {
System.out.print(++i + "\t" + entry.getSectionId() + "\t" + entry);
for (Counter<PageId> c : counters) {
System.out.print("\t" + c.get(entry));
for (PageId entry : sorted) {
System.out.print(++i + "\t" + entry.getSectionId() + "\t" + entry);
for (Counter<PageId> c : counters) {
System.out.print("\t" + c.get(entry));
}
System.out.println();
}
}
System.out.println();
}
}
}


}

0 comments on commit d8bfd09

Please sign in to comment.