Skip to content

Commit

Permalink
100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jquast committed Nov 7, 2023
1 parent 77a6fce commit 399fa61
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions tests/test_emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def test_another_emoji_zwj_sequence():
def test_longer_emoji_zwj_sequence():
"""
A much longer emoji ZWJ sequence of 10 total codepoints is just 2 cells!
Also test the same sequence in duplicate, verifying multiple VS-16 sequences
in a single function call.
"""
# 'Category Code', 'East Asian Width property' -- 'description'
phrase = (u"\U0001F9D1" # 'So', 'W' -- ADULT
Expand All @@ -127,11 +130,11 @@ def test_longer_emoji_zwj_sequence():
u"\U0001F48B" # 'So', 'W' -- KISS MARK
u"\u200d" # 'Cf', 'N' -- ZERO WIDTH JOINER
u"\U0001F9D1" # 'So', 'W' -- ADULT
u"\U0001F3FD") # 'Sk', 'W' -- EMOJI MODIFIER FITZPATRICK TYPE-4

u"\U0001F3FD" # 'Sk', 'W' -- EMOJI MODIFIER FITZPATRICK TYPE-4
) * 2
# This test adapted from https://www.unicode.org/L2/L2023/23107-terminal-suppt.pdf
expect_length_each = (2, 0, 0, 1, 0, 0, 2, 0, 2, 0)
expect_length_phrase = 2
expect_length_each = (2, 0, 0, 1, 0, 0, 2, 0, 2, 0) * 2
expect_length_phrase = 4

# exercise,
length_each = tuple(map(wcwidth.wcwidth, phrase))
Expand Down Expand Up @@ -205,3 +208,36 @@ def test_recommended_variation_16_sequences():
# verify
assert errors == []
assert num >= 742


def test_unicode_9_vs16():
"""Verify effect of VS-16 on unicode_version 9.0 and later"""
phrase = (u"\u2640" # FEMALE SIGN
u"\uFE0F") # VARIATION SELECTOR-16

expect_length_each = (1, 0)
expect_length_phrase = 2

# exercise,
length_each = tuple(wcwidth.wcwidth(w_char, unicode_version='9.0') for w_char in phrase)
length_phrase = wcwidth.wcswidth(phrase, unicode_version='9.0')

# verify.
assert length_each == expect_length_each
assert length_phrase == expect_length_phrase

def test_unicode_8_vs16():
"""Verify that VS-16 has no effect on unicode_version 8.0 and earler"""
phrase = (u"\u2640" # FEMALE SIGN
u"\uFE0F") # VARIATION SELECTOR-16

expect_length_each = (1, 0)
expect_length_phrase = 1

# exercise,
length_each = tuple(wcwidth.wcwidth(w_char, unicode_version='8.0') for w_char in phrase)
length_phrase = wcwidth.wcswidth(phrase, unicode_version='8.0')

# verify.
assert length_each == expect_length_each
assert length_phrase == expect_length_phrase

0 comments on commit 399fa61

Please sign in to comment.