Skip to content

Commit a95c3cb

Browse files
Add tests for GB12 and GB13. Remove redundant parameter in run_grapheme_break_tests().
1 parent 22cacf6 commit a95c3cb

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Lib/test/test_unicodedata.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,14 @@ def graphemes(*args):
822822
'\u200D\U0001F48B\u200D\U0001F9D1\U0001F3FC'),
823823
['\U0001F9D1\U0001F3FE\u200D\u2764\uFE0F'
824824
'\u200D\U0001F48B\u200D\U0001F9D1\U0001F3FC'])
825-
# GB11
826-
self.assertEqual(graphemes('\U0001F1FA\U0001F1E6'),
827-
['\U0001F1FA\U0001F1E6'])
825+
# GB12
826+
self.assertEqual(graphemes(
827+
'\U0001F1FA\U0001F1E6\U0001F1FA\U0001F1F3'),
828+
['\U0001F1FA\U0001F1E6', '\U0001F1FA\U0001F1F3'])
829+
# GB13
830+
self.assertEqual(graphemes(
831+
'a\U0001F1FA\U0001F1E6\U0001F1FA\U0001F1F3'),
832+
['a', '\U0001F1FA\U0001F1E6', '\U0001F1FA\U0001F1F3'])
828833

829834

830835
class Unicode_3_2_0_FunctionsTest(UnicodeFunctionsTest):
@@ -1085,9 +1090,9 @@ def test_grapheme_break(self):
10851090
self.skipTest(f"Failed to download {TESTDATAURL}: {exc}")
10861091

10871092
with testdata:
1088-
self.run_grapheme_break_tests(testdata, unicodedata)
1093+
self.run_grapheme_break_tests(testdata)
10891094

1090-
def run_grapheme_break_tests(self, testdata, ucd):
1095+
def run_grapheme_break_tests(self, testdata):
10911096
for line in testdata:
10921097
line, _, comment = line.partition('#')
10931098
line = line.strip()

Modules/unicodedata.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,9 +1773,9 @@ grapheme_break(int prev_gcb, int curr_gcb, enum ExtPictState ep_state,
17731773
/* GB6 */
17741774
if (prev_gcb == GCB_L &&
17751775
(curr_gcb == GCB_L ||
1776-
curr_gcb == GCB_V ||
1777-
curr_gcb == GCB_LV ||
1778-
curr_gcb == GCB_LVT))
1776+
curr_gcb == GCB_V ||
1777+
curr_gcb == GCB_LV ||
1778+
curr_gcb == GCB_LVT))
17791779
{
17801780
return false;
17811781
}
@@ -1819,6 +1819,7 @@ grapheme_break(int prev_gcb, int curr_gcb, enum ExtPictState ep_state,
18191819
return false;
18201820
}
18211821

1822+
/* GB12 and GB13 */
18221823
if (prev_gcb == GCB_Regional_Indicator && curr_gcb == prev_gcb) {
18231824
return ri_flag;
18241825
}

0 commit comments

Comments
 (0)