You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
498 B
20 lines
498 B
from gcode.windows import decode_bytes, truncate_output
|
|
|
|
|
|
def test_decode_utf8() -> None:
|
|
assert decode_bytes("你好".encode("utf-8")) == "你好"
|
|
|
|
|
|
def test_decode_gbk_fallback() -> None:
|
|
assert decode_bytes("你好".encode("gbk")) == "你好"
|
|
|
|
|
|
def test_decode_empty() -> None:
|
|
assert decode_bytes(b"") == ""
|
|
|
|
|
|
def test_truncate() -> None:
|
|
text = "a" * 100
|
|
assert truncate_output(text, limit=50).endswith("字符]")
|
|
assert "a" * 20 == truncate_output("a" * 20, limit=50)
|