2 # Before 'make install' is performed this script should be runnable with
3 # 'make test'. After 'make install' it should work as 'perl test.pl'
5 #########################
9 BEGIN {$SIG{__WARN__} = sub { die "Terminating test due to warning: $_[0]" } };
12 BEGIN { plan tests => 26 };
13 use Xapian qw(:standard);
16 ok(1); # If we made it this far, we're ok.
18 #########################
20 # Test non-class functions.
22 my $version = join(".", (
23 Xapian::major_version(),
24 Xapian::minor_version(),
28 ok($version eq Xapian::version_string());
30 my $ldbl = (defined($Config{uselongdouble}) &&
31 $Config{uselongdouble} eq "define" &&
32 $Config{doublesize} != $Config{longdblsize});
33 for my $val (-9e10, -1234.56, -1, -1e-10, 0, 1e-10, 1, 2, 4, 8, 9, 9e10) {
34 my $enc_val = Xapian::sortable_serialise($val);
36 # Perl is configured with -Duselongdouble and long double isn't the
37 # same as double, so we may have rounded the input value slightly
38 # passing it to Xapian.
39 my $de_enc_val = Xapian::sortable_unserialise($enc_val);
40 ok(abs($de_enc_val - $val) < 1e-12);
41 # But encoding and decoding the value we got back should give exactly
43 my $re_enc_val = Xapian::sortable_serialise($de_enc_val);
44 ok(Xapian::sortable_unserialise($re_enc_val) == $de_enc_val);
46 # We should get the exact same value back.
47 ok(Xapian::sortable_unserialise($enc_val) == $val);