Add integer range tests

This commit is contained in:
wiredfool 2025-04-21 10:46:45 +01:00
parent ce204f47f4
commit bc4b664b70

View File

@ -153,7 +153,10 @@ def test_lifetime2() -> None:
class DataShape(NamedTuple): class DataShape(NamedTuple):
dtype: Any dtype: Any
elt: Any elt: Any # Strictly speaking, this should be a pixel or pixel component,
# so list[uint8][4], float, int, uint32, uint8, etc.
# But more correctly, it should be exactly the dtype from the
# line above.
elts_per_pixel: int elts_per_pixel: int
@ -175,6 +178,12 @@ UINT32 = DataShape(
elts_per_pixel=1, # one per pixel elts_per_pixel=1, # one per pixel
) )
INT32 = DataShape(
dtype=pyarrow.uint32(),
elt=0x12CDEF45, # one packed int
elts_per_pixel=1, # one per pixel
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"mode, data_tp, mask", "mode, data_tp, mask",
@ -215,6 +224,12 @@ def test_fromarray(mode: str, data_tp: DataShape, mask: list[int] | None) -> Non
("CMYK", UINT32, None), ("CMYK", UINT32, None),
("YCbCr", UINT32, [0, 1, 2]), ("YCbCr", UINT32, [0, 1, 2]),
("HSV", UINT32, [0, 1, 2]), ("HSV", UINT32, [0, 1, 2]),
("LA", INT32, [0, 3]),
("RGB", INT32, [0, 1, 2]),
("RGBA", INT32, None),
("CMYK", INT32, None),
("YCbCr", INT32, [0, 1, 2]),
("HSV", INT32, [0, 1, 2]),
), ),
) )
def test_from_int32array(mode: str, data_tp: DataShape, mask: list[int] | None) -> None: def test_from_int32array(mode: str, data_tp: DataShape, mask: list[int] | None) -> None: