Merge "Fix Binary dict tests"

main
Jean Chalard 2013-04-15 03:53:54 +00:00 committed by Android (Google) Code Review
commit 03d1dff38d
2 changed files with 8 additions and 5 deletions

View File

@ -1467,8 +1467,8 @@ public final class BinaryDictInputOutput {
if (null == last) continue; if (null == last) continue;
builder.append(new String(last.mCharacters, 0, last.mCharacters.length)); builder.append(new String(last.mCharacters, 0, last.mCharacters.length));
buffer.position(last.mChildrenAddress + headerSize); buffer.position(last.mChildrenAddress + headerSize);
groupOffset = last.mChildrenAddress + 1; i = readCharGroupCount(buffer);
i = buffer.readUnsignedByte(); groupOffset = last.mChildrenAddress + getGroupCountSize(i);
last = null; last = null;
continue; continue;
} }
@ -1477,8 +1477,8 @@ public final class BinaryDictInputOutput {
if (0 == i && hasChildrenAddress(last.mChildrenAddress)) { if (0 == i && hasChildrenAddress(last.mChildrenAddress)) {
builder.append(new String(last.mCharacters, 0, last.mCharacters.length)); builder.append(new String(last.mCharacters, 0, last.mCharacters.length));
buffer.position(last.mChildrenAddress + headerSize); buffer.position(last.mChildrenAddress + headerSize);
groupOffset = last.mChildrenAddress + 1; i = readCharGroupCount(buffer);
i = buffer.readUnsignedByte(); groupOffset = last.mChildrenAddress + getGroupCountSize(i);
last = null; last = null;
continue; continue;
} }

View File

@ -137,7 +137,10 @@ public class BinaryDictIOTests extends AndroidTestCase {
if (r < 0) continue; if (r < 0) continue;
// Don't insert 0~20, but insert any other code point. // Don't insert 0~20, but insert any other code point.
// Code points are in the range 0~0x10FFFF. // Code points are in the range 0~0x10FFFF.
builder.appendCodePoint((int)(20 + r % (0x10FFFF - 20))); final int candidateCodePoint = (int)(20 + r % (0x10FFFF - 20));
// Code points between 0xD800 and 0xDFFF are not valid.
if (candidateCodePoint >= 0xD800 && candidateCodePoint <= 0xDFFF) continue;
builder.appendCodePoint(candidadeCodePoint);
--count; --count;
} }
return builder.toString(); return builder.toString();