diff options
Diffstat (limited to 'ext/pybind11/tests/test_opaque_types.cpp')
-rw-r--r-- | ext/pybind11/tests/test_opaque_types.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ext/pybind11/tests/test_opaque_types.cpp b/ext/pybind11/tests/test_opaque_types.cpp index 54f4dc7a5..5e83df0f6 100644 --- a/ext/pybind11/tests/test_opaque_types.cpp +++ b/ext/pybind11/tests/test_opaque_types.cpp @@ -11,17 +11,13 @@ #include <pybind11/stl.h> #include <vector> -typedef std::vector<std::string> StringList; - -class ClassWithSTLVecProperty { -public: - StringList stringList; -}; +using StringList = std::vector<std::string>; /* IMPORTANT: Disable internal pybind11 translation mechanisms for STL data structures */ PYBIND11_MAKE_OPAQUE(StringList); -test_initializer opaque_types([](py::module &m) { +TEST_SUBMODULE(opaque_types, m) { + // test_string_list py::class_<StringList>(m, "StringList") .def(py::init<>()) .def("pop_back", &StringList::pop_back) @@ -33,6 +29,10 @@ test_initializer opaque_types([](py::module &m) { return py::make_iterator(v.begin(), v.end()); }, py::keep_alive<0, 1>()); + class ClassWithSTLVecProperty { + public: + StringList stringList; + }; py::class_<ClassWithSTLVecProperty>(m, "ClassWithSTLVecProperty") .def(py::init<>()) .def_readwrite("stringList", &ClassWithSTLVecProperty::stringList); @@ -49,6 +49,7 @@ test_initializer opaque_types([](py::module &m) { return ret + "]"; }); + // test_pointers m.def("return_void_ptr", []() { return (void *) 0x1234; }); m.def("get_void_ptr_value", [](void *ptr) { return reinterpret_cast<std::intptr_t>(ptr); }); m.def("return_null_str", []() { return (char *) nullptr; }); @@ -59,4 +60,4 @@ test_initializer opaque_types([](py::module &m) { result->push_back("some value"); return std::unique_ptr<StringList>(result); }); -}); +} |