3 # openisis - an open implementation of the CDS/ISIS database
4 # Version 0.8.x (patchlevel see file Version)
5 # Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # see README for more information
24 # Before `make install' is performed this script should be runnable with
25 # `make test'. After `make install' it should work as `perl test.pl'
27 ######################### We start with some black magic to print on failure.
29 # Change 1..1 below to 1..last_test_to_print .
30 # (It may become useful if the test is moved to ./t subdirectory.)
32 BEGIN { $| = 1; print "1..6\n"; }
33 END {print "not ok 1\n" unless $loaded;}
38 ######################### End of black magic.
40 # Insert your test code below (better if it prints "ok 13"
41 # (correspondingly "not ok 13") depending on the success of chunk 13
44 sub pok { print $_[1] ? '' : 'not ', 'ok ', $_[0], ' (', $_[2], ") \n"; }
47 pok( 2, 1, 'unfortunately the effect of logging cannot be tested here' );
49 $db = OpenIsis::open( "cds", "-dbpath", "../db/cds" );
50 pok( 3, $db >= 0, $db );
52 $maxrow = OpenIsis::maxRowid( $db );
53 pok( 4, $maxrow > 0, $maxrow );
55 $row = OpenIsis::read( $db, 28 );
60 # print STDERR "\t$_=",join( "\n\t", @$a ),"\n";
62 pok( 5, "HASH" eq ref($row), $row );
64 $row = OpenIsis::subfields( '^ap. 233-238 ^billus.' );
65 # for (keys(%$row)) { print STDERR "\t$_=$row->{$_}\n"; }
66 pok( 6, "HASH" eq ref($row) && 'p. 233-238 ' eq $row->{'a'}, $row->{'a'} );
68 @res = OpenIsis::query( $db, 'plant * water' );
69 # print STDERR "mfns for 'plant * water': ", join(',',@res), "\n";
70 pok( 7, 2 == @res, scalar(@res) );
71 @res = OpenIsis::query( $db, 'devel$' );
72 # print STDERR "mfns for 'devel$': ", join(',',@res), "\n";
73 pok( 8, 18 == @res, scalar(@res) );
76 $nodb = OpenIsis::open( "foo", "-dbpath", "/no/such/database" );
77 pok( 9, $nodb == $OpenIsis::ERR_BADF, $nodb );
81 $row = OpenIsis::read( $db, $_ );
82 $title = $row->{'24'};
83 OpenIsis::MHL( @$title );
84 # print STDERR "mfn ", $row->{'mfn'}, " title: ", $title->[0], "\n";
86 @res = OpenIsis::terms( $db, 'a$' );
87 # print STDERR 'terms for "a$": ', join('; ',@res), "\n";
89 $str = OpenIsis::2html( 'lt: < gt: > amp: & quot: "' );
90 # print STDERR "\t$str\n";
92 @res = OpenIsis::query( $db, 'Dacca' );
94 $row = OpenIsis::read( $db, $_, 'V24, V26, V26^*[..], V71,' );
95 for (sort(keys(%$row))) {
97 # for $v (@$vals) { print STDERR "\t$_=$v\n"; }