Adding mpty::mtxt string member.

parent 1a0dcf46
......@@ -3,11 +3,12 @@
#include <pybind11/classh.h>
#include <memory>
#include <string>
namespace pybind11_tests {
namespace classh_wip {
struct mpty {};
struct mpty { std::string mtxt; };
mpty rtrn_mpty_valu() { mpty obj; return obj; }
mpty&& rtrn_mpty_rref() { mpty obj; return std::move(obj); }
......@@ -192,6 +193,8 @@ TEST_SUBMODULE(classh_wip, m) {
py::classh<mpty>(m, "mpty")
.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);
......
......@@ -4,9 +4,13 @@ import pytest
from pybind11_tests import classh_wip as m
def test_mpty():
def test_mpty_constructors():
e = m.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():
......
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