File: 11_get_info.t

package info (click to toggle)
libdbd-sqlite3-perl 1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,004 kB
  • sloc: ansic: 167,715; perl: 1,788; pascal: 277; makefile: 9
file content (49 lines) | stat: -rw-r--r-- 1,380 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use Test::More;
use if -d ".git", "Test::FailWarnings";

use DBI::Const::GetInfoType;

# NOTE: These are tests for just a very basic set of get_info variables.

my %info = (
    SQL_CATALOG_LOCATION       => 1,
    SQL_CATALOG_NAME           => 'Y',
    SQL_CATALOG_NAME_SEPARATOR => '.',
    SQL_CATALOG_TERM           => 'database',

    # some of these are dynamic, but always the same for connect_ok
    SQL_DATA_SOURCE_NAME       => qr/^dbi:SQLite:dbname=/,
    SQL_DATA_SOURCE_READ_ONLY  => 'N',
    SQL_DATABASE_NAME          => 'main',
    SQL_DBMS_NAME              => 'SQLite',
    SQL_DBMS_VER               => qr/^[1-9]+\.\d+\.\d+$/,

    SQL_IDENTIFIER_QUOTE_CHAR  => '"',

    SQL_MAX_IDENTIFIER_LEN     => qr/^[1-9]\d+$/,
    SQL_MAX_TABLE_NAME_LEN     => qr/^[1-9]\d+$/,

    SQL_KEYWORDS               => qr/^(?:\w+,)+\w+$/,

    SQL_SEARCH_PATTERN_ESCAPE  => '\\',
    SQL_SERVER_NAME            => qr/^dbname=/,

    SQL_TABLE_TERM             => 'table',
);

my $dbh = connect_ok( RaiseError => 1 );

foreach my $option ( sort keys %info ) {
    my $value = $dbh->get_info( $GetInfoType{$option} );
    my $check = $info{$option};
    if (ref $check eq 'Regexp') { like($value, $check, $option); }
    else                        { is  ($value, $check, $option); }
}

$dbh->disconnect;

done_testing;