ACME-QuoteDB
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/04-load_get_quote_utf8.t view on Meta::CPAN
#!perl -T
# /* vim:et: set ts=4 sw=4 sts=4 tw=78 encoding=utf-8: */
use 5.008005; # require perl 5.8.5
# DBD::SQLite Unicode is not supported before 5.8.5
use strict;
use warnings;
use utf8; # yes this source code does contain utf8 characters
use ACME::QuoteDB;
use ACME::QuoteDB::LoadDB;
#use Test::More 'no_plan';
use Test::More tests => 8;
use File::Basename qw/dirname/;
use Data::Dumper qw/Dumper/;
use Carp qw/croak/;
use File::Temp;
use File::Spec;
BEGIN {
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};
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.775 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )