Add first tests for H264 bitstream functions.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user