public void TestScriptMetadata() { UnicodeSet rtl = new UnicodeSet("[[:bc=R:][:bc=AL:]-[:Cn:]-[:sc=Common:]]"); // So far, sample characters are uppercase. // Georgian is special. UnicodeSet cased = new UnicodeSet("[[:Lu:]-[:sc=Common:]-[:sc=Geor:]]"); for (int sc = 0; sc < UScript.CodeLimit; ++sc) { String sn = UScript.GetShortName(sc); ScriptUsage usage = UScript.GetUsage(sc); String sample = UScript.GetSampleString(sc); UnicodeSet scriptSet = new UnicodeSet(); scriptSet.ApplyInt32PropertyValue(UProperty.Script, sc); if (usage == ScriptUsage.NotEncoded) { assertTrue(sn + " not encoded, no sample", sample.Length == 0); // Java 6: sample.isEmpty() assertFalse(sn + " not encoded, not RTL", UScript.IsRightToLeft(sc)); assertFalse(sn + " not encoded, not LB letters", UScript.BreaksBetweenLetters(sc)); assertFalse(sn + " not encoded, not cased", UScript.IsCased(sc)); assertTrue(sn + " not encoded, no characters", scriptSet.IsEmpty); } else { assertFalse(sn + " encoded, has a sample character", sample.Length == 0); // Java 6: sample.isEmpty() int firstChar = sample.CodePointAt(0); int charScript = GetCharScript(sc); assertEquals(sn + " script(sample(script))", charScript, UScript.GetScript(firstChar)); assertEquals(sn + " RTL vs. set", rtl.Contains(firstChar), UScript.IsRightToLeft(sc)); assertEquals(sn + " cased vs. set", cased.Contains(firstChar), UScript.IsCased(sc)); assertEquals(sn + " encoded, has characters", sc == charScript, !scriptSet.IsEmpty); if (UScript.IsRightToLeft(sc)) { rtl.RemoveAll(scriptSet); } if (UScript.IsCased(sc)) { cased.RemoveAll(scriptSet); } } } assertEquals("no remaining RTL characters", "[]", rtl.ToPattern(true)); assertEquals("no remaining cased characters", "[]", cased.ToPattern(true)); assertTrue("Hani breaks between letters", UScript.BreaksBetweenLetters(UScript.Han)); assertTrue("Thai breaks between letters", UScript.BreaksBetweenLetters(UScript.Thai)); assertFalse("Latn does not break between letters", UScript.BreaksBetweenLetters(UScript.Latin)); }