1 package org.unicode.cldr.unittest; 2 3 import org.unicode.cldr.util.CLDRConfig; 4 import org.unicode.cldr.util.CLDRFile; 5 import org.unicode.cldr.util.XPathParts; 6 7 import com.ibm.icu.dev.test.TestFmwk; 8 import com.ibm.icu.lang.UCharacter; 9 import com.ibm.icu.text.UTF16; 10 import com.ibm.icu.text.UnicodeSet; 11 12 public class NumberingSystemsTest extends TestFmwk { 13 static CLDRConfig testInfo = CLDRConfig.getInstance(); 14 15 public static void main(String[] args) { 16 new NumberingSystemsTest().run(args); 17 } 18 19 public void TestFile() { 20 CLDRFile file = testInfo.getSupplementalFactory().make( 21 "numberingSystems", false); 22 XPathParts parts = new XPathParts(); 23 for (String path : file) { 24 parts.set(path); 25 if (!"numberingSystems".equals(parts.getElement(1))) { 26 continue; 27 } 28 String id = parts.getAttributeValue(2, "id"); 29 String digits = parts.getAttributeValue(2, "digits"); 30 if (digits == null) { 31 continue; 32 } 33 assertEquals("Must have 10 values", 10, 34 UTF16.countCodePoint(digits)); 35 int cp; 36 int value = 0; 37 for (int i = 0; i < digits.length(); i += UTF16.getCharCount(cp)) { 38 cp = UTF16.charAt(digits, i); 39 assertEquals("Value mismatch", value++, 40 UCharacter.getNumericValue(cp)); 41 } 42 try { 43 UnicodeSet script = new UnicodeSet().applyPropertyAlias( 44 "script", id); 45 if (!script.containsAll(digits)) { 46 if (id.equals("latn") 47 && digits.equals("0123456789") 48 || id.equals("arab") 49 && digits 50 .equals("\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669")) { 51 // ok 52 } else { 53 errln("Script doesn't match digits: " + id + ", " 54 + digits); 55 } 56 } 57 } catch (Exception e) { 58 logln(id + " not a script"); 59 } 60 } 61 } 62 } 63