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/69_unicode_no_invalid_utf8.t
2021-05-28 22:28:27 -04:00

49 lines
1,004 B
Perl

# This is a test for correct handling of upgraded strings without
# the sqlite_unicode parameter.
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use Test::More;
use if -d ".git", "Test::FailWarnings";
{
my $dbh = connect_ok(
dbfile => 'foo',
RaiseError => 1,
);
my $tbl_name = "\xe9p\xe9e";
my $str = "CREATE TABLE $tbl_name ( col1 TEXT )";
$dbh->do($str);
$dbh->{'sqlite_unicode'} = 1;
my @warnings;
my $master_ar = do {
local $SIG{'__WARN__'} = sub { push @warnings, @_ };
$dbh->selectall_arrayref('SELECT * FROM sqlite_master', { Slice => {} });
};
for my $key ( sort keys %{ $master_ar->[0] } ) {
ok(
utf8::valid($master_ar->[0]{$key}),
"$key is utf8::valid",
);
}
is(
$master_ar->[0]{'name'},
$tbl_name,
'`name`',
);
like(
$warnings[0],
qr<UTF-8>,
'warning about invalid UTF-8',
);
}
done_testing;