mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
* log * tests * snapshot tests * change to richlog * keep raw lines * disable highlighting by default * simplify * superfluous test * optimization * update cell length * add refresh * write method * version bump * doc fix link * makes lines private * docstring * relax dev dependancy * remove superfluous code [skip ci] * added FAQ [skipci] * fix code in faq [skipci] * fix typo * max lines fix
27 lines
849 B
Python
27 lines
849 B
Python
from textual._line_split import line_split
|
|
|
|
|
|
def test_split_string_to_lines_and_endings():
|
|
# Test with different line endings
|
|
assert line_split("Hello\r\nWorld\n") == [("Hello", "\r\n"), ("World", "\n")]
|
|
assert line_split("Hello\rWorld\r\n") == [("Hello", "\r"), ("World", "\r\n")]
|
|
assert line_split("Hello\nWorld\r") == [("Hello", "\n"), ("World", "\r")]
|
|
|
|
# Test with no line endings
|
|
assert line_split("Hello World") == [("Hello World", "")]
|
|
|
|
# Test with empty string
|
|
assert line_split("") == []
|
|
|
|
# Test with multiple lines having same line endings
|
|
assert line_split("Hello\nWorld\nHow\nAre\nYou\n") == [
|
|
("Hello", "\n"),
|
|
("World", "\n"),
|
|
("How", "\n"),
|
|
("Are", "\n"),
|
|
("You", "\n"),
|
|
]
|
|
|
|
# Test with a single character
|
|
assert line_split("a") == [("a", "")]
|