3
# This is a test of STL containers using proc
4
# objects to change the sorting function used in them. Same as a
5
# std::binary_predicate in C++.
13
require 'li_std_functors'
17
swig_assert_each_line(<<EOF, binding)
18
cont = #{container}.new
19
[9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
21
cont.to_a == [1,2,3,4,5,6,7,8,9]
22
cont = #{container}.new( proc { |a,b| b < a } )
23
[9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
24
cont.to_a == [9, 8, 7, 6, 5, 4, 3, 2, 1]
25
cont = #{container}.new( proc { |a,b| b > a } )
26
[9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
27
cont.to_a == [1, 2, 3, 4, 5, 6, 7, 8, 9]
28
cont = #{container}.new(proc { |a,b| b < a } )
32
cont.erase(i0) # don't use i0 anymore, it is invalid now
38
swig_assert_each_line(<<EOF, binding)
39
cont = #{container}.new
44
cont.to_a == [['w',2],['x',8],['y',1],['z',9]]
46
cont = #{container}.new(proc { |a,b| b < a } )
51
cont.to_a == [['z',9],['y',1],['x',8],['w',2]]
56
yield method(:_set), Li_std_functors::Set
57
yield method(:_map), Li_std_functors::Map
60
# these should fail and not segfault
62
Li_std_functors::Set.new('sd')
66
test do |proc, container|