| timbo@cvs.perl.org 2005-06-03, 8:27 pm |
| Author: timbo
Date: Mon Oct 18 14:02:01 2004
New Revision: 494
Modified:
dbd-oracle/trunk/t/20select.t
dbd-oracle/trunk/t/30long.t
dbd-oracle/trunk/t/40ph_type.t
dbd-oracle/trunk/t/nchar_test_lib.pl
Log:
Factor out byte+nice string tests into new cmp_ok_byte_nice() sub.
Use cmp_ok_byte_nice in t/30long.t
Add way to give test tables unique names (so tests can be run in parallel in the same db)
Modified: dbd-oracle/trunk/t/20select.t
====================
====================
====================
==================
--- dbd-oracle/trunk/t/20select.t (original)
+++ dbd-oracle/trunk/t/20select.t Mon Oct 18 14:02:01 2004
@@ -15,7 +15,7 @@
my $t = 0;
my $failed = 0;
my %ocibug;
-my $table = "dbd_ora__drop_me";
+my $table = "dbd_ora__drop_me" . ($ENV& #123;DBD_ORACLE_SEQ}
||'');
my $dbuser = $ENV{ORACLE_USERID} || 'scott/tiger';
Modified: dbd-oracle/trunk/t/30long.t
====================
====================
====================
==================
--- dbd-oracle/trunk/t/30long.t (original)
+++ dbd-oracle/trunk/t/30long.t Mon Oct 18 14:02:01 2004
@@ -18,7 +18,7 @@
push @test_sets, [ "CLOB", ORA_CLOB, 0 ] ;
push @test_sets, [ "BLOB", ORA_BLOB, 0 ] ;
-my $tests_per_set = 92;
+my $tests_per_set = 94;
my $tests = @test_sets * $tests_per_set;
plan tests => $tests;
@@ -182,9 +182,7 @@
#print "tmp->[0][1] = " .$tmp->[0][1] ."\n" ;
for my $i (0..2) {
my $v = $tmp->[$i][1];
- ok(length($v) == $out_len, "$type_name length $out_len (actually ".length($v).")");
- ok($v eq substr($long_data& #91;$i],0,$out_len),
- cdif($v, substr($long_data& #91;$i],0,$out_len),
"Len ".length($v)) );
+ cmp_ok_byte_nice(
$v, substr($long_data& #91;$i],0,$out_len),
"truncated to LongReadLen $out_len");
if ($type_name eq 'BLOB') {
ok( !utf8::is_utf8($v), "BLOB non-UTF8");
}
@@ -240,7 +238,7 @@
SKIP: {
- skip( "blob_read tests for LONGs - not currently supported", 13 )
+ skip( "blob_read tests for LONGs - not currently supported", 15 )
if ($type_name =~ /LONG/i) ;
#$dbh->trace(4);
@@ -252,29 +250,38 @@
ok($sth = $dbh->prepare($sqlstr) ,"prepare $sqlstr" );
ok($sth->execute, "execute $sqlstr" );
+
print "fetch via fetchrow_arrayref\n";
ok($tmp = $sth->fetchrow_arrayref, "fetchrow_arrayref 1: $sqlstr" );
- ok($tmp->[1] eq $long_data[0], cdif($tmp->[1], $long_data[0]) );
+ cmp_ok_byte_nice($tm
p->[1], $long_data[0], "truncated to LongReadLen $out_len");
print "read via blob_read_all\n";
- cmp_ok(blob_read_all
($sth, 1, \$p1, 4096) ,'==', length($long_data[0]), "blob_read_all = length(\$long_data[0])" );
+ cmp_ok(blob_read_all
($sth, 1, \$p1, 4096) ,'==', length($long_data[0]),
+ "blob_read_all = length(\$long_data[0])" );
ok($p1 eq $long_data[0], cdif($p1, $long_data[0]) );
$sth->trace(0);
+
ok($tmp = $sth->fetchrow_arrayref, "fetchrow_arrayref 2: $sqlstr" );
- cmp_ok(blob_read_all
($sth, 1, \$p1, 12345) ,'==', length($long_data[1]), "blob_read_all = length(long_data[1])" );
+ cmp_ok(blob_read_all
($sth, 1, \$p1, 12345) ,'==', length($long_data[1]),
+ "blob_read_all = length(long_data[1])" );
ok($p1 eq $long_data[1], cdif($p1, $long_data[1]) );
+
ok($tmp = $sth->fetchrow_arrayref, "fetchrow_arrayref 3: $sqlstr" );
my $len = blob_read_all($sth, 1, \$p1, 34567);
cmp_ok($len,'==', length($long_data[2]), "length of long_data[2] = $len" );
- ok($p1 eq $long_data[2], cdif($p1, $long_data[2]) ); # Oracle may return the right length but corrupt the string.
+ cmp_ok_byte_nice($p1
, $long_data[2], "3rd row via blob_read_all");
print "result is ".(utf8::is_utf8($p1) ? "UTF8" : "non-UTF8")."\n";
- ok( !utf8::is_utf8($p1) == !$be_utf8,
- "$type_name should be ".($be_utf8 ? "UTF8" : "non-UTF8") );
- } #skip 13
+ if ($be_utf8) {
+ ok( utf8::is_utf8($p1), "result should be utf8");
+ }
+ else {
+ ok( !utf8::is_utf8($p1),
"result should not be utf8");
+ }
+ } #skip
SKIP: {
Modified: dbd-oracle/trunk/t/40ph_type.t
====================
====================
====================
==================
--- dbd-oracle/trunk/t/40ph_type.t (original)
+++ dbd-oracle/trunk/t/40ph_type.t Mon Oct 18 14:02:01 2004
@@ -57,7 +57,7 @@
print "1..$tests\n";
my ($sth,$tmp);
-my $table = " dbd_oracle_test__dro
p_me";
+my $table = "dbd_ora__drop_me" . ($ENV& #123;DBD_ORACLE_SEQ}
||'');
# drop table but don't warn if not there
eval {
Modified: dbd-oracle/trunk/t/nchar_test_lib.pl
====================
====================
====================
==================
--- dbd-oracle/trunk/t/nchar_test_lib.pl (original)
+++ dbd-oracle/trunk/t/nchar_test_lib.pl Mon Oct 18 14:02:01 2004
@@ -170,7 +170,7 @@
return $cnt;
}
-sub table { 'dbd_ora__drop_me' ; }
+sub table { 'dbd_ora__drop_me'.($ENV& #123;DBD_ORACLE_SEQ}
||''); }
sub drop_table
{
my ($dbh) = @_;
@@ -314,13 +314,7 @@
my $is_utf8 = utf8::is_utf8( $res ) ? " (uft8)" : "";
my $description = "row $row: column: $tcols->[$i][0] $is_utf8 $charname";
- $error += not cmp_ok( byte_string($res), 'eq', byte_string($$trows[$cnt][$i]),
-
- "byte_string test of $description"
- );
- $error += not cmp_ok( nice_string($res), 'eq', nice_string($$trows[$cnt][$i] ),
- "nice_string test of $description"
- );
+ $error += not cmp_ok_byte_nice($re
s, $$trows[$cnt][$i], $description);
#$sth->trace(0) if $cnt >= 3 ;
}
if ( $error )
@@ -333,6 +327,18 @@
my $trow_cnt = @$trows;
cmp_ok( $cnt, '==', $trow_cnt, "number of rows fetched" );
}
+
+sub cmp_ok_byte_nice {
+ my ($got, $expected, $description) = @_;
+ my $ok1 = cmp_ok( byte_string($got), 'eq', byte_string($expecte
d),
+ "byte_string test of $description"
+ );
+ my $ok2 = cmp_ok( nice_string($got), 'eq', nice_string($expecte
d),
+ "nice_string test of $description"
+ );
+ return $ok1 && $ok2;
+}
+
sub create_table
{
my ($dbh,$tdata,$drop) = @_;
|