New -- initial version exercises all the functions, but doesn't
[ZOOM-Perl-moved-to-github.git] / t / 16-packages.t
1 # $Id: 16-packages.t,v 1.1 2005-11-08 13:47:11 mike Exp $
2
3 # Before `make install' is performed this script should be runnable with
4 # `make test'. After `make install' it should work as `perl 16-packages.t'
5
6 use strict;
7 use warnings;
8 use Test::More tests => 6;
9
10 BEGIN { use_ok('Net::Z3950::ZOOM') };
11
12 my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy");
13
14 my $host = "indexdata.com/gils";
15 my $conn = Net::Z3950::ZOOM::connection_new($host, 0);
16 $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
17 ok($errcode == 0, "connection to '$host'");
18
19 my $o = Net::Z3950::ZOOM::options_create();
20 my $p = Net::Z3950::ZOOM::connection_package($conn, $o);
21 # Inspection of the ZOOM-C code shows that this can never fail, in fact.
22 ok(defined $p, "created package");
23
24 # There may be useful options to set, but this is not one of them!
25 Net::Z3950::ZOOM::package_option_set($p, "foo", "bar");
26 my $val = Net::Z3950::ZOOM::package_option_get($p, "foo");
27 ok($val eq "bar", "package option retrieved as expected");
28
29 Net::Z3950::ZOOM::package_send($p, "foo");
30 $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
31 ok($errcode == 0, "sent 'foo' package");
32
33 ### Now what?
34
35 Net::Z3950::ZOOM::package_destroy($p);
36 ok(1, "destroyed package");