Skip to content

Commit

Permalink
Import non-functional test changes made on smart_holder branch under PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Jul 22, 2024
1 parent 18b72c0 commit c4c3d9a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
8 changes: 6 additions & 2 deletions tests/test_class_sh_trampoline_self_life_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <string>
#include <utility>

namespace {
namespace pybind11_tests {
namespace class_sh_trampoline_self_life_support {

struct Big5 { // Also known as "rule of five".
std::string history;
Expand Down Expand Up @@ -43,7 +44,10 @@ struct Big5Trampoline : Big5, py::trampoline_self_life_support {
};
#endif

} // namespace
} // namespace class_sh_trampoline_self_life_support
} // namespace pybind11_tests

using namespace pybind11_tests::class_sh_trampoline_self_life_support;

PYBIND11_SMART_HOLDER_TYPE_CASTERS(Big5)

Expand Down
18 changes: 12 additions & 6 deletions tests/test_class_sh_trampoline_unique_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cstdint>

namespace pybind11_tests {
namespace class_sh_trampoline_basic {
namespace class_sh_trampoline_unique_ptr {

class Class {
public:
Expand All @@ -31,6 +31,14 @@ class Class {
std::uint64_t val_ = 0;
};

} // namespace class_sh_trampoline_unique_ptr
} // namespace pybind11_tests

PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_trampoline_unique_ptr::Class)

namespace pybind11_tests {
namespace class_sh_trampoline_unique_ptr {

#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
class PyClass : public Class, public py::trampoline_self_life_support {
public:
Expand All @@ -42,20 +50,18 @@ class PyClass : public Class, public py::trampoline_self_life_support {
};
#endif

} // namespace class_sh_trampoline_basic
} // namespace class_sh_trampoline_unique_ptr
} // namespace pybind11_tests

using namespace pybind11_tests::class_sh_trampoline_basic;

PYBIND11_SMART_HOLDER_TYPE_CASTERS(Class)

TEST_SUBMODULE(class_sh_trampoline_unique_ptr, m) {
m.attr("defined_PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT") =
#ifndef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
false;
#else
true;

using namespace pybind11_tests::class_sh_trampoline_unique_ptr;

py::classh<Class, PyClass>(m, "Class")
.def(py::init<>())
.def("set_val", &Class::setVal)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_class_sh_virtual_py_cpp_mix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ struct CppDerivedVirtualOverrider : CppDerived, py::trampoline_self_life_support
} // namespace class_sh_virtual_py_cpp_mix
} // namespace pybind11_tests

PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::Base)
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::CppDerivedPlain)
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::CppDerived)
using namespace pybind11_tests::class_sh_virtual_py_cpp_mix;

PYBIND11_SMART_HOLDER_TYPE_CASTERS(Base)
PYBIND11_SMART_HOLDER_TYPE_CASTERS(CppDerivedPlain)
PYBIND11_SMART_HOLDER_TYPE_CASTERS(CppDerived)

TEST_SUBMODULE(class_sh_virtual_py_cpp_mix, m) {
m.attr("defined_PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT") =
Expand All @@ -61,8 +63,6 @@ TEST_SUBMODULE(class_sh_virtual_py_cpp_mix, m) {
#else
true;

using namespace pybind11_tests::class_sh_virtual_py_cpp_mix;

py::classh<Base, BaseVirtualOverrider>(m, "Base").def(py::init<>()).def("get", &Base::get);

py::classh<CppDerivedPlain, Base>(m, "CppDerivedPlain").def(py::init<>());
Expand Down

0 comments on commit c4c3d9a

Please sign in to comment.