DBD-PO
view release on metacpan or search on metacpan
t/03_DBD-PO/13_charsets.t view on Meta::CPAN
#!perl -T
use strict;
use warnings;
use Carp qw(croak);
use English qw(-no_match_vars $OS_ERROR $INPUT_RECORD_SEPARATOR);
use Test::DBD::PO::Defaults qw(
$TRACE $PATH $DROP_TABLE
trace_file_name
$TABLE_13 $FILE_13
);
use Test::More tests => 27 + 1;
use Test::NoWarnings;
use Test::Differences;
BEGIN {
require_ok('DBI');
require_ok('charnames');
charnames->import(':full');
require_ok('Encode');
Encode->import('encode');
}
my $trace_file;
if ($TRACE) {
open $trace_file, '>', trace_file_name();
}
# build table
sub build_table {
my $param = shift;
my $charset = $param->{charset};
my $dbh = $param->{dbh} = DBI->connect(
"dbi:PO:f_dir=$PATH;po_eol=\n;po_charset=$charset",
undef,
undef,
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
},
);
isa_ok($dbh, 'DBI::db', "connect ($charset)");
if ($trace_file) {
$dbh->trace(4, $trace_file);
}
@{$param}{qw(table table_file)} = (
$TABLE_13,
$FILE_13,
);
for my $name (@{$param}{qw(table table_file)}) {
$name =~ s{\?}{$charset}xms;
}
my $result = $dbh->do(<<"EO_SQL");
CREATE TABLE $param->{table} (
msgid VARCHAR,
msgstr VARCHAR
)
EO_SQL
is($result, '0E0', "create table ($charset)");
ok(-e $param->{table_file}, "table file found ($charset)");
return;
}
sub add_header {
my $param = shift;
my $dbh = $param->{dbh};
my $charset = $param->{charset};
( run in 1.562 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )