Author: theory
Date: Tue Jan 22 09:35:28 2008
New Revision: 10638
Modified:
DBD-Pg/trunk/t/09arrays.t
Log:
Added a few more tests to ensure that the utf8 flag is enabled on the values in
text arrays.
Modified: DBD-Pg/trunk/t/09arrays.t
==============================================================================
--- DBD-Pg/trunk/t/09arrays.t (original)
+++ DBD-Pg/trunk/t/09arrays.t Tue Jan 22 09:35:28 2008
@@ -15,7 +15,7 @@
my $dbh = connect_database();
if (defined $dbh) {
- plan tests => 220;
+ plan tests => 227;
}
else {
plan skip_all => 'Connection to database failed, cannot continue
testing';
@@ -455,11 +455,14 @@
local $dbh->{pg_enable_utf8} = 1;
my $utf8_str = chr(0x100).'dam'; # LATIN CAPITAL LETTER A WITH MACRON
+ ok Encode::is_utf8( $utf8_str ), 'String should be UTF-8';
my $quoted = $dbh->quote($utf8_str);
is( $quoted, qq{'$utf8_str'}, 'quote() handles utf8' );
+ ok Encode::is_utf8( $quoted ), 'Quoted string should be UTF-8';
$quoted = $dbh->quote([$utf8_str, $utf8_str]);
is( $quoted, qq!{"$utf8_str","$utf8_str"}!, 'quote() handles utf8
inside array' );
+ ok Encode::is_utf8( $quoted ), 'Quoted array of strings should be UTF-8';
$dbh->do("DELETE FROM dbd_pg_test");
$SQL = "INSERT INTO dbd_pg_test (id, testarray, val) VALUES (1,
'$quoted', 'one')";
@@ -475,6 +478,8 @@
my $t = q{Retreiving an array containing utf-8 works};
my $expected = [1,[$utf8_str,$utf8_str],'one'];
is_deeply($result, $expected, $t);
+ ok Encode::is_utf8( $result->[1][0] ), 'Selected string should be UTF-8';
+ ok Encode::is_utf8( $result->[1][1] ), 'Selected string should be UTF-8';
$dbh->do("DELETE FROM dbd_pg_test");
$SQL = "INSERT INTO dbd_pg_test (id, testarray, val) VALUES (?, ?,
'one')";
@@ -491,6 +496,8 @@
$t = q{Retreiving an array containing utf-8 works};
$expected = [1,['Bob',$utf8_str],'one'];
is_deeply($result, $expected, $t);
+ ok !Encode::is_utf8( $result->[1][0] ), 'Selected ASCII string should not
be UTF-8';
+ ok Encode::is_utf8( $result->[1][1] ), 'Selected string should be UTF-8';
$dbh->do("DELETE FROM dbd_pg_test");
$SQL = qq{INSERT INTO dbd_pg_test (id, testarray, val) VALUES (1,
'{"noutfhere"}', 'one')};