private void _testTrieIteration(Int32Trie trie, CheckRange[] checkRanges, int countCheckRanges) { // write a string int countValues = 0; StringBuffer s = new StringBuffer(); int[] values = new int[30]; for (int i = 0; i < countCheckRanges; ++i) { int c = checkRanges[i].Limit; if (c != 0) { --c; UTF16.Append(s, c); values[countValues++] = checkRanges[i].Value; } } { int limit = s.Length; // try forward int p = 0; int i = 0; while (p < limit) { int c = UTF16.CharAt(s, p); p += UTF16.GetCharCount(c); int value = trie.GetCodePointValue(c); if (value != values[i]) { Errln("wrong value from UTRIE_NEXT(U+" + (c).ToHexString() + "): 0x" + (value).ToHexString() + " instead of 0x" + (values[i]).ToHexString()); } // unlike the c version lead is 0 if c is non-supplementary char lead = UTF16.GetLeadSurrogate(c); char trail = UTF16.GetTrailSurrogate(c); if (lead == 0 ? trail != s[p - 1] : !UTF16.IsLeadSurrogate(lead) || !UTF16.IsTrailSurrogate(trail) || lead != s[p - 2] || trail != s[p - 1]) { Errln("wrong (lead, trail) from UTRIE_NEXT(U+" + (c).ToHexString()); continue; } if (lead != 0) { value = trie.GetLeadValue(lead); value = trie.GetTrailValue(value, trail); if (value != trie.GetSurrogateValue(lead, trail) && value != values[i]) { Errln("wrong value from getting supplementary " + "values (U+" + (c).ToHexString() + "): 0x" + (value).ToHexString() + " instead of 0x" + (values[i]).ToHexString()); } } ++i; } } }