diff options
author | Valentin Valls <valentin.valls@esrf.fr> | 2018-04-20 15:58:15 +0200 |
---|---|---|
committer | Valentin Valls <valentin.valls@esrf.fr> | 2018-04-20 15:58:15 +0200 |
commit | a5d0bb1b05fcdb81b756cf403b7574965bb179fa (patch) | |
tree | 32cc3b2ed73cb7a2629e7cbdeffc55a1a10c6cb6 /tests/run | |
parent | 37436f04bb959023384e6e56b3eae6ad878722b1 (diff) | |
download | cython-a5d0bb1b05fcdb81b756cf403b7574965bb179fa.tar.gz |
Update unordered_set to match C++11
- bucket API
- load_factor API
- erase and insert with begin/end iterators
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/cpp_stl_cpp11.pyx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/run/cpp_stl_cpp11.pyx b/tests/run/cpp_stl_cpp11.pyx index 8133fb8fb..2d371094b 100644 --- a/tests/run/cpp_stl_cpp11.pyx +++ b/tests/run/cpp_stl_cpp11.pyx @@ -4,6 +4,7 @@ import sys from libcpp.unordered_map cimport unordered_map +from libcpp.unordered_set cimport unordered_set from libcpp.vector cimport vector from libcpp.queue cimport queue from libcpp.queue cimport priority_queue @@ -85,6 +86,43 @@ def test_map_functionality(): return "pass" +def test_unordered_set_functionality(): + """ + >>> test_unordered_set_functionality() + 'pass' + """ + cdef: + unordered_set[int] int_set = unordered_set[int]() + unordered_set[int] int_set2 + unordered_set[int].iterator iterator = int_set.begin() + int_set.insert(1) + assert int_set.size() == 1 + int_set.erase(int_set.begin(), int_set.end()) + assert int_set.size() == 0 + int_set.insert(1) + assert int_set.erase(1) == 1 # returns number of elements erased + assert int_set.size() == 0 + int_set.insert(1) + iterator = int_set.find(1) + assert int_set.erase(iterator) == int_set.end() + + int_set2.insert(3) + int_set2.insert(5) + int_set.insert(int_set2.begin(), int_set2.end()) + assert int_set.size() == 2 + + int_set.max_load_factor(0.5) + assert int_set.max_load_factor() == 0.5 + int_set.rehash(20) + int_set.reserve(20) + + int_set.bucket_size(0) + int_set.bucket_count() + int_set.max_bucket_count() + int_set.bucket(3) + return "pass" + + def test_unordered_map_functionality(): """ >>> test_unordered_map_functionality() |