Merge branch 'tamuratak-fix_std_unordred'
* tamuratak-fix_std_unordred: Move cpp11_hash_tables test to Ruby makefile until other languages work Cosmetic changes in C++11 std_unordered support files [ruby] add tests for unordered containers. [ruby] support for std unordered containers. use equal_range instead of upper_bound. unordered containers do not have the upper_bound method. fix a %fragment argument. use %std_container_methods_without_reverse_iterators fix Lib/std/std unordered containers
This commit is contained in:
commit
de6476f321
13 changed files with 376 additions and 65 deletions
|
|
@ -534,7 +534,7 @@ CPP_TEST_CASES += \
|
|||
wrapmacro
|
||||
|
||||
# C++11 test cases.
|
||||
CPP11_TEST_CASES = \
|
||||
CPP11_TEST_CASES += \
|
||||
cpp11_alignment \
|
||||
cpp11_alternate_function_syntax \
|
||||
cpp11_constexpr \
|
||||
|
|
@ -572,7 +572,6 @@ CPP11_TEST_CASES = \
|
|||
|
||||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN = \
|
||||
# cpp11_hash_tables \ # not fully implemented yet
|
||||
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
|
||||
# cpp11_reference_wrapper \ # No typemaps
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,27 @@
|
|||
|
||||
%inline %{
|
||||
#include <set>
|
||||
//#include <map>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
//#include <unordered_map>
|
||||
#include <unordered_map>
|
||||
%}
|
||||
|
||||
%include "std_set.i"
|
||||
//%include "std_map.i"
|
||||
%include "std_multiset.i"
|
||||
%include "std_map.i"
|
||||
%include "std_multimap.i"
|
||||
%include "std_unordered_set.i"
|
||||
//%include "std_unordered_map.i"
|
||||
%include "std_unordered_multiset.i"
|
||||
%include "std_unordered_map.i"
|
||||
%include "std_unordered_multimap.i"
|
||||
%template (SetInt) std::set<int>;
|
||||
//%template (MapIntInt) std::map<int, int>;
|
||||
%template (MultiSetInt) std::multiset<int>;
|
||||
%template (MapIntInt) std::map<int, int>;
|
||||
%template (MultiMapIntInt) std::multimap<int, int>;
|
||||
%template (UnorderedSetInt) std::unordered_set<int>;
|
||||
//%template (UnorderedMapIntInt) std::unordered_map<int, int>;
|
||||
%template (UnorderedMultiSetInt) std::unordered_multiset<int>;
|
||||
%template (UnorderedMapIntInt) std::unordered_map<int, int>;
|
||||
%template (UnorderedMultiMapIntInt) std::unordered_multimap<int, int>;
|
||||
|
||||
%inline %{
|
||||
using namespace std;
|
||||
|
|
@ -25,19 +33,19 @@ class MyClass {
|
|||
public:
|
||||
set<int> getSet() { return _set; }
|
||||
void addSet(int elt) { _set.insert(_set.begin(), elt); }
|
||||
// map<int, int> getMap() { return _map; }
|
||||
// void addMap(int elt1, int elt2) { _map.insert(make_pair(elt1, elt2)); }
|
||||
map<int, int> getMap() { return _map; }
|
||||
void addMap(int elt1, int elt2) { _map.insert(make_pair(elt1, elt2)); }
|
||||
|
||||
unordered_set<int> getUnorderedSet() { return _unordered_set; }
|
||||
void addUnorderedSet(int elt) { _unordered_set.insert(_unordered_set.begin(), elt); }
|
||||
// unordered_map<int, int> getUnorderedMap() { return _unordered_map; }
|
||||
// void addUnorderedMap(int elt1, int elt2) { _unordered_map.insert(make_pair(elt1, elt2)); }
|
||||
unordered_map<int, int> getUnorderedMap() { return _unordered_map; }
|
||||
void addUnorderedMap(int elt1, int elt2) { _unordered_map.insert(make_pair(elt1, elt2)); }
|
||||
private:
|
||||
set<int> _set;
|
||||
// map<int, int> _map;
|
||||
map<int, int> _map;
|
||||
|
||||
unordered_set<int> _unordered_set;
|
||||
// unordered_map<int, int> _unordered_map;
|
||||
unordered_map<int, int> _unordered_map;
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ CPP_TEST_CASES = \
|
|||
# ruby_li_std_speed
|
||||
# stl_new
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_hash_tables \
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cstring \
|
||||
ruby_manual_proxy \
|
||||
|
|
|
|||
44
Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
Normal file
44
Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
require 'swig_assert'
|
||||
require 'cpp11_hash_tables'
|
||||
|
||||
[Cpp11_hash_tables::MapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::MultiMapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::UnorderedMapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::UnorderedMultiMapIntInt.new({1=>7})].each{|x|
|
||||
swig_assert_equal("x[1]", "7", binding)
|
||||
swig_assert_equal("x[2]", "nil", binding)
|
||||
x[2] = 9
|
||||
swig_assert_equal("x[2]", "9", binding)
|
||||
x.delete(2)
|
||||
swig_assert_equal("x[2]", "nil", binding)
|
||||
swig_assert_equal("x.empty?", "false", binding)
|
||||
x.delete(1)
|
||||
swig_assert_equal("x.empty?", "true", binding)
|
||||
swig_assert_equal("x.include?(1)", "false", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::MultiMapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::UnorderedMultiMapIntInt.new({1=>7})].each{|x|
|
||||
x[1] = 9
|
||||
swig_assert_equal("x[1].sort", "[7,9]", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::SetInt.new([1]),
|
||||
Cpp11_hash_tables::MultiSetInt.new([1]),
|
||||
Cpp11_hash_tables::UnorderedSetInt.new([1]),
|
||||
Cpp11_hash_tables::UnorderedMultiSetInt.new([1])].each{|x|
|
||||
swig_assert_equal("x.include?(1)", "true", binding)
|
||||
swig_assert_equal("x.include?(2)", "false", binding)
|
||||
x << 2
|
||||
swig_assert_equal("x.include?(2)", "true", binding)
|
||||
x.erase(2)
|
||||
swig_assert_equal("x.empty?", "false", binding)
|
||||
x.erase(1)
|
||||
swig_assert_equal("x.empty?", "true", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::MultiSetInt.new([1]),
|
||||
Cpp11_hash_tables::UnorderedMultiSetInt.new([1])].each{|x|
|
||||
x << 1
|
||||
swig_assert_equal("x.count(1)", "2", binding)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue