Skip to content

Commit 93a376a

Browse files
authored
[smart_holder] Add missing test case to CMakeLists.txt (#3645)
* Add missing test case to CMakeLists.txt * Fix warnings * Fix Clangtidy
1 parent da058a2 commit 93a376a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ set(PYBIND11_TEST_FILES
136136
test_class_sh_trampoline_unique_ptr
137137
test_class_sh_unique_ptr_member
138138
test_class_sh_virtual_py_cpp_mix
139+
test_class_sh_void_ptr_capsule
139140
test_classh_mock
140141
test_const_name
141142
test_constants_and_functions

tests/test_class_sh_void_ptr_capsule.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace class_sh_void_ptr_capsule {
2020
// Conveniently, the helper also serves to keep track of `capsule_generated`.
2121
struct HelperBase {
2222
HelperBase() = default;
23+
HelperBase(const HelperBase &) = delete;
2324
virtual ~HelperBase() = default;
2425

2526
bool capsule_generated = false;
@@ -45,7 +46,7 @@ struct NoConversion: public HelperBase {
4546
};
4647

4748
struct NoCapsuleReturned: public HelperBase {
48-
int get() const { return 103; }
49+
int get() const override { return 103; }
4950

5051
PyObject* as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned() {
5152
capsule_generated = true;
@@ -72,7 +73,7 @@ int get_from_valid_capsule(const Valid* c) {
7273
return c->get();
7374
}
7475

75-
int get_from_shared_ptr_valid_capsule(std::shared_ptr<Valid> c) {
76+
int get_from_shared_ptr_valid_capsule(const std::shared_ptr<Valid> &c) {
7677
return c->get();
7778
}
7879

@@ -109,7 +110,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
109110
.def(py::init<>())
110111
.def("as_pybind11_tests_class_sh_void_ptr_capsule_Valid",
111112
[](HelperBase* self) {
112-
Valid *obj = dynamic_cast<Valid *>(self);
113+
auto obj = dynamic_cast<Valid *>(self);
113114
assert(obj != nullptr);
114115
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid();
115116
return pybind11::reinterpret_steal<py::capsule>(capsule);
@@ -122,7 +123,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
122123
.def(py::init<>())
123124
.def("as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned",
124125
[](HelperBase* self) {
125-
NoCapsuleReturned *obj = dynamic_cast<NoCapsuleReturned *>(self);
126+
auto obj = dynamic_cast<NoCapsuleReturned *>(self);
126127
assert(obj != nullptr);
127128
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned();
128129
return pybind11::reinterpret_steal<py::capsule>(capsule);
@@ -132,7 +133,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
132133
.def(py::init<>())
133134
.def("as_pybind11_tests_class_sh_void_ptr_capsule_Valid",
134135
[](HelperBase* self) {
135-
AsAnotherObject *obj = dynamic_cast<AsAnotherObject *>(self);
136+
auto obj = dynamic_cast<AsAnotherObject *>(self);
136137
assert(obj != nullptr);
137138
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid();
138139
return pybind11::reinterpret_steal<py::capsule>(capsule);

0 commit comments

Comments
 (0)