Stop py::array_t arguments from accepting arrays that do not match the C- or F-contiguity flags (#2484)
* Stop py::array_t arguments from accepting arrays that do not match the C- or F-contiguity flags
* Add trivially-contiguous arrays to the tests
diff --git a/tests/test_numpy_array.cpp b/tests/test_numpy_array.cpp
index e37beb5..caa0525 100644
--- a/tests/test_numpy_array.cpp
+++ b/tests/test_numpy_array.cpp
@@ -385,4 +385,42 @@
sm.def("index_using_ellipsis", [](py::array a) {
return a[py::make_tuple(0, py::ellipsis(), 0)];
});
+
+ // test_argument_conversions
+ sm.def("accept_double",
+ [](py::array_t<double, 0>) {},
+ py::arg("a"));
+ sm.def("accept_double_forcecast",
+ [](py::array_t<double, py::array::forcecast>) {},
+ py::arg("a"));
+ sm.def("accept_double_c_style",
+ [](py::array_t<double, py::array::c_style>) {},
+ py::arg("a"));
+ sm.def("accept_double_c_style_forcecast",
+ [](py::array_t<double, py::array::forcecast | py::array::c_style>) {},
+ py::arg("a"));
+ sm.def("accept_double_f_style",
+ [](py::array_t<double, py::array::f_style>) {},
+ py::arg("a"));
+ sm.def("accept_double_f_style_forcecast",
+ [](py::array_t<double, py::array::forcecast | py::array::f_style>) {},
+ py::arg("a"));
+ sm.def("accept_double_noconvert",
+ [](py::array_t<double, 0>) {},
+ py::arg("a").noconvert());
+ sm.def("accept_double_forcecast_noconvert",
+ [](py::array_t<double, py::array::forcecast>) {},
+ py::arg("a").noconvert());
+ sm.def("accept_double_c_style_noconvert",
+ [](py::array_t<double, py::array::c_style>) {},
+ py::arg("a").noconvert());
+ sm.def("accept_double_c_style_forcecast_noconvert",
+ [](py::array_t<double, py::array::forcecast | py::array::c_style>) {},
+ py::arg("a").noconvert());
+ sm.def("accept_double_f_style_noconvert",
+ [](py::array_t<double, py::array::f_style>) {},
+ py::arg("a").noconvert());
+ sm.def("accept_double_f_style_forcecast_noconvert",
+ [](py::array_t<double, py::array::forcecast | py::array::f_style>) {},
+ py::arg("a").noconvert());
}