MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_recursive_casting

Function test_recursive_casting

tests/test_stl.py:106–123  ·  view source on GitHub ↗

Tests that stl casters preserve lvalue/rvalue context for container values

()

Source from the content-addressed store, hash-verified

104
105
106def test_recursive_casting():
107 """Tests that stl casters preserve lvalue/rvalue context for container values"""
108 assert m.cast_rv_vector() == ["rvalue", "rvalue"]
109 assert m.cast_lv_vector() == ["lvalue", "lvalue"]
110 assert m.cast_rv_array() == ["rvalue", "rvalue", "rvalue"]
111 assert m.cast_lv_array() == ["lvalue", "lvalue"]
112 assert m.cast_rv_map() == {"a": "rvalue"}
113 assert m.cast_lv_map() == {"a": "lvalue", "b": "lvalue"}
114 assert m.cast_rv_nested() == [[[{"b": "rvalue", "c": "rvalue"}], [{"a": "rvalue"}]]]
115 assert m.cast_lv_nested() == {
116 "a": [[["lvalue", "lvalue"]], [["lvalue", "lvalue"]]],
117 "b": [[["lvalue", "lvalue"], ["lvalue", "lvalue"]]],
118 }
119
120 # Issue #853 test case:
121 z = m.cast_unique_ptr_vector()
122 assert z[0].value == 7
123 assert z[1].value == 42
124
125
126def test_move_out_container():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected