From 210a24e613608592a47ede19a6a3eaab9d8870a9 Mon Sep 17 00:00:00 2001 From: Erik Whiting Date: Sat, 2 Jul 2022 15:57:50 -0500 Subject: [PATCH] Add test --- tests/test_code_generator_stllibcpp.py | 8 ++++++++ tests/test_files/libcpp_stl_test.hpp | 10 ++++++++++ tests/test_files/libcpp_stl_test.pxd | 1 + 3 files changed, 19 insertions(+) diff --git a/tests/test_code_generator_stllibcpp.py b/tests/test_code_generator_stllibcpp.py index fbff67b2..39e66672 100644 --- a/tests/test_code_generator_stllibcpp.py +++ b/tests/test_code_generator_stllibcpp.py @@ -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 diff --git a/tests/test_files/libcpp_stl_test.hpp b/tests/test_files/libcpp_stl_test.hpp index b64f5fe7..17c095d5 100644 --- a/tests/test_files/libcpp_stl_test.hpp +++ b/tests/test_files/libcpp_stl_test.hpp @@ -207,4 +207,14 @@ class LibCppSTLTest { } return -1; } + + int process_15_map(std::map& in) + { + if (!in.empty()) + { + in.begin()->second.i_ += 10; + return 1; + } + return -1; + } }; diff --git a/tests/test_files/libcpp_stl_test.pxd b/tests/test_files/libcpp_stl_test.pxd index 934b0528..5d193df3 100644 --- a/tests/test_files/libcpp_stl_test.pxd +++ b/tests/test_files/libcpp_stl_test.pxd @@ -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_)