From a1a1ae5399348d0ec2badc444e954f550a2fd18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tronel?= Date: Fri, 28 Aug 2026 21:43:30 +0200 Subject: [PATCH] Add first tests for H264 bitstream functions. --- src/tscut/tests/h264/test_bitstream.py | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/tscut/tests/h264/test_bitstream.py diff --git a/src/tscut/tests/h264/test_bitstream.py b/src/tscut/tests/h264/test_bitstream.py new file mode 100644 index 0000000..c9ac24f --- /dev/null +++ b/src/tscut/tests/h264/test_bitstream.py @@ -0,0 +1,37 @@ +from tscut.h264.bitstream import ( + read_bit, + read_byte, + read_word +) + +def test_read_bit_1(): + buf = bytes(10) + for p in range(80): + pos, b = read_bit(buf, p) + assert pos == p+1 and b == 0 + +def test_read_bit_2(): + buf = b'\xFF'*10 + for p in range(80): + pos, b = read_bit(buf, p) + assert pos == p+1 and b == 1 + +def test_read_byte_1(): + buf = bytes(10) + for p in range(10): + pos, b = read_byte(buf, p*8) + assert pos == (p+1)*8 and b == 0 + +def test_read_byte_2(): + buf = bytes(10) + buf = b'\xFF'*10 + for p in range(10): + pos, b = read_byte(buf, p*8) + assert pos == (p+1)*8 and b == 0xFF + +def test_read_word_1(): + buf = bytes(20) + for p in range(10): + pos, b = read_word(buf, p*16) + assert pos == (p+1)*16 and b == 0 +