}
++ start;
}
}
IntTrie trie = newTrie.serialize(new _testFoldedValue(newTrie),
new _testFoldingOffset());
// test linear Latin-1 range from utrie_getData()
if (latin1Linear) {
start = 0;
for (int i = 0; i < countCheckRanges && start <= 0xff; ++ i) {
int limit = checkRanges[i].limit;
int value = checkRanges[i].value;
while (start < limit && start <= 0xff) {
if (value != trie.getLatin1LinearValue((char)start)) {
errln("IntTrie.getLatin1LinearValue[U+"
+ Integer.toHexString(start) + "]==0x"
+ Integer.toHexString(
trie.getLatin1LinearValue((char) start))
+ " instead of 0x" + Integer.toHexString(value));
}
++ start;
}
}
}
if (latin1Linear != trie.isLatin1Linear()) {
errln("trie serialization did not preserve "
+ "Latin-1-linearity");
}
// verify that all these values are in the serialized Trie
start = 0;
for (int i = 0; i < countCheckRanges; ++ i) {
int limit = checkRanges[i].limit;
int value = checkRanges[i].value;
if (start == 0xd800) {
// skip surrogates
start = limit;
continue;
}
while (start < limit) {
if (start <= 0xffff) {
int value2 = trie.getBMPValue((char)start);
if (value != value2) {
errln("serialized trie.getBMPValue(U+"
+ Integer.toHexString(start) + " == 0x"
+ Integer.toHexString(value2) + " instead of 0x"
+ Integer.toHexString(value));
}
if (!UTF16.isLeadSurrogate((char)start)) {
value2 = trie.getLeadValue((char)start);
if (value != value2) {
errln("serialized trie.getLeadValue(U+"
+ Integer.toHexString(start) + " == 0x"
+ Integer.toHexString(value2) + " instead of 0x"
+ Integer.toHexString(value));
}
}
}
int value2 = trie.getCodePointValue(start);
if (value != value2) {
errln("serialized trie.getCodePointValue(U+"
+ Integer.toHexString(start) + ")==0x"
+ Integer.toHexString(value2) + " instead of 0x"
+ Integer.toHexString(value));
}
++ start;
}
}
// enumerate and verify all ranges
int enumRanges = 1;
TrieIterator iter = new _testEnumValue(trie);
RangeValueIterator.Element result = new RangeValueIterator.Element();
while (iter.next(result)) {
if (result.start != checkRanges[enumRanges -1].limit
|| result.limit != checkRanges[enumRanges].limit
|| (result.value ^ 0x5555) != checkRanges[enumRanges].value) {
errln("utrie_enum() delivers wrong range [U+"
+ Integer.toHexString(result.start) + "..U+"
+ Integer.toHexString(result.limit) + "].0x"
+ Integer.toHexString(result.value ^ 0x5555)
+ " instead of [U+"
+ Integer.toHexString(checkRanges[enumRanges -1].limit)
+ "..U+"
+ Integer.toHexString(checkRanges[enumRanges].limit)
+ "].0x"
+ Integer.toHexString(checkRanges[enumRanges].value));
}
enumRanges ++;
}
// test linear Latin-1 range
if (trie.isLatin1Linear()) {
for (start = 0; start < 0x100; ++ start) {
if (trie.getLatin1LinearValue((char)start)
!= trie.getLeadValue((char)start)) {
errln("trie.getLatin1LinearValue[U+"
+ Integer.toHexString(start) + "]=0x"
+ Integer.toHexString(
trie.getLatin1LinearValue((char)start))
+ " instead of 0x"
+ Integer.toHexString(
trie.getLeadValue((char)start)));
}
}
}
_testTrieIteration(trie, checkRanges, countCheckRanges);