| OLD | NEW |
| 1 # 2007 May 1 | 1 # 2007 May 1 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| 11 # | 11 # |
| 12 # $Id: icu.test,v 1.2 2008/07/12 14:52:20 drh Exp $ | 12 # $Id: icu.test,v 1.2 2008/07/12 14:52:20 drh Exp $ |
| 13 # | 13 # |
| 14 | 14 |
| 15 set testdir [file dirname $argv0] | 15 set testdir [file dirname $argv0] |
| 16 source $testdir/tester.tcl | 16 source $testdir/tester.tcl |
| 17 | 17 |
| 18 ifcapable !icu { | 18 ifcapable !icu { |
| 19 finish_test | 19 finish_test |
| 20 return | 20 return |
| 21 } | 21 } |
| 22 | 22 |
| 23 # Create a table to work with. | 23 # Create a table to work with. |
| 24 # | 24 # |
| 25 execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)} | 25 execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)} |
| 26 execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')} | 26 execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')} |
| 27 proc test_expr {name settings expr result} { | 27 proc test_expr {name settings expr result} { |
| 28 do_test $name [format { | 28 do_test $name [format { |
| 29 db one { | 29 lindex [db eval { |
| 30 BEGIN; | 30 BEGIN; |
| 31 UPDATE test1 SET %s; | 31 UPDATE test1 SET %s; |
| 32 SELECT %s FROM test1; | 32 SELECT %s FROM test1; |
| 33 ROLLBACK; | 33 ROLLBACK; |
| 34 } | 34 }] 0 |
| 35 } $settings $expr] $result | 35 } $settings $expr] $result |
| 36 } | 36 } |
| 37 | 37 |
| 38 # Tests of the REGEXP operator. | 38 # Tests of the REGEXP operator. |
| 39 # | 39 # |
| 40 test_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'} 1 | 40 test_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'} 1 |
| 41 test_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'} 1 | 41 test_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'} 1 |
| 42 test_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'} 0 | 42 test_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'} 0 |
| 43 test_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1 | 43 test_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1 |
| 44 test_expr icu-1.5 {i1=NULL} {i1 REGEXP '.ell.*'} {} | 44 test_expr icu-1.5 {i1=NULL} {i1 REGEXP '.ell.*'} {} |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 # Test collation using Lithuanian rules. In the Lithuanian | 108 # Test collation using Lithuanian rules. In the Lithuanian |
| 109 # alphabet, "y" comes right after "i". | 109 # alphabet, "y" comes right after "i". |
| 110 # | 110 # |
| 111 do_test icu-4.3 { | 111 do_test icu-4.3 { |
| 112 execsql { | 112 execsql { |
| 113 SELECT name FROM fruit ORDER BY name COLLATE Lithuanian ASC; | 113 SELECT name FROM fruit ORDER BY name COLLATE Lithuanian ASC; |
| 114 } | 114 } |
| 115 } {apricot cherry chokecherry yamot peach plum} | 115 } {apricot cherry chokecherry yamot peach plum} |
| 116 | 116 |
| 117 #------------------------------------------------------------------------- |
| 118 # Test that it is not possible to call the ICU regex() function with |
| 119 # anything other than exactly two arguments. See also: |
| 120 # |
| 121 # http://src.chromium.org/viewvc/chrome/trunk/src/third_party/sqlite/icu-regex
p.patch?revision=34807&view=markup |
| 122 # |
| 123 do_catchsql_test icu-5.1 { SELECT regexp('a[abc]c.*', 'abc') } {0 1} |
| 124 do_catchsql_test icu-5.2 { |
| 125 SELECT regexp('a[abc]c.*') |
| 126 } {1 {wrong number of arguments to function regexp()}} |
| 127 do_catchsql_test icu-5.3 { |
| 128 SELECT regexp('a[abc]c.*', 'abc', 'c') |
| 129 } {1 {wrong number of arguments to function regexp()}} |
| 130 do_catchsql_test icu-5.4 { |
| 131 SELECT 'abc' REGEXP 'a[abc]c.*' |
| 132 } {0 1} |
| 133 do_catchsql_test icu-5.4 { SELECT 'abc' REGEXP } {1 {near " ": syntax error}} |
| 134 do_catchsql_test icu-5.5 { SELECT 'abc' REGEXP, 1 } {1 {near ",": syntax error}} |
| 135 |
| 117 finish_test | 136 finish_test |
| OLD | NEW |