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

* Add missing test case to CMakeLists.txt

* Fix warnings

* Fix Clangtidy
This commit is contained in:
Xiaofei Wang 2022-01-25 16:43:11 -08:00 committed by GitHub
parent da058a2904
commit 93a376a40a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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;
@ -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;
@ -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();
}
@ -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);
@ -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);
@ -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);