mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-02 01:47:12 +00:00
Adding mpty::mtxt string member.
This commit is contained in:
parent
c8d19f9599
commit
1ce4256921
@ -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) {
|
|||||||
|
|
||||||
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
|
|||||||
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():
|
||||||
|
Loading…
Reference in New Issue
Block a user