Adding mpty::mtxt string member.

parent 994d4dff
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
#include <pybind11/classh.h> #include <pybind11/classh.h>
#include <memory> #include <memory>
#include <string>
namespace pybind11_tests { namespace pybind11_tests {
namespace classh_wip { namespace classh_wip {
struct mpty {}; struct mpty { std::string mtxt; };
mpty rtrn_mpty_valu() { mpty obj; return obj; } mpty rtrn_mpty_valu() { mpty obj; return obj; }
mpty&& rtrn_mpty_rref() { mpty obj; return std::move(obj); } mpty&& rtrn_mpty_rref() { mpty obj; return std::move(obj); }
...@@ -192,6 +193,8 @@ TEST_SUBMODULE(classh_wip, m) { ...@@ -192,6 +193,8 @@ TEST_SUBMODULE(classh_wip, m) {
py::classh<mpty>(m, "mpty") py::classh<mpty>(m, "mpty")
.def(py::init<>()) .def(py::init<>())
.def(py::init([](const std::string& mtxt) {
mpty obj; obj.mtxt = mtxt; return obj; }))
; ;
m.def("rtrn_mpty_valu", rtrn_mpty_valu); m.def("rtrn_mpty_valu", rtrn_mpty_valu);
......
...@@ -4,9 +4,13 @@ import pytest ...@@ -4,9 +4,13 @@ import pytest
from pybind11_tests import classh_wip as m from pybind11_tests import classh_wip as m
def test_mpty(): def test_mpty_constructors():
e = m.mpty() e = m.mpty()
assert e.__class__.__name__ == "mpty" assert e.__class__.__name__ == "mpty"
e = m.mpty("")
assert e.__class__.__name__ == "mpty"
e = m.mpty("txtm")
assert e.__class__.__name__ == "mpty"
def test_cast(): def test_cast():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment