os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/icu.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/icu.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,117 @@
     1.4 +# 2007 May 1
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.  In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +#
    1.15 +# $Id: icu.test,v 1.2 2008/07/12 14:52:20 drh Exp $
    1.16 +#
    1.17 +
    1.18 +set testdir [file dirname $argv0]
    1.19 +source $testdir/tester.tcl
    1.20 +
    1.21 +ifcapable !icu {
    1.22 +  finish_test
    1.23 +  return
    1.24 +}
    1.25 +
    1.26 +# Create a table to work with.
    1.27 +#
    1.28 +execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
    1.29 +execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
    1.30 +proc test_expr {name settings expr result} {
    1.31 +  do_test $name [format {
    1.32 +    db one {
    1.33 +      BEGIN; 
    1.34 +      UPDATE test1 SET %s; 
    1.35 +      SELECT %s FROM test1; 
    1.36 +      ROLLBACK;
    1.37 +    }
    1.38 +  } $settings $expr] $result
    1.39 +}
    1.40 +
    1.41 +# Tests of the REGEXP operator.
    1.42 +#
    1.43 +test_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'}  1
    1.44 +test_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'}  1
    1.45 +test_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'}   0
    1.46 +test_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1
    1.47 +test_expr icu-1.5 {i1=NULL}    {i1 REGEXP '.ell.*'} {}
    1.48 +
    1.49 +# Some non-ascii characters with defined case mappings
    1.50 +#
    1.51 +set ::EGRAVE "\xC8"
    1.52 +set ::egrave "\xE8"
    1.53 +
    1.54 +set ::OGRAVE "\xD2"
    1.55 +set ::ograve "\xF2"
    1.56 +
    1.57 +# That German letter that looks a bit like a B. The
    1.58 +# upper-case version of which is "SS" (two characters).
    1.59 +#
    1.60 +set ::szlig "\xDF" 
    1.61 +
    1.62 +# Tests of the upper()/lower() functions.
    1.63 +#
    1.64 +test_expr icu-2.1 {i1='HellO WorlD'} {upper(i1)} {HELLO WORLD}
    1.65 +test_expr icu-2.2 {i1='HellO WorlD'} {lower(i1)} {hello world}
    1.66 +test_expr icu-2.3 {i1=$::egrave} {lower(i1)}     $::egrave
    1.67 +test_expr icu-2.4 {i1=$::egrave} {upper(i1)}     $::EGRAVE
    1.68 +test_expr icu-2.5 {i1=$::ograve} {lower(i1)}     $::ograve
    1.69 +test_expr icu-2.6 {i1=$::ograve} {upper(i1)}     $::OGRAVE
    1.70 +test_expr icu-2.3 {i1=$::EGRAVE} {lower(i1)}     $::egrave
    1.71 +test_expr icu-2.4 {i1=$::EGRAVE} {upper(i1)}     $::EGRAVE
    1.72 +test_expr icu-2.5 {i1=$::OGRAVE} {lower(i1)}     $::ograve
    1.73 +test_expr icu-2.6 {i1=$::OGRAVE} {upper(i1)}     $::OGRAVE
    1.74 +
    1.75 +test_expr icu-2.7 {i1=$::szlig} {upper(i1)}      "SS"
    1.76 +test_expr icu-2.8 {i1='SS'} {lower(i1)}          "ss"
    1.77 +
    1.78 +# In turkish (locale="tr_TR"), the lower case version of I
    1.79 +# is "small dotless i" (code point 0x131 (decimal 305)).
    1.80 +#
    1.81 +set ::small_dotless_i "\u0131"
    1.82 +test_expr icu-3.1 {i1='I'} {lower(i1)}           "i"
    1.83 +test_expr icu-3.2 {i1='I'} {lower(i1, 'tr_tr')}  $::small_dotless_i
    1.84 +test_expr icu-3.3 {i1='I'} {lower(i1, 'en_AU')}  "i"
    1.85 +
    1.86 +#--------------------------------------------------------------------
    1.87 +# Test the collation sequence function.
    1.88 +#
    1.89 +do_test icu-4.1 {
    1.90 +  execsql {
    1.91 +    CREATE TABLE fruit(name);
    1.92 +    INSERT INTO fruit VALUES('plum');
    1.93 +    INSERT INTO fruit VALUES('cherry');
    1.94 +    INSERT INTO fruit VALUES('apricot');
    1.95 +    INSERT INTO fruit VALUES('peach');
    1.96 +    INSERT INTO fruit VALUES('chokecherry');
    1.97 +    INSERT INTO fruit VALUES('yamot');
    1.98 +  }
    1.99 +} {}
   1.100 +do_test icu-4.2 {
   1.101 +  execsql {
   1.102 +    SELECT icu_load_collation('en_US', 'AmericanEnglish');
   1.103 +    SELECT icu_load_collation('lt_LT', 'Lithuanian');
   1.104 +  }
   1.105 +  execsql {
   1.106 +    SELECT name FROM fruit ORDER BY name COLLATE AmericanEnglish ASC;
   1.107 +  }
   1.108 +} {apricot cherry chokecherry peach plum yamot}
   1.109 +
   1.110 +
   1.111 +# Test collation using Lithuanian rules. In the Lithuanian
   1.112 +# alphabet, "y" comes right after "i".
   1.113 +#
   1.114 +do_test icu-4.3 {
   1.115 +  execsql {
   1.116 +    SELECT name FROM fruit ORDER BY name COLLATE Lithuanian ASC;
   1.117 +  }
   1.118 +} {apricot cherry chokecherry yamot peach plum}
   1.119 +
   1.120 +finish_test