The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl -w
use strict;

use Test::More tests => 26;
use WWW::Scraper::ISBN::Driver;

###########################################################

my %isbn = (
    '098765432X'    => { ean13 => '9780987654328',  isbn10 => '0987654322' },
    '0987654322'    => { ean13 => '9780987654328',  isbn10 => '0987654322' },
    '0987654321'    => { ean13 => '9780987654328',  isbn10 => '0987654322' },
    '0571239560'    => { ean13 => '9780571239566',  isbn10 => '0571239560' },
    
    '9780571239566' => { ean13 => '9780571239566',  isbn10 => '0571239560' },
    '9780571239567' => { ean13 => '9780571239566',  isbn10 => '0571239560' },
    '9780571239580' => { ean13 => '9780571239580',  isbn10 => '0571239587' },

    '9790571239589' => { ean13 => '9790571239589',  isbn10 => '0571239587' },
    '9790577229560' => { ean13 => '9790577229560',  isbn10 => '0577229567' },

    '9790579239567' => { ean13 => '9790579239567',  isbn10 => '057923956X' },
    
    '978057123956'  => { ean13 => undef,            isbn10 => undef },
    '9990571239567' => { ean13 => undef,            isbn10 => undef },
    '098765432Z'    => { ean13 => undef,            isbn10 => undef },
);

###########################################################
# Internal tests

my $driver = WWW::Scraper::ISBN::Driver->new();
for my $isbn (keys %isbn) {
    is($driver->convert_to_ean13($isbn), $isbn{$isbn}{ean13} ,".. isbn 13 convert for $isbn");
    is($driver->convert_to_isbn10($isbn),$isbn{$isbn}{isbn10},".. isbn 10 convert for $isbn");
}

###########################################################