From 79be5c83164ae2362d24dbfc1928035477eafe5c Mon Sep 17 00:00:00 2001 From: Paul Ganssle <67915935+pganssle-google@users.noreply.github.com> Date: Thu, 6 Mar 2025 03:19:54 -0500 Subject: [PATCH] test: Explicitly mark char as signed in dtype tests (#5545) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- tests/test_numpy_dtypes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_numpy_dtypes.cpp b/tests/test_numpy_dtypes.cpp index b6db439d9..04bf19f3e 100644 --- a/tests/test_numpy_dtypes.cpp +++ b/tests/test_numpy_dtypes.cpp @@ -512,7 +512,7 @@ TEST_SUBMODULE(numpy_dtypes, m) { py::list res; #define TEST_DTYPE(T) res.append(py::make_tuple(py::dtype::of().num(), py::dtype::num_of())); 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())); 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);