1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00
DBD-SQLite-SQLcipher/t/rt_96877_unicode_statements.t
Peter Rabbitson c4eab85ff7 Workaround for upcoming lack of dot in @INC ( RT#120444, sigh )
Zero functional changes, simply executed the following:

find . -name '*.t' -exec perl -0777 -p -i -e 's|^use t::lib::SQLiteTest|use lib "t/lib";\nuse SQLiteTest|m' {} +

Also had to do a manual (but identical) fix in t/01_compile.t
2017-05-05 00:48:33 +02:00

41 lines
1 KiB
Perl

#!/usr/bin/perl
# According to the sqlite doc, the SQL argument to sqlite3_prepare_v2
# should be in utf8, but DBD::SQLite does not ensure this (even with
# sqlite_unicode => 1). Only bind values are properly converted.
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
use lib "t/lib";
use SQLiteTest;
use Test::More;
BEGIN {
if ( $] >= 5.008005 ) {
plan( tests => 16 );
} else {
plan( skip_all => 'Unicode is not supported before 5.8.5' );
}
}
use Test::NoWarnings;
my $dbh = connect_ok( sqlite_unicode => 1 );
is( $dbh->{sqlite_unicode}, 1, 'Unicode is on' );
ok( $dbh->do(<<'END_SQL'), 'CREATE TABLE' );
CREATE TABLE foo (
bar varchar(255)
)
END_SQL
foreach ( "A", "\xe9", "\x{20ac}" ) {
note sprintf "testing \\x{%x}", ord($_);
ok( $dbh->do("INSERT INTO foo VALUES ( ? )", {}, $_), 'INSERT with bind' );
ok( $dbh->do("INSERT INTO foo VALUES ( '$_' )"), 'INSERT without bind' );
my $vals = $dbh->selectcol_arrayref("SELECT bar FROM foo");
is $vals->[0], $vals->[1], "both values are equal";
ok( $dbh->do("DELETE FROM foo"), 'DELETE ok' );
}