Skip to content

[smart_holder] Add missing test case to CMakeLists.txt #3645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ set(PYBIND11_TEST_FILES
test_class_sh_trampoline_unique_ptr
test_class_sh_unique_ptr_member
test_class_sh_virtual_py_cpp_mix
test_class_sh_void_ptr_capsule
test_classh_mock
test_const_name
test_constants_and_functions
Expand Down
11 changes: 6 additions & 5 deletions tests/test_class_sh_void_ptr_capsule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace class_sh_void_ptr_capsule {
// Conveniently, the helper also serves to keep track of `capsule_generated`.
struct HelperBase {
HelperBase() = default;
HelperBase(const HelperBase &) = delete;
virtual ~HelperBase() = default;

bool capsule_generated = false;
Expand All @@ -45,7 +46,7 @@ struct NoConversion: public HelperBase {
};

struct NoCapsuleReturned: public HelperBase {
int get() const { return 103; }
int get() const override { return 103; }

PyObject* as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned() {
capsule_generated = true;
Expand All @@ -72,7 +73,7 @@ int get_from_valid_capsule(const Valid* c) {
return c->get();
}

int get_from_shared_ptr_valid_capsule(std::shared_ptr<Valid> c) {
int get_from_shared_ptr_valid_capsule(const std::shared_ptr<Valid> &c) {
return c->get();
}

Expand Down Expand Up @@ -109,7 +110,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
.def(py::init<>())
.def("as_pybind11_tests_class_sh_void_ptr_capsule_Valid",
[](HelperBase* self) {
Valid *obj = dynamic_cast<Valid *>(self);
auto obj = dynamic_cast<Valid *>(self);
assert(obj != nullptr);
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid();
return pybind11::reinterpret_steal<py::capsule>(capsule);
Expand All @@ -122,7 +123,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
.def(py::init<>())
.def("as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned",
[](HelperBase* self) {
NoCapsuleReturned *obj = dynamic_cast<NoCapsuleReturned *>(self);
auto obj = dynamic_cast<NoCapsuleReturned *>(self);
assert(obj != nullptr);
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned();
return pybind11::reinterpret_steal<py::capsule>(capsule);
Expand All @@ -132,7 +133,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
.def(py::init<>())
.def("as_pybind11_tests_class_sh_void_ptr_capsule_Valid",
[](HelperBase* self) {
AsAnotherObject *obj = dynamic_cast<AsAnotherObject *>(self);
auto obj = dynamic_cast<AsAnotherObject *>(self);
assert(obj != nullptr);
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid();
return pybind11::reinterpret_steal<py::capsule>(capsule);
Expand Down