#!/usr/bin/perl
package bookfinder;
use Test::More tests=>12;
use strict;
use warnings;
require "index.cgi";
is(scalar get_book(), 0, "0 books in the beginning");
my @books = qw
(
lang/aa.chm
lang/bb.pdf
misc/cc.txt
);
find_book() for @books;
my $first = list_book_callback(0, 1);
is(scalar @$first, 1, "show 1 book");
is(scalar @{$$first[0]}, 1, "one item for one book");
is(${$$first[0]}[0], qq{aa.chm}, "table data");
my $second = list_book_callback(1, 1);
is(scalar @$second, 1, "show 1 book");
is(${$$second[0]}[0], qq{bb.pdf}, "table data");
my $both = list_book_callback(0, 2);
is(scalar @$both, 2, "show 2 books");
is(${$$both[0]}[0], qq{aa.chm}, "table data");
is(${$$both[1]}[0], qq{bb.pdf}, "table data");
my $three = list_book_callback(0, 3);
is(scalar @$three, 2, "show 2 books even want 3");
is(${$$three[0]}[0], qq{aa.chm}, "table data");
is(${$$three[1]}[0], qq{bb.pdf}, "table data");