// Test getCharNameCharacters
if (getInclusion() >= 10) {
boolean map[] = new boolean[256];
UnicodeSet set = new UnicodeSet(1, 0); // empty set
UnicodeSet dumb = new UnicodeSet(1, 0); // empty set
// uprv_getCharNameCharacters() will likely return more lowercase
// letters than actual character names contain because
// it includes all the characters in lowercased names of
// general categories, for the full possible set of extended names.
UCharacterName.getInstance().getCharNameCharacters(set);
// build set the dumb (but sure-fire) way
Arrays.fill(map, false);
int maxLength = 0;
for (int cp = 0; cp < 0x110000; ++ cp) {
String n = UCharacter.getExtendedName(cp);
int len = n.length();
if (len > maxLength) {
maxLength = len;
}
for (int i = 0; i < len; ++ i) {
char ch = n.charAt(i);
if (!map[ch & 0xff]) {
dumb.add(ch);
map[ch & 0xff] = true;
}
}
}
length = UCharacterName.getInstance().getMaxCharNameLength();
if (length != maxLength) {
errln("getMaxCharNameLength()=" + length
+ " differs from the maximum length " + maxLength
+ " of all extended names");
}
// compare the sets. Where is my uset_equals?!!
boolean ok = true;
for (int i = 0; i < 256; ++ i) {
if (set.contains(i) != dumb.contains(i)) {
if (0x61 <= i && i <= 0x7a // a-z
&& set.contains(i) && !dumb.contains(i)) {
// ignore lowercase a-z that are in set but not in dumb
ok = true;
}
else {
ok = false;
break;
}
}
}
String pattern1 = set.toPattern(true);
String pattern2 = dumb.toPattern(true);
if (!ok) {
errln("FAIL: getCharNameCharacters() returned " + pattern1
+ " expected " + pattern2
+ " (too many lowercase a-z are ok)");