summaryrefslogtreecommitdiff
path: root/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/ruby/cpp11_hash_tables_runme.rb')
-rw-r--r--Examples/test-suite/ruby/cpp11_hash_tables_runme.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb b/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
new file mode 100644
index 000000000..db910505e
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
@@ -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)
+}