|
Revision 16900, 1.8 kB
(checked in by bonar, 5 years ago)
|
|
module for International Standard Recording Code (ISRC)
|
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | |
|---|
| 6 | use Test::More tests => 2000; |
|---|
| 7 | use Business::ISRC; |
|---|
| 8 | |
|---|
| 9 | # only officially assigned code |
|---|
| 10 | my @country_code = qw/ |
|---|
| 11 | AD AE AF AG AI AL AM AN AO AQ Co AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY Co BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CX CY CZ DE Co DJ DK DM DO DZ EC EE EG EH Co ER ES Co ET FI FJ FK FM FO FR GA GB GD GE GF GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IN IO IQ IR IS IT JM JO JP KE KG KH Co KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD MG MH MK Co ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR ST SV SY SZ TC TD TF Co TG TH TJ TK TL TM TN TO TR TT TV TW De TZ UA UG UM US UY UZ VA Pr VC VE VG VI VN VU WF WS YE YT ZA ZM ZW |
|---|
| 12 | /; |
|---|
| 13 | # GG ME IM MF JE BL RS UK |
|---|
| 14 | |
|---|
| 15 | my @registrant = qw/ |
|---|
| 16 | a b c d e f g h i j k l m n o p q r s t u |
|---|
| 17 | A B C D E F G H I J K L M N O P Q R S T U |
|---|
| 18 | 0 1 2 3 4 5 6 7 8 9 |
|---|
| 19 | /; |
|---|
| 20 | |
|---|
| 21 | for (1..1000) { |
|---|
| 22 | # create dummy isrc |
|---|
| 23 | my %dummy = ( |
|---|
| 24 | country => $country_code[int(rand()*(scalar @country_code))], |
|---|
| 25 | registrant => |
|---|
| 26 | $registrant[int(rand()*(scalar @registrant))] . |
|---|
| 27 | $registrant[int(rand()*(scalar @registrant))] . |
|---|
| 28 | $registrant[int(rand()*(scalar @registrant))], |
|---|
| 29 | year => sprintf("%02d", int(rand()*100)), |
|---|
| 30 | designation => sprintf("%05d", int(rand()*10000)), |
|---|
| 31 | ); |
|---|
| 32 | my $prefix = int(rand()*3) == 0 ? 'ISRC-' : ''; |
|---|
| 33 | my $delim = int(rand()*3) == 0 ? '' : '-'; |
|---|
| 34 | |
|---|
| 35 | my $dummy_isrc = $prefix . (join $delim |
|---|
| 36 | , @dummy{qw/country registrant year designation/}); |
|---|
| 37 | |
|---|
| 38 | my $isrc = Business::ISRC->new($dummy_isrc); |
|---|
| 39 | isa_ok($isrc, 'Business::ISRC'); |
|---|
| 40 | is($dummy_isrc, $isrc->raw_string(), "$dummy_isrc"); |
|---|
| 41 | } |
|---|
| 42 | |
|---|