mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-12 09:17:42 +00:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user