summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-15 09:39:39 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-15 09:39:39 +0000
commite08a4cc70c9ee5c264c6490733482c74517c9836 (patch)
tree9efc4e1812c469374a24ddad6c3ca88af35b30a3 /test
parenta3a7cd1e656fb8f1959a1989383fbbf93c25dd94 (diff)
add a gdbm test for [ruby-dev:23381]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/gdbm/test_gdbm.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb
new file mode 100644
index 0000000000..a4bddfe078
--- /dev/null
+++ b/test/gdbm/test_gdbm.rb
@@ -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