am 0c2cdcc7: Fix bug of testCodePointTable.

* commit '0c2cdcc7350e8dc0e97f0aa4f343984f3cf39f72':
  Fix bug of testCodePointTable.
This commit is contained in:
Akifumi Yoshimoto 2014-09-30 04:03:32 +00:00 committed by Android Git Automerger
commit c613c3e3b8
2 changed files with 9 additions and 6 deletions

View file

@ -100,8 +100,11 @@ public class Ver2DictEncoder implements DictEncoder {
Collections.sort(codePointOccurrenceArray, new Comparator<Entry<Integer, Integer>>() { Collections.sort(codePointOccurrenceArray, new Comparator<Entry<Integer, Integer>>() {
@Override @Override
public int compare(final Entry<Integer, Integer> a, final Entry<Integer, Integer> b) { public int compare(final Entry<Integer, Integer> a, final Entry<Integer, Integer> b) {
if (a.getValue() != b.getValue()) {
return b.getValue().compareTo(a.getValue()); return b.getValue().compareTo(a.getValue());
} }
return b.getKey().compareTo(a.getKey());
}
}); });
int currentCodePointTableIndex = FormatSpec.MINIMAL_ONE_BYTE_CHARACTER_VALUE; int currentCodePointTableIndex = FormatSpec.MINIMAL_ONE_BYTE_CHARACTER_VALUE;
// Temporary map for writing of nodes // Temporary map for writing of nodes

View file

@ -42,8 +42,8 @@ public class Ver2DictEncoderTests extends AndroidTestCase {
final List<String> words = Arrays.asList(wordSource); final List<String> words = Arrays.asList(wordSource);
final String correctCodePointTable = "eotdsanirfg bclwup"; final String correctCodePointTable = "eotdsanirfg bclwup";
final String correctCodePointOccurrenceArrayString = final String correctCodePointOccurrenceArrayString =
"10141164111411531003110297210521142103111911171108198199132111211021"; "11641114101411531003114211021052972119111711121108110311021991981321";
final String correctCodePointExpectedMapString = "323433363538373940494147454644424348"; final String correctCodePointExpectedMapString = "343332363540383937464549484744414243";
final String dictName = "codePointTableTest"; final String dictName = "codePointTableTest";
final String dictVersion = Long.toString(System.currentTimeMillis()); final String dictVersion = Long.toString(System.currentTimeMillis());
@ -60,8 +60,8 @@ public class Ver2DictEncoderTests extends AndroidTestCase {
codePointOccurrenceArrayString.append(entry.getKey()); codePointOccurrenceArrayString.append(entry.getKey());
codePointOccurrenceArrayString.append(entry.getValue()); codePointOccurrenceArrayString.append(entry.getValue());
} }
assertEquals(codePointOccurrenceArrayString.toString(), assertEquals(correctCodePointOccurrenceArrayString,
correctCodePointOccurrenceArrayString); codePointOccurrenceArrayString.toString());
// Check if mCodePointToOneByteCodeMap is correct // Check if mCodePointToOneByteCodeMap is correct
final StringBuilder codePointExpectedMapString = new StringBuilder(); final StringBuilder codePointExpectedMapString = new StringBuilder();
@ -69,7 +69,7 @@ public class Ver2DictEncoderTests extends AndroidTestCase {
codePointExpectedMapString.append(codePointTable.mCodePointToOneByteCodeMap.get( codePointExpectedMapString.append(codePointTable.mCodePointToOneByteCodeMap.get(
correctCodePointTable.codePointAt(i))); correctCodePointTable.codePointAt(i)));
} }
assertEquals(codePointExpectedMapString.toString(), correctCodePointExpectedMapString); assertEquals(correctCodePointExpectedMapString, codePointExpectedMapString.toString());
} }
/** /**