1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
4 ######################### We start with some black magic to print on failure.
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
9 BEGIN { $| = 1; print "1..2\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use Business::CreditCard;
15 ######################### End of black magic.
17 # Insert your test code below (better if it prints "ok 13"
18 # (correspondingly "not ok 13") depending on the success of chunk 13
22 if( test_card_identification() ){ print "ok 2\n" }else{ print "not ok 2\n" }
24 sub test_card_identification{
26 # For the curious the table of test number aren't real credit card
27 # in fact they won't validate but they do obey the rule for the
28 # cardtype table to identify the card type.
31 '5212345678901234' => 'MasterCard',
32 '5512345678901234' => 'MasterCard',
33 '4123456789012' => 'VISA card',
34 '4512345678901234' => 'VISA card',
35 '341234567890123' => 'American Express card',
36 '371234567890123' => 'American Express card',
37 '30112345678901' => "Diner's Club/Carte Blanche",
38 '30512345678901' => "Diner's Club/Carte Blanche",
39 #'36123456789012' => "Diner's Club/Carte Blanche",
40 '36123456789012' => 'MasterCard',
41 '38123456789012' => "Diner's Club/Carte Blanche",
42 '201412345678901' => 'enRoute',
43 '214912345678901' => 'enRoute',
44 '6011123456789012' => 'Discover card',
45 '3123456789012345' => 'JCB',
46 '213112345678901' => 'JCB',
47 '180012345678901' => 'JCB',
48 '1800123456789012' => 'Unknown',
49 '312345678901234' => 'Unknown',
50 '4111xxxxxxxxxxxx' => 'VISA card',
51 '6599xxxxxxxxxxxx' => 'Discover card',
52 '6222xxxxxxxxxxxx' => 'Discover card', #China Union Pay
53 '6304980000000000004' => 'Laser',
55 while( my ($k, $v)=each(%test_table) ){
56 if(cardtype($k) ne $v){
57 print "Card $k - should be $v cardtpe returns ",cardtype