Files
textual/tests/test_line_split.py
Will McGugan 879c985296 Rich log (#3046)
* 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
2023-08-03 10:11:17 +01:00

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", "")]