Add first tests for H264 bitstream functions.

This commit is contained in:
Frédéric Tronel
2026-08-28 21:43:30 +02:00
parent 8dc2af580d
commit a1a1ae5399
+37
View File
@@ -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