Committed by Greg Sabino Mullane <[email protected]>

Subject: [DBD::Pg 2/2] Add test skeleton for new pg_utf8_flag work.

---
 MANIFEST       |    1 +
 t/10utf8flag.t |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/MANIFEST b/MANIFEST
index a056945..569b621 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -39,6 +39,7 @@ t/06bytea.t
 t/07copy.t
 t/08async.t
 t/09arrays.t
+t/10utf8flag.t
 t/12placeholders.t
 t/20savepoints.t
 t/99cleanup.t
diff --git a/t/10utf8flag.t b/t/10utf8flag.t
new file mode 100644
index 0000000..258a326
--- /dev/null
+++ b/t/10utf8flag.t
@@ -0,0 +1,79 @@
+#!perl
+
+## Test the pg_utf8_flag handling
+
+use 5.006;
+use strict;
+use warnings;
+use Test::More;
+use DBI     ':sql_types';
+use DBD::Pg ':pg_types';
+use lib 't','.';
+require 'dbdpg_test_setup.pl';
+select(($|=1,select(STDERR),$|=1)[1]);
+
+my $dbh = connect_database();
+
+if (! $dbh) {
+       plan skip_all => 'Connection to database failed, cannot continue 
testing';
+}
+plan tests => 16;
+
+isnt ($dbh, undef, 'Connect to database for pg_utf8_flag testing');
+
+my ($pglibversion,$pgversion) = 
($dbh->{pg_lib_version},$dbh->{pg_server_version});
+if ($pgversion >= 80100) {
+       $dbh->do('SET escape_string_warning = false');
+}
+
+my ($sth, $t);
+
+$t='pg_utf8_flag starts life with sane default value';
+
+$t='pg_utf8_flag can be set on startup to true';
+
+$t='pg_utf8_flag can be set on startup to false';
+
+$t='pg_utf8_flag can be set on startup to -1';
+
+$t='pg_utf8_flag can be set after startup to true';
+
+$t='pg_utf8_flag can be set after startup to false';
+
+$t='pg_utf8_flag can be set after startup to -1';
+
+
+$t='A UTF-8 database sets utf8_flag correctly';
+
+$t='A UTF-8 database returns flagged data when client_encoding is UTF-8';
+
+$t='A UTF-8 database returns raw data when client_encoding is UTF-8 and 
pg_utf8_flag off';
+
+$t='A UTF-8 database returns raw data when client_encoding is not UTF-8';
+
+$t='A UTF-8 database returns flagged data when client_encoding is not UTF-8 
and pg_utf8_flag on';
+
+
+$t='A SQL_ASCII database sets utf8_flag correctly';
+
+$t='A SQL_ASCII database returns raw data when client_encoding is UTF-8';
+
+$t='A SQL_ASCII database returns raw data when client_encoding is UTF-8 and 
pg_utf8_flag off';
+
+$t='A SQL_ASCII database returns raw data when client_encoding is not UTF-8';
+
+$t='A SQL_ASCII database returns raw data when client_encoding is not UTF-8 
and pg_utf8_flag on';
+
+
+$t='A BIG5 database sets utf8_flag correctly';
+
+$t='A BIG5 database returns flagged data when client_encoding is UTF-8';
+
+$t='A BIG5 database returns raw data when client_encoding is UTF-8 and 
pg_utf8_flag off';
+
+$t='A BIG5 database returns raw data when client_encoding is not UTF-8';
+
+$t='A BIG5 database returns flagged data when client_encoding is not UTF-8 and 
pg_utf8_flag on';
+
+
+exit;
-- 
1.7.0.5

Reply via email to