diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-09-24 10:15:50 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-26 13:46:46 +0000 |
commit | 485b97be9f2f2abf5a40923b5fd85f75714a8c02 (patch) | |
tree | ca05cb0ecf3828d909a898c3e5805804a0aff5f8 /t/rt_53235_icu_compatibility.t | |
download | perl-dbd-sqlite-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/perl-dbd-sqlite-tarball/DBD-SQLite-1.38_01.tar.gz.HEADDBD-SQLite-1.38_01masterbaserock/morph
Diffstat (limited to 't/rt_53235_icu_compatibility.t')
-rw-r--r-- | t/rt_53235_icu_compatibility.t | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/t/rt_53235_icu_compatibility.t b/t/rt_53235_icu_compatibility.t new file mode 100644 index 0000000..ccec7a6 --- /dev/null +++ b/t/rt_53235_icu_compatibility.t @@ -0,0 +1,96 @@ +#!/usr/bin/perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test; +use Test::More; +BEGIN { + require DBD::SQLite; + if (DBD::SQLite->can('compile_options') + && grep /ENABLE_ICU/, DBD::SQLite::compile_options()) { + plan( tests => 16 ); + } else { + plan( skip_all => 'requires SQLite ICU plugin to be enabled' ); + } +} +# use Test::NoWarnings; + +my @isochars = (ord("K"), 0xf6, ord("n"), ord("i"), ord("g")); +my $koenig = pack("U*", @isochars); +my $konig = 'konig'; +utf8::encode($koenig); + +{ # without ICU + my @expected = ($koenig, $konig); + + my $dbh = connect_ok(); + $dbh->do('create table foo (bar text)'); + foreach my $str (reverse @expected) { + $dbh->do('insert into foo values(?)', undef, $str); + } + my $sth = $dbh->prepare('select bar from foo order by bar'); + $sth->execute; + my @got; + while(my ($value) = $sth->fetchrow_array) { + push @got, $value; + } + for (my $i = 0; $i < @expected; $i++) { + is $got[$i] => $expected[$i], "got: $got[$i]"; + } +} + +{ # with ICU + my @expected = ($konig, $koenig); + + my $dbh = connect_ok(); + eval { $dbh->do('select icu_load_collation("de_DE", "german")') }; + ok !$@, "installed icu collation"; + # XXX: as of this writing, a warning is known to be printed. + $dbh->do('create table foo (bar text collate german)'); + foreach my $str (reverse @expected) { + $dbh->do('insert into foo values(?)', undef, $str); + } + my $sth = $dbh->prepare('select bar from foo order by bar'); + $sth->execute; + my @got; + while(my ($value) = $sth->fetchrow_array) { + push @got, $value; + } + for (my $i = 0; $i < @expected; $i++) { + is $got[$i] => $expected[$i], "got: $got[$i]"; + } +} + +{ # more ICU + my @expected = qw( + flusse + Flusse + fluße + Fluße + flüsse + flüße + Fuße + ); + + my $dbh = connect_ok(); + eval { $dbh->do('select icu_load_collation("de_DE", "german")') }; + ok !$@, "installed icu collation"; + # XXX: as of this writing, a warning is known to be printed. + $dbh->do('create table foo (bar text collate german)'); + foreach my $str (reverse @expected) { + $dbh->do('insert into foo values(?)', undef, $str); + } + my $sth = $dbh->prepare('select bar from foo order by bar'); + $sth->execute; + my @got; + while(my ($value) = $sth->fetchrow_array) { + push @got, $value; + } + for (my $i = 0; $i < @expected; $i++) { + is $got[$i] => $expected[$i], "got: $got[$i]"; + } +} |