28 lines
737 B
Python
28 lines
737 B
Python
"""split_sbs 裁切测试(需求说明 §2.3:sbs 单流形态)。"""
|
||
|
||
import numpy as np
|
||
import pytest
|
||
|
||
from stereo_yolo import split_sbs
|
||
|
||
|
||
def test_split_returns_left_and_right_halves():
|
||
image = np.zeros((4, 10, 3), dtype=np.uint8)
|
||
image[:, :5] = 1
|
||
image[:, 5:] = 2
|
||
|
||
left, right = split_sbs(image)
|
||
|
||
assert left.shape == (4, 5, 3) and right.shape == (4, 5, 3)
|
||
assert (left == 1).all() and (right == 2).all()
|
||
|
||
|
||
def test_odd_width_rejected():
|
||
with pytest.raises(ValueError, match="宽度须为偶数"):
|
||
split_sbs(np.zeros((4, 9, 3), dtype=np.uint8))
|
||
|
||
|
||
def test_non_image_rejected():
|
||
with pytest.raises(ValueError, match="宽度须为偶数"):
|
||
split_sbs(np.zeros((9,), dtype=np.uint8))
|