mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-08 06:38:12 -04:00
compare perl_match and db_match
This commit is contained in:
parent
8a50806e17
commit
c716e6b56a
1 changed files with 6 additions and 12 deletions
|
@ -12,9 +12,6 @@ BEGIN {
|
||||||
if ($] < 5.008005) {
|
if ($] < 5.008005) {
|
||||||
plan skip_all => 'Unicode is not supported before 5.8.5';
|
plan skip_all => 'Unicode is not supported before 5.8.5';
|
||||||
}
|
}
|
||||||
if (!eval "require Encode; 1") {
|
|
||||||
plan skip_all => 'requires Encode for this test';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
use Test::NoWarnings;
|
use Test::NoWarnings;
|
||||||
|
|
||||||
|
@ -37,9 +34,10 @@ foreach my $call_func (@CALL_FUNCS) {
|
||||||
my @vals = @words;
|
my @vals = @words;
|
||||||
my $re = $regex;
|
my $re = $regex;
|
||||||
if ($use_unicode) {
|
if ($use_unicode) {
|
||||||
@vals = map {Encode::decode_utf8($_)} @vals;
|
utf8::decode($_) foreach @vals;
|
||||||
$re = Encode::decode_utf8($re);
|
utf8::decode($re);
|
||||||
}
|
}
|
||||||
|
my @perl_match = grep {$_ =~ /$re/} @vals;
|
||||||
|
|
||||||
$dbh->do( 'CREATE TEMP TABLE regexp_test ( txt )' );
|
$dbh->do( 'CREATE TEMP TABLE regexp_test ( txt )' );
|
||||||
$dbh->do( "INSERT INTO regexp_test VALUES ( '$_' )" ) foreach @vals;
|
$dbh->do( "INSERT INTO regexp_test VALUES ( '$_' )" ) foreach @vals;
|
||||||
|
@ -47,13 +45,9 @@ foreach my $call_func (@CALL_FUNCS) {
|
||||||
my $sql = "SELECT txt from regexp_test WHERE txt REGEXP '$re' ";
|
my $sql = "SELECT txt from regexp_test WHERE txt REGEXP '$re' ";
|
||||||
my $db_match = $dbh->selectcol_arrayref($sql);
|
my $db_match = $dbh->selectcol_arrayref($sql);
|
||||||
|
|
||||||
if ($use_unicode) {
|
is_deeply \@perl_match => $db_match;
|
||||||
is @$db_match => 2;
|
note explain \@perl_match;
|
||||||
note explain $db_match;
|
note explain $db_match;
|
||||||
} else {
|
|
||||||
is @$db_match => 0;
|
|
||||||
note explain $db_match;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue