3 # $RCSfile: dbm.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:43 $
5 if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h'
6 && !-r '/usr/include/rpcsvc/dbm.h') {
16 unlink Op.dbmx; # in case we're running gdbm
19 print (tie(%h,SDBM_File,'Op.dbmx', 0x202, 0640) ? "ok 1\n" : "not ok 1\n");
21 $Dfile = "Op.dbmx.pag";
24 print "# Probably a gdbm database\n";
26 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
27 $blksize,$blocks) = stat($Dfile);
28 print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n");
29 while (($key,$value) = each(%h)) {
32 print (!$i ? "ok 3\n" : "not ok 3\n");
34 $h{'goner1'} = 'snork';
38 $h{'jkl','mno'} = "JKL\034MNO";
39 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
50 $h{'goner2'} = 'snork';
54 print (tie(%h,SDBM_File,'Op.dbmx', 0x2, 0640) ? "ok 4\n" : "not ok 4\n");
74 $h{'goner3'} = 'snork';
82 if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
84 while (($key,$value) = each(h)) {
85 if ($key eq $keys[$i] && $value eq $values[$i] && $key gt $value) {
87 $i++ if $key eq $value;
91 if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
93 @keys = ('blurfl', keys(h), 'dyick');
94 if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
99 # check cache overflow and numeric keys and contents
101 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
102 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
103 print ($ok ? "ok 8\n" : "not ok 8\n");
105 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
106 $blksize,$blocks) = stat($Dfile);
107 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
109 @h{0..200} = 200..400;
111 print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
113 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
114 print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n");
116 unlink 'Op.dbmx.dir', $Dfile;