test: Explicitly mark char as signed in dtype tests (#5545)

When run on a platform where `char` is unsigned by default — which is
implementation-defined.

This explicitly uses `signed char` in two tests where the sign of the
char is important (though only `test_dtype_normalized_num` fails without
this change).
This commit is contained in:
Paul Ganssle 2025-03-06 03:19:54 -05:00 committed by GitHub
parent 2943a27a14
commit 79be5c8316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -512,7 +512,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
py::list res;
#define TEST_DTYPE(T) res.append(py::make_tuple(py::dtype::of<T>().num(), py::dtype::num_of<T>()));
TEST_DTYPE(bool)
TEST_DTYPE(char)
TEST_DTYPE(signed char)
TEST_DTYPE(unsigned char)
TEST_DTYPE(short)
TEST_DTYPE(unsigned short)
@ -545,7 +545,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
res.append(py::make_tuple(py::dtype(py::detail::npy_api::NT).normalized_num(), \
py::dtype::num_of<T>()));
TEST_DTYPE(NPY_BOOL_, bool)
TEST_DTYPE(NPY_BYTE_, char);
TEST_DTYPE(NPY_BYTE_, signed char);
TEST_DTYPE(NPY_UBYTE_, unsigned char);
TEST_DTYPE(NPY_SHORT_, short);
TEST_DTYPE(NPY_USHORT_, unsigned short);