comparison DBD/t/07q.t @ 0:cedccb7e0143

Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
author Sjoerd Mullender <sjoerd@acm.org>
date Mon, 19 Sep 2016 15:15:52 +0200 (2016-09-19)
parents
children a0ec9e080a5b
comparison
equal deleted inserted replaced
-1:000000000000 0:cedccb7e0143
1 #!perl -I./t
2
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 #
7 # Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
8
9 $| = 1;
10
11 use strict;
12 use warnings;
13 use DBI();
14 use DBD_TEST();
15
16 use Test::More;
17
18 if ( defined $ENV{DBI_DSN} ) {
19 plan tests => 12;
20 } else {
21 plan skip_all => 'Cannot test without DB info';
22 }
23
24 pass('Quote tests');
25
26 my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n";
27 $dbh->{RaiseError} = 1;
28 $dbh->{PrintError} = 0;
29 pass('Database connection created');
30
31 eval { $dbh->quote };
32 ok( $@,"Call to quote() with 0 arguments, error expected: $@");
33
34 my $val =
35 [
36 [ 1 , q{'1'} ]
37 , [ 2 , q{'2'} ]
38 , [ undef , 'NULL' ]
39 , ['NULL' , q{'NULL'} ]
40 , ['ThisIsAString' , q{'ThisIsAString'} ]
41 , ['This is Another String', q{'This is Another String'} ]
42 , ["This isn't unusual" , q{'This isn''t unusual'} ]
43 ];
44 for ( @$val ) {
45 my $val0 = $_->[0];
46 my $val1 = defined $val0 ? $val0 : 'undef';
47 my $val2 = $dbh->quote( $val0 );
48 is( $val2, $_->[1],"quote on $val1 returned $val2");
49 }
50
51 my $ti = DBD_TEST::get_type_for_column( $dbh,'A');
52 is( $dbh->quote( 1, $ti->{DATA_TYPE} ), 1,"quote( 1, $ti->{DATA_TYPE} )");
53
54 ok( $dbh->disconnect,'Disconnect');