diff options
Diffstat (limited to 'test/test_set.rb')
-rw-r--r-- | test/test_set.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/test_set.rb b/test/test_set.rb index e9867dd923..854bcc637b 100644 --- a/test/test_set.rb +++ b/test/test_set.rb @@ -364,6 +364,10 @@ class TC_Set < Test::Unit::TestCase ary.empty? or raise "forgotten elements: #{ary.join(', ')}" } + + assert_equal(6, e.size) + set << 42 + assert_equal(7, e.size) end def test_add @@ -669,6 +673,29 @@ class TC_SortedSet < Test::Unit::TestCase assert_equal(['four', 'one', 'three', 'two'], s.to_a) assert_equal(['four', 'one', 'three', 'two'], a) end + + def test_each + ary = [1,3,5,7,10,20] + set = SortedSet.new(ary) + + ret = set.each { |o| } + assert_same(set, ret) + + e = set.each + assert_instance_of(Enumerator, e) + + assert_nothing_raised { + set.each { |o| + ary.delete(o) or raise "unexpected element: #{o}" + } + + ary.empty? or raise "forgotten elements: #{ary.join(', ')}" + } + + assert_equal(6, e.size) + set << 42 + assert_equal(7, e.size) + end end class TC_Enumerable < Test::Unit::TestCase |