~stewart/dbd-drizzle/fixup-for-modern-perl

« back to all changes in this revision

Viewing changes to t_old/35limit.t

  • Committer: Patrick
  • Date: 2009-04-20 01:10:02 UTC
  • mfrom: (19.1.6 dbd-drizzle-ng)
  • Revision ID: patg@testpatg.com-20090420011002-yif1wb9jmcwawenn
Pre-release clean-up

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!perl -w
2
 
# vim: ft=perl
3
 
 
4
 
use Test::More;
5
 
use DBI;
6
 
use DBI::Const::GetInfoType;
7
 
use strict;
8
 
$|= 1;
9
 
 
10
 
my $rows = 0;
11
 
my $sth;
12
 
my $testInsertVals;
13
 
use vars qw($table $test_dsn $test_user $test_password);
14
 
use lib 't', '.';
15
 
require 'lib.pl';
16
 
 
17
 
my $dbh;
18
 
eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
19
 
                      { RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
20
 
if ($@) {
21
 
    plan skip_all => "ERROR: $@. Can't continue test";
22
 
}
23
 
plan tests => 111; 
24
 
 
25
 
ok(defined $dbh, "Connected to database");
26
 
 
27
 
ok($dbh->do("DROP TABLE IF EXISTS $table"), "making slate clean");
28
 
 
29
 
ok($dbh->do("CREATE TABLE $table (id INT(4), name VARCHAR(64))"), "creating table");
30
 
 
31
 
ok(($sth = $dbh->prepare("INSERT INTO $table VALUES (?,?)")));
32
 
 
33
 
print "PERL testing insertion of values from previous prepare of insert statement:\n";
34
 
for (my $i = 0 ; $i < 100; $i++) { 
35
 
  my @chars = grep !/[0O1Iil]/, 0..9, 'A'..'Z', 'a'..'z';
36
 
  my $random_chars = join '', map { $chars[rand @chars] } 0 .. 16;
37
 
# save these values for later testing
38
 
  $testInsertVals->{$i} = $random_chars;
39
 
  ok(($rows = $sth->execute($i, $random_chars)));
40
 
}
41
 
print "PERL rows : " . $rows . "\n"; 
42
 
 
43
 
print "PERL testing prepare of select statement with LIMIT placeholders:\n";
44
 
ok($sth = $dbh->prepare("SELECT * FROM $table LIMIT ?, ?"));
45
 
 
46
 
print "PERL testing exec of bind vars for LIMIT\n";
47
 
ok($sth->execute(20, 50));
48
 
 
49
 
my ($row, $errstr, $array_ref);
50
 
ok( (defined($array_ref = $sth->fetchall_arrayref) &&
51
 
  (!defined($errstr = $sth->errstr) || $sth->errstr eq '')));
52
 
 
53
 
ok(@$array_ref == 50);
54
 
 
55
 
ok($sth->finish);
56
 
 
57
 
ok($dbh->do("DROP TABLE $table"));
58
 
 
59
 
ok($dbh->disconnect);