mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
tests: add unit test for StreamReader.readlines()
This commit is contained in:
parent
0c2f8fec3c
commit
56c33fb8b6
@ -157,6 +157,42 @@ def test_streamreader_readline():
|
|||||||
assert reader.readline() == b'\x00\x00'
|
assert reader.readline() == b'\x00\x00'
|
||||||
|
|
||||||
|
|
||||||
|
def test_streamreader_readlines():
|
||||||
|
# Empty stream
|
||||||
|
stream = StringStream(b'')
|
||||||
|
reader = StreamReader(stream, False)
|
||||||
|
assert reader.readlines() == []
|
||||||
|
|
||||||
|
# Single line without newline
|
||||||
|
stream = StringStream(b'A')
|
||||||
|
reader = StreamReader(stream, False)
|
||||||
|
assert reader.readlines() == [b'A']
|
||||||
|
assert reader.readlines() == []
|
||||||
|
|
||||||
|
# Single newline
|
||||||
|
stream = StringStream(b'\n')
|
||||||
|
reader = StreamReader(stream, False)
|
||||||
|
assert reader.readlines() == [b'\n']
|
||||||
|
assert reader.readlines() == []
|
||||||
|
|
||||||
|
# Line with text followed by empty line
|
||||||
|
stream = StringStream(b'A\n\n')
|
||||||
|
reader = StreamReader(stream, False)
|
||||||
|
assert reader.readlines() == [b'A\n', b'\n']
|
||||||
|
assert reader.readlines() == []
|
||||||
|
|
||||||
|
# Multiple lines
|
||||||
|
stream = StringStream(b'A\nB\nC')
|
||||||
|
reader = StreamReader(stream, False)
|
||||||
|
assert reader.readlines() == [b'A\n', b'B\n', b'C']
|
||||||
|
assert reader.readlines() == []
|
||||||
|
|
||||||
|
# Preserve null byte
|
||||||
|
stream = StringStream(b'\x00\x00')
|
||||||
|
reader = StreamReader(stream, False)
|
||||||
|
assert reader.readlines() == [b'\x00\x00']
|
||||||
|
|
||||||
|
|
||||||
def test_streamreader_extract_bytes():
|
def test_streamreader_extract_bytes():
|
||||||
# Empty bytes
|
# Empty bytes
|
||||||
stream = StringStream(b'')
|
stream = StringStream(b'')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user