2020-04-26 14:48:04 +00:00
|
|
|
from rich import cells
|
|
|
|
|
|
|
|
|
2022-09-07 14:26:05 +00:00
|
|
|
def test_cell_len_long_string():
|
|
|
|
# Long strings don't use cached cell length implementation
|
|
|
|
assert cells.cell_len("abc" * 200) == 3 * 200
|
|
|
|
|
|
|
|
|
2020-04-26 14:48:04 +00:00
|
|
|
def test_set_cell_size():
|
2021-11-13 09:07:42 +00:00
|
|
|
assert cells.set_cell_size("foo", 0) == ""
|
|
|
|
assert cells.set_cell_size("f", 0) == ""
|
|
|
|
assert cells.set_cell_size("", 0) == ""
|
|
|
|
assert cells.set_cell_size("😽😽", 0) == ""
|
2020-04-26 14:48:04 +00:00
|
|
|
assert cells.set_cell_size("foo", 2) == "fo"
|
|
|
|
assert cells.set_cell_size("foo", 3) == "foo"
|
|
|
|
assert cells.set_cell_size("foo", 4) == "foo "
|
|
|
|
assert cells.set_cell_size("😽😽", 4) == "😽😽"
|
|
|
|
assert cells.set_cell_size("😽😽", 3) == "😽 "
|
|
|
|
assert cells.set_cell_size("😽😽", 2) == "😽"
|
|
|
|
assert cells.set_cell_size("😽😽", 1) == " "
|
2021-11-27 19:41:29 +00:00
|
|
|
assert cells.set_cell_size("😽😽", 5) == "😽😽 "
|
2021-11-13 09:04:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_set_cell_size_infinite():
|
|
|
|
for size in range(38):
|
|
|
|
assert (
|
|
|
|
cells.cell_len(
|
|
|
|
cells.set_cell_size(
|
|
|
|
"เป็นเกมที่ต้องมีความอดทนมากที่สุดตั้งเเต่เคยเล่นมา", size
|
|
|
|
)
|
|
|
|
)
|
|
|
|
== size
|
|
|
|
)
|