mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add a gdbm test for [ruby-dev:23381]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c7629cdd28
commit
ec2f913670
1 changed files with 33 additions and 0 deletions
33
test/gdbm/test_gdbm.rb
Normal file
33
test/gdbm/test_gdbm.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'test/unit/testsuite'
|
||||
require 'test/unit/testcase'
|
||||
|
||||
begin
|
||||
require 'gdbm'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
if defined? GDBM
|
||||
require 'tmpdir'
|
||||
require 'fileutils'
|
||||
|
||||
class TestGDBM < Test::Unit::TestCase
|
||||
TMPROOT = "#{Dir.tmpdir}/ruby-gdbm.#{$$}"
|
||||
|
||||
def setup
|
||||
Dir.mkdir TMPROOT
|
||||
end
|
||||
|
||||
def teardown
|
||||
FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
|
||||
end
|
||||
|
||||
def test_open
|
||||
GDBM.open("#{TMPROOT}/a.dbm") {}
|
||||
v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::READER) {|d|
|
||||
assert_raises(GDBMError) { d["k"] = "v" }
|
||||
true
|
||||
}
|
||||
assert(v)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue