mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
Fix to use string_mode
This commit is contained in:
parent
31483a245f
commit
1dc2e1dbe2
1 changed files with 4 additions and 4 deletions
|
@ -101,21 +101,21 @@ for my $string_mode (DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES, DBD::
|
||||||
# the 'snippet' function should highlight the words in the MATCH query
|
# the 'snippet' function should highlight the words in the MATCH query
|
||||||
my $sql_snip = "SELECT snippet(try_$fts) FROM try_$fts WHERE content MATCH ?";
|
my $sql_snip = "SELECT snippet(try_$fts) FROM try_$fts WHERE content MATCH ?";
|
||||||
my $result = $dbh->selectcol_arrayref($sql_snip, undef, 'une');
|
my $result = $dbh->selectcol_arrayref($sql_snip, undef, 'une');
|
||||||
is_deeply($result, ['il était <b>une</b> bergère'], "snippet ($fts, unicode=$use_unicode)");
|
is_deeply($result, ['il était <b>une</b> bergère'], "snippet ($fts, string_mode=$string_mode)");
|
||||||
|
|
||||||
# the 'offsets' function should return integer offsets for the words in the MATCH query
|
# the 'offsets' function should return integer offsets for the words in the MATCH query
|
||||||
my $sql_offsets = "SELECT offsets(try_$fts) FROM try_$fts WHERE content MATCH ?";
|
my $sql_offsets = "SELECT offsets(try_$fts) FROM try_$fts WHERE content MATCH ?";
|
||||||
$result = $dbh->selectcol_arrayref($sql_offsets, undef, 'une');
|
$result = $dbh->selectcol_arrayref($sql_offsets, undef, 'une');
|
||||||
my $offset_une = $use_unicode ? $ix_une_utf8 : $ix_une_native;
|
my $offset_une = $string_mode == DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT ? $ix_une_utf8 : $ix_une_native;
|
||||||
my $expected_offsets = "0 0 $offset_une 3";
|
my $expected_offsets = "0 0 $offset_une 3";
|
||||||
is_deeply($result, [$expected_offsets], "offsets ($fts, unicode=$use_unicode)");
|
is_deeply($result, [$expected_offsets], "offsets ($fts, string_mode=$string_mode)");
|
||||||
|
|
||||||
# test snippet() on a longer sentence
|
# test snippet() on a longer sentence
|
||||||
$insert_sth->execute(join " ", @texts);
|
$insert_sth->execute(join " ", @texts);
|
||||||
$result = $dbh->selectcol_arrayref($sql_snip, undef, '"bergère qui gardait"');
|
$result = $dbh->selectcol_arrayref($sql_snip, undef, '"bergère qui gardait"');
|
||||||
like($result->[0],
|
like($result->[0],
|
||||||
qr[une <b>bergère</b> <b>qui</b> <b>gardait</b> ses],
|
qr[une <b>bergère</b> <b>qui</b> <b>gardait</b> ses],
|
||||||
"longer snippet ($fts, unicode=$use_unicode)");
|
"longer snippet ($fts, string_mode=$string_mode)");
|
||||||
|
|
||||||
# simulated large document
|
# simulated large document
|
||||||
open my $fh, "<", $INC{'DBD/SQLite.pm'} or die $!;
|
open my $fh, "<", $INC{'DBD/SQLite.pm'} or die $!;
|
||||||
|
|
Loading…
Add table
Reference in a new issue