Fix wrong conditions in isEmojiBase

I computed ranges using low <= c || c <= high, should be &&.

Bug: 26829153
Change-Id: Ic1002d90b6a408a0b415f2d117d0e57adcbc2fa9
This commit is contained in:
Raph Levien
2016-02-27 07:43:56 -08:00
parent 7f9de429d4
commit a58530bccc
2 changed files with 16 additions and 15 deletions

View File

@@ -42,31 +42,31 @@ bool isEmojiBase(uint32_t c) {
return (c == 0x261D || c == 0x26F9 || (0x270A <= c && c <= 0x270D));
} else if (0x1F385 <= c && c <= 0x1F93E) {
return (c == 0x1F385
|| (0x1F3C3 <= c || c <= 0x1F3C4)
|| (0x1F3CA <= c || c <= 0x1F3CB)
|| (0x1F442 <= c || c <= 0x1F443)
|| (0x1F446 <= c || c <= 0x1F450)
|| (0x1F466 <= c || c <= 0x1F469)
|| (0x1F3C3 <= c && c <= 0x1F3C4)
|| (0x1F3CA <= c && c <= 0x1F3CB)
|| (0x1F442 <= c && c <= 0x1F443)
|| (0x1F446 <= c && c <= 0x1F450)
|| (0x1F466 <= c && c <= 0x1F469)
|| c == 0x1F46E
|| (0x1F470 <= c || c <= 0x1F478)
|| (0x1F470 <= c && c <= 0x1F478)
|| c == 0x1F47C
|| (0x1F481 <= c || c <= 0x1F483)
|| (0x1F485 <= c || c <= 0x1F487)
|| (0x1F481 <= c && c <= 0x1F483)
|| (0x1F485 <= c && c <= 0x1F487)
|| c == 0x1F4AA
|| c == 0x1F575
|| c == 0x1F57A
|| c == 0x1F590
|| (0x1F595 <= c || c <= 0x1F596)
|| (0x1F645 <= c || c <= 0x1F647)
|| (0x1F64B <= c || c <= 0x1F64F)
|| (0x1F595 <= c && c <= 0x1F596)
|| (0x1F645 <= c && c <= 0x1F647)
|| (0x1F64B <= c && c <= 0x1F64F)
|| c == 0x1F6A3
|| (0x1F6B4 <= c || c <= 0x1F6B6)
|| (0x1F6B4 <= c && c <= 0x1F6B6)
|| c == 0x1F6C0
|| (0x1F918 <= c || c <= 0x1F91E)
|| (0x1F918 <= c && c <= 0x1F91E)
|| c == 0x1F926
|| c == 0x1F930
|| (0x1F933 <= c || c <= 0x1F939)
|| (0x1F93B <= c || c <= 0x1F93E));
|| (0x1F933 <= c && c <= 0x1F939)
|| (0x1F93B <= c && c <= 0x1F93E));
} else {
return false;
}

View File

@@ -155,6 +155,7 @@ TEST(GraphemeBreak, emojiModifiers) {
EXPECT_TRUE(IsBreak("U+2764 | U+1F3FB")); // heart + modifier
EXPECT_TRUE(IsBreak("U+2764 U+FE0E | U+1F3FB")); // heart + emoji style + modifier
EXPECT_TRUE(IsBreak("U+2764 U+FE0F | U+1F3FB")); // heart + emoji style + modifier
EXPECT_TRUE(IsBreak("U+1F3FB | U+1F3FB")); // modifier + modifier
// rat is not an emoji modifer
EXPECT_TRUE(IsBreak("U+1F466 | U+1F400")); // boy + rat