summaryrefslogtreecommitdiff
path: root/test/gdbm
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-16 12:03:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-16 12:03:23 +0000
commit4769fb9d126617e20aad104856f7078bb7741c6d (patch)
tree843f2cfc70dd91f1bc8b43251984850e3b1ad42f /test/gdbm
parentc303f0407e0aa1a926428b5f12a75af1c0c3b92a (diff)
* ext/dbm/dbm.c (fdbm_initialize): accept optional 3rd argument to
specify an open flag. (Init_dbm): define open flags: DBM::READER, DBM::WRITER, DBM::WRCREAT and DBM::NEWDB. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/gdbm')
-rw-r--r--test/gdbm/test_gdbm.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb
index ca0110cd91..c90f4a6074 100644
--- a/test/gdbm/test_gdbm.rb
+++ b/test/gdbm/test_gdbm.rb
@@ -21,7 +21,7 @@ if defined? GDBM
FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
end
- def test_open
+ def test_reader_open
GDBM.open("#{TMPROOT}/a.dbm") {}
v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::READER) {|d|
assert_raises(GDBMError) { d["k"] = "v" }
@@ -30,6 +30,18 @@ if defined? GDBM
assert(v)
end
+ def test_newdb_open
+ GDBM.open("#{TMPROOT}/a.dbm") {|dbm|
+ dbm["k"] = "v"
+ }
+ v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::NEWDB) {|d|
+ assert_equal(0, d.length)
+ assert_nil(d["k"])
+ true
+ }
+ assert(v)
+ end
+
def test_freeze
GDBM.open("#{TMPROOT}/a.dbm") {|d|
d.freeze