3 # $Header: dbm.t,v 4.0 91/03/20 01:51:52 lwall Locked $
5 if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h') {
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)) {
21 print (!$i ? "ok 3\n" : "not ok 3\n");
23 $h{'goner1'} = 'snork';
27 $h{'jkl','mno'} = "JKL\034MNO";
28 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
39 $h{'goner2'} = 'snork';
43 print (dbmopen(h,'Op.dbmx',0640) ? "ok 4\n" : "not ok 4\n");
63 $h{'goner3'} = 'snork';
71 if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
73 while (($key,$value) = each(h)) {
74 if ($key eq $keys[$i] && $value eq $values[$i] && $key gt $value) {
76 $i++ if $key eq $value;
80 if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
82 @keys = ('blurfl', keys(h), 'dyick');
83 if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
88 # check cache overflow and numeric keys and contents
90 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
91 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
92 print ($ok ? "ok 8\n" : "not ok 8\n");
94 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
95 $blksize,$blocks) = stat('Op.dbmx.pag');
96 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
98 @h{0..200} = 200..400;
100 print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
102 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
103 print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n");
105 unlink 'Op.dbmx.dir', 'Op.dbmx.pag';