# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

use strict;
my ($loaded, $tests, $testnum, $ret);

sub testing { printf "%sok %d\n", (@_[0] ? "" : "not "), ++$testnum; }

######################### We start with some black magic to print on failure.

# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)

BEGIN { $tests++; }
END {print "not ok 1\n" unless $loaded;}
use Zephyr;
$loaded = 1;
testing(1);

######################### End of black magic.

# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):

BEGIN { $tests++; }
my $Version = ZVERSIONHDR . ZVERSIONMAJOR . '.' . ZVERSIONMINOR;
print "# Zephyr version is $Version\n";
testing ($Version eq "ZEPH0.2");

BEGIN { $tests++; }
testing (Zephyr::error_message(-772103679) eq 'Notice header too large');

BEGIN { $tests++; }
testing (Z::Initialize());

BEGIN { $tests++; }
$ret = Z::OpenPort(0);
print "# port = $ret\n";
testing ( $ret );

BEGIN { $tests++; }
testing (Z::ClosePort());

BEGIN { $tests++; }
testing (ref(ZAUTH) eq 'Z_AuthProc');

BEGIN { $tests++; }
testing (! defined ZNOAUTH() );

BEGIN { $tests++; }
my $obj1 = Zephyr::Notice->TIEHASH();
my $obj2 = Zephyr::Notice->TIEHASH();
print "# OBJ1 is $obj1, OBJ2 is $obj2\n";
testing( "$obj1" ne "$obj2" );

BEGIN { $tests++; }
my %foo;
my $obj = tie %foo, 'Zephyr::Notice';
testing( $obj );
BEGIN { $tests++; }
testing( $obj eq tied(%foo) );
BEGIN { $tests++; }
testing( ! defined $foo{'sender'} );
BEGIN { $tests++; }
testing( ! defined $foo{'message'} );
print "# z_time = $foo{'time'}\n";
BEGIN { $tests++; }
testing( $foo{'checksum'} eq 0 );

###### Print out how many tests (at the start of execution).

BEGIN { $| = 1; print "1..$tests\n"; }
