Add a unit test for scanning/wrapping output reference to container parameter (e.g.std::vector<std::string> &outVec)
This commit is contained in:
1 parent
10b347bd76
commit
20b51a7f92
4 files changed
+20
-1
No files matched your search
@@ -354,6 +354,14 @@ TestContainer::set_simple_vec (std::vector<simple_struct_t> list)
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
TestContainer::get_vec (std::vector<std::string> &outVec)
|
||||
{
|
||||
outVec.clear ();
|
||||
outVec.push_back ("hello");
|
||||
outVec.push_back ("world");
|
||||
}
|
||||
|
||||
std::map<std::string, int>
|
||||
get_map ()
|
||||
{
|
||||
|
||||
@@ -764,6 +764,9 @@ public:
|
||||
virtual SimpleStructVec get_simple_vec ();
|
||||
virtual int set_simple_vec (SimpleStructVec vec);
|
||||
|
||||
// -#- @outVec(direction=out) -#-
|
||||
void get_vec (std::vector<std::string> &outVec);
|
||||
|
||||
private:
|
||||
SimpleStructList m_simpleList;
|
||||
};
|
||||
|
||||
@@ -407,10 +407,14 @@ int %s::custom_method_added_by_a_hook(int x)
|
||||
direction=Parameter.DIRECTION_INOUT)],
|
||||
is_virtual=True)
|
||||
|
||||
SimpleStructList = mod.add_container('std::vector<simple_struct_t>', ReturnValue.new('simple_struct_t'), 'vector')
|
||||
mod.add_container('std::vector<simple_struct_t>', ReturnValue.new('simple_struct_t'), 'vector')
|
||||
TestContainer.add_method('get_simple_vec', ReturnValue.new('std::vector<simple_struct_t>'), [], is_virtual=True)
|
||||
TestContainer.add_method('set_simple_vec', 'int', [Parameter.new('std::vector<simple_struct_t>', 'vec')], is_virtual=True)
|
||||
|
||||
mod.add_container('std::vector<std::string>', 'std::string', 'vector')
|
||||
TestContainer.add_method('get_vec', 'void', [Parameter.new('std::vector<std::string> &', 'outVec',
|
||||
direction=Parameter.DIRECTION_OUT)])
|
||||
|
||||
|
||||
#### --- error handler ---
|
||||
class MyErrorHandler(pybindgen.settings.ErrorHandler):
|
||||
|
||||
@@ -990,6 +990,10 @@ class TestFoo(unittest.TestCase):
|
||||
v = list(t.m_floatSet)
|
||||
self.assertEqual(v, [1,2,3])
|
||||
|
||||
def test_out_vec(self):
|
||||
t = foo.TestContainer()
|
||||
v = list(t.get_vec())
|
||||
self.assertEqual(v, ["hello", "world"])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user