From 1ce42569217d9ef27ecbaaa6dc314aecef1949d3 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 11 Jan 2021 15:58:14 -0800 Subject: [PATCH] Adding mpty::mtxt string member. --- tests/test_classh_wip.cpp | 5 ++++- tests/test_classh_wip.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_classh_wip.cpp b/tests/test_classh_wip.cpp index 381b59b60..f9dc6e57e 100644 --- a/tests/test_classh_wip.cpp +++ b/tests/test_classh_wip.cpp @@ -3,11 +3,12 @@ #include #include +#include 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(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); diff --git a/tests/test_classh_wip.py b/tests/test_classh_wip.py index 0c07eae01..00eafce08 100644 --- a/tests/test_classh_wip.py +++ b/tests/test_classh_wip.py @@ -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():