summaryrefslogtreecommitdiff
path: root/test/-ext-/st/test_numhash.rb
blob: c092049bf9eed46b777178194e784d0dcc6b3b9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'test/unit'
require "-test-/st/numhash"

class Bug::StNumHash
  class Test_NumHash < Test::Unit::TestCase
    def setup
      @tbl = Bug::StNumHash.new
      5.times {|i| @tbl[i] = i}
    end

    def test_check
      keys = []
      @tbl.each do |k, v, t|
        keys << k
        t[5] = 5 if k == 3
        true
      end
      assert_equal([*0..5], keys)
    end

    def test_update
      assert_equal(true, @tbl.update(0) {@tbl[5] = :x})
      assert_equal(:x, @tbl[0])
      assert_equal(:x, @tbl[5])
    end
  end
end