From 631e26ae48a3e4e9b6485993deb3078f5fb3ea6e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Sep 2018 17:02:19 +0100 Subject: [PATCH] Python std::unordered_set tidy up and additional testing --- Examples/test-suite/python/cpp11_hash_tables_runme.py | 2 ++ Lib/python/std_unordered_set.i | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py index 28158c79a..7b772ff9a 100644 --- a/Examples/test-suite/python/cpp11_hash_tables_runme.py +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -34,6 +34,7 @@ for x in [cpp11_hash_tables.MultiMapIntInt({1:7}), cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: x[1] = 9 swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) + swig_assert_equal(len(x), 2) for x in [cpp11_hash_tables.SetInt([1]), cpp11_hash_tables.MultiSetInt([1]), @@ -56,3 +57,4 @@ for x in [cpp11_hash_tables.MultiSetInt([1]), cpp11_hash_tables.UnorderedMultiSetInt([1])]: x.append(1) swig_assert_equal(x.count(1), 2) + swig_assert_equal(len(x), 2) diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i index 06dfc261e..8736cb1b5 100644 --- a/Lib/python/std_unordered_set.i +++ b/Lib/python/std_unordered_set.i @@ -49,7 +49,7 @@ #endif - %extend { + %extend { void append(value_type x) { self->insert(x); } @@ -61,8 +61,7 @@ value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } - - }; + } %enddef %include