| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from _pytest._io.wcwidth import wcswidth |
| 4 |
from _pytest._io.wcwidth import wcwidth |
| 5 |
import pytest |
| 6 |
|
| 7 |
|
| 8 |
@pytest.mark.parametrize( |
| 9 |
("c", "expected"), |
| 10 |
[ |
| 11 |
("\0", 0), |
| 12 |
("\n", -1), |
| 13 |
("a", 1), |
| 14 |
("1", 1), |
| 15 |
("א", 1), |
| 16 |
("\u200b", 0), |
| 17 |
("\u1abe", 0), |
| 18 |
("\u0591", 0), |
| 19 |
("🉐", 2), |
| 20 |
("$", 2), # noqa: RUF001 |
| 21 |
], |
| 22 |
) |
| 23 |
def test_wcwidth(c: str, expected: int) -> None: |
| 24 |
assert wcwidth(c) == expected |
| 25 |
|
| 26 |
|
| 27 |
@pytest.mark.parametrize( |
| 28 |
("s", "expected"), |
| 29 |
[ |
| 30 |
("", 0), |
| 31 |
("hello, world!", 13), |
| 32 |
("hello, world!\n", -1), |
| 33 |
("0123456789", 10), |
| 34 |
("שלום, עולם!", 11), |
| 35 |
("שְבֻעָיים", 6), |
| 36 |
("🉐🉐🉐", 6), |
| 37 |
], |
| 38 |
) |
| 39 |
def test_wcswidth(s: str, expected: int) -> None: |
| 40 |
assert wcswidth(s) == expected |