This repository has been archived by the owner on Dec 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from bcho/fix/cjk-width
Fix miscalculation of cjk characters.
- Loading branch information
Showing
2 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# coding: utf-8 | ||
"""Tests for character length calculating.""" | ||
|
||
from colorclass import Color | ||
|
||
from terminaltables import _get_width | ||
|
||
|
||
def test_get_width(): | ||
"""Test characters width.""" | ||
testcases = [ | ||
('hello, world', 12), | ||
('世界你好', 8), | ||
('hello 世界', 10), | ||
(Color(u'{autoblue}蓝色{/autoblue}'), 4), | ||
] | ||
|
||
for string, expected_length in testcases: | ||
assert _get_width(string) == expected_length |