From 485b97be9f2f2abf5a40923b5fd85f75714a8c02 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Mon, 24 Sep 2012 10:15:50 +0000 Subject: Imported from /srv/lorry/lorry-area/perl-dbd-sqlite-tarball/DBD-SQLite-1.38_01.tar.gz. --- t/22_listfields.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 t/22_listfields.t (limited to 't/22_listfields.t') diff --git a/t/22_listfields.t b/t/22_listfields.t new file mode 100644 index 0000000..b20e930 --- /dev/null +++ b/t/22_listfields.t @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# This is a test for statement attributes being present appropriately. + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test; +use Test::More tests => 12; +use Test::NoWarnings; + +# Create a database +my $dbh = connect_ok(); + +# Create the table +ok( $dbh->do(<<'END_SQL'), 'CREATE TABLE' ); +CREATE TABLE one ( + id INTEGER NOT NULL, + name CHAR (64) +) +END_SQL + +SCOPE: { + # Create the statement + my $sth = $dbh->prepare('SELECT * from one'); + isa_ok( $sth, 'DBI::st' ); + + # Execute the statement + ok( $sth->execute, '->execute' ); + + # Check the field metadata + is( $sth->{NUM_OF_FIELDS}, 2, 'Found 2 fields' ); + is_deeply( $sth->{NAME}, [ 'id', 'name' ], 'Names are ok' ); + ok( $sth->finish, '->finish ok' ); +} + +SCOPE: { + # Check field metadata on a drop statement + my $sth = $dbh->prepare('DROP TABLE one'); + isa_ok( $sth, 'DBI::st' ); + ok( $sth->execute, '->execute' ); + is( $sth->{NUM_OF_FIELDS}, 0, 'No fields in statement' ); + ok( $sth->finish, '->finish ok' ); +} -- cgit v1.2.1