2020-05-26 19:59:16 +08:00
|
|
|
|
from _pytest._io.wcwidth import wcswidth
|
|
|
|
|
from _pytest._io.wcwidth import wcwidth
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
("c", "expected"),
|
|
|
|
|
[
|
|
|
|
|
("\0", 0),
|
|
|
|
|
("\n", -1),
|
|
|
|
|
("a", 1),
|
|
|
|
|
("1", 1),
|
|
|
|
|
("א", 1),
|
2024-03-13 21:30:18 +08:00
|
|
|
|
("\u200b", 0),
|
|
|
|
|
("\u1abe", 0),
|
2020-05-26 19:59:16 +08:00
|
|
|
|
("\u0591", 0),
|
|
|
|
|
("🉐", 2),
|
2024-02-02 22:07:29 +08:00
|
|
|
|
("$", 2), # noqa: RUF001
|
2020-05-26 19:59:16 +08:00
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
def test_wcwidth(c: str, expected: int) -> None:
|
|
|
|
|
assert wcwidth(c) == expected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
("s", "expected"),
|
|
|
|
|
[
|
|
|
|
|
("", 0),
|
|
|
|
|
("hello, world!", 13),
|
|
|
|
|
("hello, world!\n", -1),
|
|
|
|
|
("0123456789", 10),
|
|
|
|
|
("שלום, עולם!", 11),
|
|
|
|
|
("שְבֻעָיים", 6),
|
|
|
|
|
("🉐🉐🉐", 6),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
def test_wcswidth(s: str, expected: int) -> None:
|
|
|
|
|
assert wcswidth(s) == expected
|