[svn:DBD-Pg] r14548 - in DBD-Pg/trunk: . t

[email protected]
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Author: theory
Date: Mon Nov 22 20:57:51 2010
New Revision: 14548

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/t/06bytea.t

Log:
Fix hexidecimal bytea tests.

They need to actually compare to hexidecimal strings.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes	(original)
+++ DBD-Pg/trunk/Changes	Mon Nov 22 20:57:51 2010
@@ -4,8 +4,10 @@
 
   - Fix the number of tests to skip in t/01connect.t when the $DBI_DSN
     environment variable lacks a database specification.
-  - Fix the number of tests to skip in t/06bytea.t when running on a version
+  - Fix algorithm for skiping tests in t/06bytea.t when running on a version
     of PostgreSQL lower than 9.0.
+  - Fix failing tests in t/06bytea.t when running on PostgreSQL 9.0 or later
+    and using hexadecimal binary format.
 
 2.17.2 Released November 21, 2010 (subversion r14542)
 

Modified: DBD-Pg/trunk/t/06bytea.t
==============================================================================
--- DBD-Pg/trunk/t/06bytea.t	(original)
+++ DBD-Pg/trunk/t/06bytea.t	Mon Nov 22 20:57:51 2010
@@ -50,9 +50,13 @@
 ok ($sth->execute(404, $binary_out), $t);
 
 SKIP: {
-    skip 'No BYTEA output format setting before 9.0', 10
-        if $pgversion < 90000;
-    for my $output (qw(hex escape)) {
+    my @output;
+    if ($pgversion < 90000) {
+        skip 'No BYTEA output format setting before 9.0', 5;
+    } else {
+        @output = (qw(hex escape));
+    }
+    for my $output (@output) {
         $dbh->do(qq{SET bytea_output = '$output'}) if $output;
 
         $t='Received correct text from BYTEA column with backslashes';
@@ -60,22 +64,33 @@
         $sth = $dbh->prepare(q{SELECT bytetest FROM dbd_pg_test WHERE id=?});
         $sth->execute(400);
         my $byte = $sth->fetchall_arrayref()->[0][0];
-        is ($byte, 'aa\bb\cc\\\0dd\\', $t);
+        my $exp = $output eq 'hex'
+            ? 'x61615c62625c63635c5c3064645c'
+            : 'aa\bb\cc\\\0dd\\';
+        is ($byte, $exp, $t);
 
         $t='Received correct text from BYTEA column with quote';
         $t.=" ($output output)" if $output;
         $sth->execute(402);
         $byte = $sth->fetchall_arrayref()->[0][0];
-        is ($byte, '\'', $t);
+        is ($byte, ($output eq 'hex' ? 'x27' : '\''), $t);
 
         $t='Ensure proper handling of high bit characters';
         $t.=" ($output output)" if $output;
         $sth->execute(403);
         ($binary_in) = $sth->fetchrow_array();
-        ok ($binary_in eq $binary_out, $t);
-        $sth->execute(404);
-        ($binary_in) = $sth->fetchrow_array();
-        ok ($binary_in eq $binary_out, $t);
+        if ($output eq 'hex') {
+            my $hex = 'x' . unpack 'H*', $binary_out;
+            is $binary_in, $hex, $t;
+            $sth->execute(404);
+            ($binary_in) = $sth->fetchrow_array();
+            is $binary_in, $hex, $t;
+        } else {
+            ok ($binary_in eq $binary_out, $t);
+            $sth->execute(404);
+            ($binary_in) = $sth->fetchrow_array();
+            ok ($binary_in eq $binary_out, $t);
+        }
 
         $t='quote properly handles bytea strings';
         $t.=" ($output output)" if $output;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.