[ruby] add tests for unordered containers.
This commit is contained in:
parent
d29a325b99
commit
ec9b380c0c
3 changed files with 65 additions and 13 deletions
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