2014-11-02 07:46:19 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Test::More;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => "country_codes";
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
2016-05-12 06:23:28 -07:00
|
|
|
sub build_structured_answer{
|
|
|
|
my ($country, $response) = @_;
|
|
|
|
return 'ISO 3166: '. ucfirst $country .' - '. $response,
|
|
|
|
structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => $response,
|
|
|
|
subtitle => "ISO 3166 Country code: " . ucfirst ($country),
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => "text",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
sub build_test { test_zci(build_structured_answer(@_)) }
|
2014-11-02 07:46:19 -08:00
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[ 'DDG::Goodie::CountryCodes' ],
|
2016-05-12 06:23:28 -07:00
|
|
|
"country code Japan" => build_test("Japan","jp"),
|
|
|
|
"3 letter country code Japan" => build_test("Japan","jpn"),
|
|
|
|
"3 letter country code of China" => build_test("China","chn"),
|
|
|
|
"Japan 3 letter country code" => build_test("Japan","jpn"),
|
|
|
|
"Russia two letter country code" => build_test("Russia","ru"),
|
|
|
|
"two letter country code Japan" => build_test("Japan","jp"),
|
|
|
|
"three letter country code for Japan" => build_test("Japan","jpn"),
|
|
|
|
"numerical iso code japan" => build_test("Japan",392),
|
|
|
|
"iso code for spain" => build_test("Spain","es"),
|
|
|
|
"country code jp" => build_test("Japan","jp"),
|
|
|
|
"japan numerical iso 3166" => build_test("Japan",392),
|
|
|
|
"united states of america iso code" => build_test("United states of america","us"),
|
|
|
|
"3 letter iso code isle of man" => build_test("Isle of man","imn"),
|
|
|
|
'country code for gelgamek' => undef,
|
|
|
|
'iso code for english' => undef,
|
2014-11-02 07:46:19 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|