ACME-QuoteDB
view release on metacpan or search on metacpan
t/04-load_get_quote_utf8.t view on Meta::CPAN
eval "use DBD::SQLite";
$@ and croak 'DBD::SQLite is a required dependancy';
# give alternate path to the DB
$ENV{ACME_QUOTEDB_PATH} =
File::Temp->new( UNLINK => 0,
EXLOCK => 0,
SUFFIX => '.dat',
);
}
# matches the data in our utf8.csv file, soon to be in our quote db
my $utf8_quotes = [
'¥ · £ · â¬Â · $ · ¢ · â¡Â · â¢Â · â£Â · â¤Â · â¥Â · â¦Â · â§Â · â¨Â · â©Â · âªÂ · â«Â · â · â®Â · â¯',
'æè½åä¸ç»çèä¸ä¼¤èº«ä½ã',
'ç§ã¯ã¬ã©ã¹ãé£ã¹ããã¾ããããã¯ç§ãå·ã¤ãã¾ããã',
'ëë ì 리를 먹ì ì ìì´ì. ê·¸ëë ìíì§ ììì',
'Tsésǫʼ yishÄ
ÌÄ
go bÃÃnÃshghah dóó doo shiÅ neezgai da. ',
'ÎÏοÏÏ Î½Î± ÏÎ¬Ï ÏÏαÏμÎνα γÏ
αλιά ÏÏÏÎ¯Ï Î½Î± ÏÎ¬Î¸Ï ÏίÏοÏα.',
'मà¥à¤ à¤à¤¾à¤à¤ à¤à¤¾ सà¤à¤¤à¤¾ हà¥à¤, मà¥à¤à¥ à¤à¤¸ सॠà¤à¥à¤ पà¥à¤¡à¤¾ नहà¥à¤ हà¥à¤¤à¥.',
'×× × ×××× ××××× ×××××ת ××× ×× ××××§ ××',
];# any takers for specifying each multibyte code sequence for the above,.. ;)
{
#make test db writeable
use ACME::QuoteDB::DB::DBI;
# yeah, this is supposed to be covered by the build process
# but is failing sometimes,...
chmod 0666, ACME::QuoteDB::DB::DBI->get_current_db_path;
my $q = File::Spec->catfile((dirname(__FILE__),'data'),
'utf8.csv'
);
my $load_db = ACME::QuoteDB::LoadDB->new({
file => $q,
file_format => 'csv',
delimiter => "\t",
create_db => 1
});
isa_ok $load_db, 'ACME::QuoteDB::LoadDB';
$load_db->data_to_db;
is $load_db->success, 1;
}
my $sq = ACME::QuoteDB->new;
# matches the data in our utf8.csv file, attribution's to the 'quotes' above
my @expected_attribution_list = (
'UTF-8 Sampler Currency',
'I can eat grass (Chinese)',
'I can eat grass (Japanese)',
'I can eat grass (Korean)',
'I can eat grass (Navajo)',
'I can eat grass (Greek)',
'I can eat grass (Hindi)',
'I can eat grass (Hebrew)',
);
is( $sq->list_attr_names, join "\n", sort @expected_attribution_list);
ok $sq->get_quote; # default get random quote
ok $sq->get_quote =~ m{\w+};
is $sq->get_quote({AttrName => $expected_attribution_list[1]}),
$utf8_quotes->[1] . "\n-- " . $expected_attribution_list[1];
is $sq->get_quote({AttrName => $expected_attribution_list[6]}),
$utf8_quotes->[6] . "\n-- " . $expected_attribution_list[6];
is @{ $sq->get_quotes({ Rating => '10' })}, @{$utf8_quotes};
( run in 0.908 second using v1.01-cache-2.11-cpan-39bf76dae61 )