Skip to content

Commit 0465f23

Browse files
committed
Add test
1 parent 7d51843 commit 0465f23

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

tests/test_code_generator_stllibcpp.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,11 @@ def test_stl_libcpp():
213213
assert len(map_inp) == 1
214214
assert list(map_inp.values())[0][0] == 6 + 10
215215
assert list(map_inp.values())[0][1] == 2
216+
217+
# Part 9
218+
# Test std::map< Widget, Widget >
219+
i1 = libcpp_stl.IntWrapper(1)
220+
i2 = libcpp_stl.IntWrapper(2)
221+
map_inp = {i1: i2}
222+
assert t.process_15_map(map_inp) == 1
223+
assert list(map_inp.values())[0].i_ == 12

tests/test_files/libcpp_stl_test.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,14 @@ class LibCppSTLTest {
207207
}
208208
return -1;
209209
}
210+
211+
int process_15_map(std::map<IntWrapper, IntWrapper>& in)
212+
{
213+
if (!in.empty())
214+
{
215+
in.begin()->second.i_ += 10;
216+
return in.begin()->first.i_;
217+
}
218+
return -1;
219+
}
210220
};

tests/test_files/libcpp_stl_test.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ cdef extern from "libcpp_stl_test.hpp":
5858
int process_13_map(libcpp_map[IntWrapper, libcpp_vector[int] ]& in_)
5959

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

0 commit comments

Comments
 (0)