Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-whiting committed Jul 2, 2022
1 parent 7d51843 commit 210a24e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_code_generator_stllibcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,11 @@ def test_stl_libcpp():
assert len(map_inp) == 1
assert list(map_inp.values())[0][0] == 6 + 10
assert list(map_inp.values())[0][1] == 2

# Part 9
# Test std::map< Widget, Widget >
i1 = libcpp_stl.IntWrapper(1)
i2 = libcpp_stl.IntWrapper(2)
map_inp = {i1: i2}
assert t.process_15_map(map_inp) == 1
assert list(map_inp.values())[0].i_ == 12
10 changes: 10 additions & 0 deletions tests/test_files/libcpp_stl_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,14 @@ class LibCppSTLTest {
}
return -1;
}

int process_15_map(std::map<IntWrapper, IntWrapper>& in)
{
if (!in.empty())
{
in.begin()->second.i_ += 10;
return 1;
}
return -1;
}
};
1 change: 1 addition & 0 deletions tests/test_files/libcpp_stl_test.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ cdef extern from "libcpp_stl_test.hpp":
int process_13_map(libcpp_map[IntWrapper, libcpp_vector[int] ]& in_)

int process_14_map(libcpp_map[IntWrapper, IntVecWrapper]& in_)
int process_15_map(libcpp_map[IntWrapper, IntWrapper]& in_)

0 comments on commit 210a24e

Please sign in to comment.