Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Added test_string_width
Browse files Browse the repository at this point in the history
  • Loading branch information
rockygo2 committed Jun 13, 2024
1 parent de2f99c commit 1a5311c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,15 @@ def test__human_join() -> None:
assert utils._human_join(["cat", "dog"]) == "cat or dog"
assert utils._human_join(["cat", "dog", "fish"]) == "cat, dog or fish"
assert utils._human_join(["cat", "dog", "fish", "bird"], delimiter="; ", final="and") == "cat; dog; fish and bird"

def test_string_width():
test_cases = [("", 0),("a", 1),("hello", 5),("hello\tworld", 11),("a" * 1000, 1000)]

for string, expected_width in test_cases:
assert utils._string_width(string) == expected_width

test_cases = [("你" * 500, 1000),("hello 你好 world", 16),("你好", 4),("你", 2)]

for string, expected_width in test_cases:
assert utils._string_width(string) == expected_width

0 comments on commit 1a5311c

Please sign in to comment.