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 #########################
8 BEGIN { plan tests => 26 };
9 use Search::Xapian qw(:standard);
12 ok(1); # If we made it this far, we're ok.
14 #########################
16 # Test non-class functions.
18 my $version = join(".", (
19 Search::Xapian::major_version(),
20 Search::Xapian::minor_version(),
21 Search::Xapian::revision()
24 ok($version eq Search::Xapian::version_string());
26 my $ldbl = (defined($Config{uselongdouble}) &&
27 $Config{uselongdouble} eq "define" &&
28 $Config{doublesize} != $Config{longdblsize});
29 for my $val (-9e10, -1234.56, -1, -1e-10, 0, 1e-10, 1, 2, 4, 8, 9, 9e10) {
30 my $enc_val = Search::Xapian::sortable_serialise($val);
32 # Perl is configured with -Duselongdouble and long double isn't the
33 # same as double, so we may have rounded the input value slightly
34 # passing it to Xapian.
35 my $de_enc_val = Search::Xapian::sortable_unserialise($enc_val);
36 ok(abs($de_enc_val - $val) < 1e-12);
37 # But encoding and decoding the value we got back should give exactly
39 my $re_enc_val = Search::Xapian::sortable_serialise($de_enc_val);
40 ok(Search::Xapian::sortable_unserialise($re_enc_val) == $de_enc_val);
42 # We should get the exact same value back.
43 ok(Search::Xapian::sortable_unserialise($enc_val) == $val);