mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 16:37:13 +00:00
SH, test for shared_ptr move
This commit is contained in:
parent
c807807c55
commit
660f83e81d
@ -106,7 +106,7 @@ set(PYBIND11_TEST_FILES
|
||||
test_class_sh_disowning_mi.cpp
|
||||
test_class_sh_factory_constructors.cpp
|
||||
test_class_sh_inheritance.cpp
|
||||
test_class_sh_shared_ptr_copy.cpp
|
||||
test_class_sh_shared_ptr_copy_move.cpp
|
||||
test_class_sh_trampoline_basic.cpp
|
||||
test_class_sh_trampoline_self_life_support.cpp
|
||||
test_class_sh_trampoline_shared_ptr_cpp_arg.cpp
|
||||
|
@ -1,11 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pybind11_tests import class_sh_shared_ptr_copy as m
|
||||
|
||||
|
||||
def test_avl():
|
||||
m.test_avl()
|
||||
|
||||
|
||||
def test_def():
|
||||
m.test_def()
|
@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace pybind11_tests {
|
||||
namespace class_sh_shared_ptr_copy {
|
||||
namespace class_sh_shared_ptr_copy_move {
|
||||
|
||||
template<int SerNo>
|
||||
struct Foo {
|
||||
@ -21,31 +21,42 @@ struct Foo {
|
||||
using FooAVL = Foo<0>;
|
||||
using FooDEF = Foo<1>;
|
||||
|
||||
} // namespace class_sh_shared_ptr_copy
|
||||
} // namespace class_sh_shared_ptr_copy_move
|
||||
} // namespace pybind11_tests
|
||||
|
||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_shared_ptr_copy::FooAVL)
|
||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_shared_ptr_copy_move::FooAVL)
|
||||
|
||||
namespace pybind11_tests {
|
||||
namespace class_sh_shared_ptr_copy {
|
||||
namespace class_sh_shared_ptr_copy_move {
|
||||
|
||||
TEST_SUBMODULE(class_sh_shared_ptr_copy, m) {
|
||||
TEST_SUBMODULE(class_sh_shared_ptr_copy_move, m) {
|
||||
namespace py = pybind11;
|
||||
|
||||
py::class_<FooAVL, PYBIND11_SH_AVL(FooAVL)>(m, "FooAVL");
|
||||
py::class_<FooDEF, PYBIND11_SH_DEF(FooDEF)>(m, "FooDEF");
|
||||
|
||||
m.def("test_avl", []() {
|
||||
m.def("test_avl_copy", []() {
|
||||
auto o = std::make_shared<FooAVL>("AVL");
|
||||
auto l = py::list();
|
||||
l.append(o);
|
||||
});
|
||||
m.def("test_def", []() {
|
||||
m.def("test_def_copy", []() {
|
||||
auto o = std::make_shared<FooDEF>("DEF");
|
||||
auto l = py::list();
|
||||
l.append(o);
|
||||
});
|
||||
|
||||
m.def("test_avl_move", []() {
|
||||
auto o = std::make_shared<FooAVL>("AVL");
|
||||
auto l = py::list();
|
||||
l.append(std::move(o));
|
||||
});
|
||||
m.def("test_def_move", []() {
|
||||
auto o = std::make_shared<FooDEF>("DEF");
|
||||
auto l = py::list();
|
||||
l.append(std::move(o));
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace class_sh_shared_ptr_copy
|
||||
} // namespace class_sh_shared_ptr_copy_move
|
||||
} // namespace pybind11_tests
|
19
tests/test_class_sh_shared_ptr_copy_move.py
Normal file
19
tests/test_class_sh_shared_ptr_copy_move.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pybind11_tests import class_sh_shared_ptr_copy_move as m
|
||||
|
||||
|
||||
def test_avl_copy():
|
||||
m.test_avl_copy()
|
||||
|
||||
|
||||
def test_def_copy():
|
||||
m.test_def_copy()
|
||||
|
||||
|
||||
def test_avl_move():
|
||||
m.test_avl_move()
|
||||
|
||||
|
||||
def test_def_move():
|
||||
m.test_def_move()
|
Loading…
Reference in New Issue
Block a user