blob: ca0110cd91ad7f3b3108b669033607cd1379d0c1 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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
def test_freeze
GDBM.open("#{TMPROOT}/a.dbm") {|d|
d.freeze
assert_raises(TypeError) { d["k"] = "v" }
}
end
end
end
|