Commit | Line | Data |
a687059c |
1 | #!./perl |
2 | |
3 | # $Header: op.dbm,v 3.0 89/10/18 15:28:31 lwall Locked $ |
4 | |
5 | if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h') { |
6 | print "1..0\n"; |
7 | exit; |
8 | } |
9 | |
10 | print "1..9\n"; |
11 | |
12 | unlink 'Op.dbmx.dir', 'Op.dbmx.pag'; |
13 | umask(0); |
14 | print (dbmopen(h,'Op.dbmx',0640) ? "ok 1\n" : "not ok 1\n"); |
15 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
16 | $blksize,$blocks) = stat('Op.dbmx.pag'); |
17 | print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n"); |
18 | while (($key,$value) = each(h)) { |
19 | $i++; |
20 | } |
21 | print (!$i ? "ok 3\n" : "not ok 3\n"); |
22 | |
23 | $h{'goner1'} = 'snork'; |
24 | |
25 | $h{'abc'} = 'ABC'; |
26 | $h{'def'} = 'DEF'; |
27 | $h{'jkl','mno'} = "JKL\034MNO"; |
28 | $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5); |
29 | $h{'a'} = 'A'; |
30 | $h{'b'} = 'B'; |
31 | $h{'c'} = 'C'; |
32 | $h{'d'} = 'D'; |
33 | $h{'e'} = 'E'; |
34 | $h{'f'} = 'F'; |
35 | $h{'g'} = 'G'; |
36 | $h{'h'} = 'H'; |
37 | $h{'i'} = 'I'; |
38 | |
39 | $h{'goner2'} = 'snork'; |
40 | delete $h{'goner2'}; |
41 | |
42 | dbmclose(h); |
43 | print (dbmopen(h,'Op.dbmx',0640) ? "ok 4\n" : "not ok 4\n"); |
44 | |
45 | $h{'j'} = 'J'; |
46 | $h{'k'} = 'K'; |
47 | $h{'l'} = 'L'; |
48 | $h{'m'} = 'M'; |
49 | $h{'n'} = 'N'; |
50 | $h{'o'} = 'O'; |
51 | $h{'p'} = 'P'; |
52 | $h{'q'} = 'Q'; |
53 | $h{'r'} = 'R'; |
54 | $h{'s'} = 'S'; |
55 | $h{'t'} = 'T'; |
56 | $h{'u'} = 'U'; |
57 | $h{'v'} = 'V'; |
58 | $h{'w'} = 'W'; |
59 | $h{'x'} = 'X'; |
60 | $h{'y'} = 'Y'; |
61 | $h{'z'} = 'Z'; |
62 | |
63 | $h{'goner3'} = 'snork'; |
64 | |
65 | delete $h{'goner1'}; |
66 | delete $h{'goner3'}; |
67 | |
68 | @keys = keys(%h); |
69 | @values = values(%h); |
70 | |
71 | if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";} |
72 | |
73 | while (($key,$value) = each(h)) { |
74 | if ($key eq $keys[$i] && $value eq $values[$i] && $key gt $value) { |
75 | $key =~ y/a-z/A-Z/; |
76 | $i++ if $key eq $value; |
77 | } |
78 | } |
79 | |
80 | if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";} |
81 | |
82 | @keys = ('blurfl', keys(h), 'dyick'); |
83 | if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";} |
84 | |
85 | # check cache overflow and numeric keys and contents |
86 | $ok = 1; |
87 | for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; } |
88 | for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; } |
89 | print ($ok ? "ok 8\n" : "not ok 8\n"); |
90 | |
91 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
92 | $blksize,$blocks) = stat('Op.dbmx.pag'); |
93 | print ($size > 0 ? "ok 9\n" : "not ok 9\n"); |
94 | |
95 | unlink 'Op.dbmx.dir', 'Op.dbmx.pag'; |