1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/sdbm/test_sdbm.rb: add some tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-08-01 12:50:17 +00:00
parent 57b9e18d71
commit 8a43d16272
2 changed files with 38 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Fri Aug 1 21:49:41 2008 Yusuke Endoh <mame@tsg.ne.jp>
* test/sdbm/test_sdbm.rb: add some tests.
Fri Aug 1 21:36:00 2008 Yusuke Endoh <mame@tsg.ne.jp>
* gc.c (allocate_heaps, assign_heap_slot, rb_newobj_from_heap):

View file

@ -525,5 +525,39 @@ class TestSDBM < Test::Unit::TestCase
assert_equal(key.to_i, val.to_i)
}
end
def test_closed
assert_equal(false, @sdbm.closed?)
@sdbm.close
assert_equal(true, @sdbm.closed?)
@sdbm = SDBM.new(@path)
end
def test_index
assert_equal(nil, @sdbm.index("foo"))
@sdbm["bar"] = "foo"
assert_equal("bar", @sdbm.index("foo"))
end
def test_readonly
@sdbm["bar"] = "baz"
@sdbm.close
File.chmod(0444, @path + ".dir")
File.chmod(0444, @path + ".pag")
@sdbm = SDBM.new(@path)
assert_raise(SDBMError) { @sdbm["bar"] = "foo" }
assert_raise(SDBMError) { @sdbm.delete("bar") }
assert_raise(SDBMError) { @sdbm.delete_if { true } }
assert_raise(SDBMError) { @sdbm.clear }
assert_nil(@sdbm.store("bar", nil))
end
def test_update2
obj = Object.new
def obj.each_pair
yield []
end
assert_raise(ArgumentError) { @sdbm.update(obj) }
end
end