/ Check-in [465c819f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Changes to test scripts so that they work with SQLITE_ENABLE_ICU.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 465c819fdb601961eddb7304642c823d78111992
User & Date: dan 2010-11-01 05:42:26
Context
2010-11-01
05:54
Fix a broken test case in exclusive.test. check-in: 582db832 user: dan tags: trunk
05:42
Changes to test scripts so that they work with SQLITE_ENABLE_ICU. check-in: 465c819f user: dan tags: trunk
2010-10-31
22:47
Fix a test module comment typo reported on the mailing list. check-in: 87eb1f04 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/e_expr.test.

   932    932   #
   933    933   # EVIDENCE-OF: R-04532-11527 The LIKE operator is case sensitive by
   934    934   # default for unicode characters that are beyond the ASCII range.
   935    935   #
   936    936   # EVIDENCE-OF: R-44381-11669 the expression
   937    937   # 'a' LIKE 'A' is TRUE but
   938    938   # 'æ' LIKE 'Æ' is FALSE.
          939  +#
          940  +#   The restriction to ASCII characters does not apply if the ICU
          941  +#   library is compiled in. When ICU is enabled SQLite does not act
          942  +#   as it does "by default".
   939    943   #
   940    944   do_execsql_test e_expr-14.5.1 { SELECT 'A' LIKE 'a'         } 1
   941         -do_execsql_test e_expr-14.5.2 "SELECT '\u00c6' LIKE '\u00e6'" 0
          945  +ifcapable !icu {
          946  +  do_execsql_test e_expr-14.5.2 "SELECT '\u00c6' LIKE '\u00e6'" 0
          947  +}
   942    948   
   943    949   # EVIDENCE-OF: R-56683-13731 If the optional ESCAPE clause is present,
   944    950   # then the expression following the ESCAPE keyword must evaluate to a
   945    951   # string consisting of a single character.
   946    952   #
   947    953   do_catchsql_test e_expr-14.6.1 { 
   948    954     SELECT 'A' LIKE 'a' ESCAPE '12' 
................................................................................
   981    987   # EVIDENCE-OF: R-51359-17496 The infix LIKE operator is implemented by
   982    988   # calling the application-defined SQL functions like(Y,X) or like(Y,X,Z).
   983    989   #
   984    990   proc likefunc {args} {
   985    991     eval lappend ::likeargs $args
   986    992     return 1
   987    993   }
   988         -db func like likefunc
          994  +db func like -argcount 2 likefunc
          995  +db func like -argcount 3 likefunc
   989    996   set ::likeargs [list]
   990    997   do_execsql_test e_expr-15.1.1 { SELECT 'abc' LIKE 'def' } 1
   991    998   do_test         e_expr-15.1.2 { set likeargs } {def abc}
   992    999   set ::likeargs [list]
   993   1000   do_execsql_test e_expr-15.1.3 { SELECT 'abc' LIKE 'def' ESCAPE 'X' } 1
   994   1001   do_test         e_expr-15.1.4 { set likeargs } {def abc X}
   995   1002   db close
................................................................................
  1052   1059   do_test         e_expr-17.3.4 { set globargs } {Y X}
  1053   1060   sqlite3 db test.db
  1054   1061   
  1055   1062   # EVIDENCE-OF: R-41650-20872 No regexp() user function is defined by
  1056   1063   # default and so use of the REGEXP operator will normally result in an
  1057   1064   # error message.
  1058   1065   #
  1059         -do_catchsql_test e_expr-18.1.1 { 
  1060         -  SELECT regexp('abc', 'def') 
  1061         -} {1 {no such function: regexp}}
  1062         -do_catchsql_test e_expr-18.1.2 { 
  1063         -  SELECT 'abc' REGEXP 'def'
  1064         -} {1 {no such function: REGEXP}}
         1066  +#   There is a regexp function if ICU is enabled though.
         1067  +#
         1068  +ifcapable !icu {
         1069  +  do_catchsql_test e_expr-18.1.1 { 
         1070  +    SELECT regexp('abc', 'def') 
         1071  +  } {1 {no such function: regexp}}
         1072  +  do_catchsql_test e_expr-18.1.2 { 
         1073  +    SELECT 'abc' REGEXP 'def'
         1074  +  } {1 {no such function: REGEXP}}
         1075  +}
  1065   1076   
  1066   1077   # EVIDENCE-OF: R-33693-50180 The REGEXP operator is a special syntax for
  1067   1078   # the regexp() user function.
  1068   1079   #
  1069   1080   # EVIDENCE-OF: R-57289-13578 If a application-defined SQL function named
  1070   1081   # "regexp" is added at run-time, that function will be called in order
  1071   1082   # to implement the REGEXP operator.

Changes to test/like.test.

   111    111   
   112    112   # Tests of the REGEXP operator
   113    113   #
   114    114   do_test like-2.1 {
   115    115     proc test_regexp {a b} {
   116    116       return [regexp $a $b]
   117    117     }
   118         -  db function regexp test_regexp
          118  +  db function regexp -argcount 2 test_regexp
   119    119     execsql {
   120    120       SELECT x FROM t1 WHERE x REGEXP 'abc' ORDER BY 1;
   121    121     }
   122    122   } {{ABC abc xyz} abc abcd}
   123    123   do_test like-2.2 {
   124    124     execsql {
   125    125       SELECT x FROM t1 WHERE x REGEXP '^abc' ORDER BY 1;
................................................................................
   604    604     db eval {
   605    605       SELECT 1, x FROM t8 WHERE x LIKE '%h%';
   606    606       SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
   607    607     }
   608    608   } {1 abcdef 1 ghijkl 1 mnopqr 2 abcdef 2 ghijkl 2 mnopqr}
   609    609   
   610    610   
   611         -ifcapable like_opt {
          611  +ifcapable like_opt&&!icu {
   612    612     # Evaluate SQL.  Return the result set followed by the
   613    613     # and the number of full-scan steps.
   614    614     #
   615    615     db close
   616    616     sqlite3 db test.db
   617    617     proc count_steps {sql} {
   618    618       set r [db eval $sql]
................................................................................
   669    669       do_test like-9.5.2 {
   670    670         set res [sqlite3_exec_hex db {
   671    671            EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25'
   672    672         }]
   673    673         regexp {INDEX i2} $res
   674    674       } {1}
   675    675     }
   676         -}
   677    676   
   678         -# Do an SQL statement.  Append the search count to the end of the result.
   679         -#
   680         -proc count sql {
   681         -  set ::sqlite_search_count 0
   682         -  set ::sqlite_like_count 0
   683         -  return [concat [execsql $sql] scan $::sqlite_search_count \
   684         -           like $::sqlite_like_count]
   685         -}
          677  +  # Do an SQL statement.  Append the search count to the end of the result.
          678  +  #
          679  +  proc count sql {
          680  +    set ::sqlite_search_count 0
          681  +    set ::sqlite_like_count 0
          682  +    return [concat [execsql $sql] scan $::sqlite_search_count \
          683  +             like $::sqlite_like_count]
          684  +  }
   686    685   
   687         -# The LIKE and GLOB optimizations do not work on columns with
   688         -# affinity other than TEXT.
   689         -# Ticket #3901
   690         -#
   691         -do_test like-10.1 {
   692         -  db close
   693         -  sqlite3 db test.db
   694         -  execsql {
   695         -    CREATE TABLE t10(
   696         -      a INTEGER PRIMARY KEY,
   697         -      b INTEGER COLLATE nocase UNIQUE,
   698         -      c NUMBER COLLATE nocase UNIQUE,
   699         -      d BLOB COLLATE nocase UNIQUE,
   700         -      e COLLATE nocase UNIQUE,
   701         -      f TEXT COLLATE nocase UNIQUE
   702         -    );
   703         -    INSERT INTO t10 VALUES(1,1,1,1,1,1);
   704         -    INSERT INTO t10 VALUES(12,12,12,12,12,12);
   705         -    INSERT INTO t10 VALUES(123,123,123,123,123,123);
   706         -    INSERT INTO t10 VALUES(234,234,234,234,234,234);
   707         -    INSERT INTO t10 VALUES(345,345,345,345,345,345);
   708         -    INSERT INTO t10 VALUES(45,45,45,45,45,45);
   709         -  }
   710         -  count {
   711         -    SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY a;
   712         -  }
   713         -} {12 123 scan 5 like 6}
   714         -do_test like-10.2 {
   715         -  count {
   716         -    SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY a;
   717         -  }
   718         -} {12 123 scan 5 like 6}
   719         -do_test like-10.3 {
   720         -  count {
   721         -    SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY a;
   722         -  }
   723         -} {12 123 scan 5 like 6}
   724         -do_test like-10.4 {
   725         -  count {
   726         -    SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY a;
   727         -  }
   728         -} {12 123 scan 5 like 6}
   729         -do_test like-10.5 {
   730         -  count {
   731         -    SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY a;
   732         -  }
   733         -} {12 123 scan 3 like 0}
   734         -do_test like-10.6 {
   735         -  count {
   736         -    SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY a;
   737         -  }
   738         -} {12 123 scan 5 like 6}
   739         -do_test like-10.10 {
   740         -  execsql {
   741         -    CREATE TABLE t10b(
   742         -      a INTEGER PRIMARY KEY,
   743         -      b INTEGER UNIQUE,
   744         -      c NUMBER UNIQUE,
   745         -      d BLOB UNIQUE,
   746         -      e UNIQUE,
   747         -      f TEXT UNIQUE
   748         -    );
   749         -    INSERT INTO t10b SELECT * FROM t10;
   750         -  }
   751         -  count {
   752         -    SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY a;
   753         -  }
   754         -} {12 123 scan 5 like 6}
   755         -do_test like-10.11 {
   756         -  count {
   757         -    SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY a;
   758         -  }
   759         -} {12 123 scan 5 like 6}
   760         -do_test like-10.12 {
   761         -  count {
   762         -    SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY a;
   763         -  }
   764         -} {12 123 scan 5 like 6}
   765         -do_test like-10.13 {
   766         -  count {
   767         -    SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY a;
   768         -  }
   769         -} {12 123 scan 5 like 6}
   770         -do_test like-10.14 {
   771         -  count {
   772         -    SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY a;
   773         -  }
   774         -} {12 123 scan 3 like 0}
   775         -do_test like-10.15 {
   776         -  count {
   777         -    SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY a;
   778         -  }
   779         -} {12 123 scan 5 like 6}
          686  +  # The LIKE and GLOB optimizations do not work on columns with
          687  +  # affinity other than TEXT.
          688  +  # Ticket #3901
          689  +  #
          690  +  do_test like-10.1 {
          691  +    db close
          692  +    sqlite3 db test.db
          693  +    execsql {
          694  +      CREATE TABLE t10(
          695  +        a INTEGER PRIMARY KEY,
          696  +        b INTEGER COLLATE nocase UNIQUE,
          697  +        c NUMBER COLLATE nocase UNIQUE,
          698  +        d BLOB COLLATE nocase UNIQUE,
          699  +        e COLLATE nocase UNIQUE,
          700  +        f TEXT COLLATE nocase UNIQUE
          701  +      );
          702  +      INSERT INTO t10 VALUES(1,1,1,1,1,1);
          703  +      INSERT INTO t10 VALUES(12,12,12,12,12,12);
          704  +      INSERT INTO t10 VALUES(123,123,123,123,123,123);
          705  +      INSERT INTO t10 VALUES(234,234,234,234,234,234);
          706  +      INSERT INTO t10 VALUES(345,345,345,345,345,345);
          707  +      INSERT INTO t10 VALUES(45,45,45,45,45,45);
          708  +    }
          709  +    count {
          710  +      SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY a;
          711  +    }
          712  +  } {12 123 scan 5 like 6}
          713  +  do_test like-10.2 {
          714  +    count {
          715  +      SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY a;
          716  +    }
          717  +  } {12 123 scan 5 like 6}
          718  +  do_test like-10.3 {
          719  +    count {
          720  +      SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY a;
          721  +    }
          722  +  } {12 123 scan 5 like 6}
          723  +  do_test like-10.4 {
          724  +    count {
          725  +      SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY a;
          726  +    }
          727  +  } {12 123 scan 5 like 6}
          728  +  do_test like-10.5 {
          729  +    count {
          730  +      SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY a;
          731  +    }
          732  +  } {12 123 scan 3 like 0}
          733  +  do_test like-10.6 {
          734  +    count {
          735  +      SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY a;
          736  +    }
          737  +  } {12 123 scan 5 like 6}
          738  +  do_test like-10.10 {
          739  +    execsql {
          740  +      CREATE TABLE t10b(
          741  +        a INTEGER PRIMARY KEY,
          742  +        b INTEGER UNIQUE,
          743  +        c NUMBER UNIQUE,
          744  +        d BLOB UNIQUE,
          745  +        e UNIQUE,
          746  +        f TEXT UNIQUE
          747  +      );
          748  +      INSERT INTO t10b SELECT * FROM t10;
          749  +    }
          750  +    count {
          751  +      SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY a;
          752  +    }
          753  +  } {12 123 scan 5 like 6}
          754  +  do_test like-10.11 {
          755  +    count {
          756  +      SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY a;
          757  +    }
          758  +  } {12 123 scan 5 like 6}
          759  +  do_test like-10.12 {
          760  +    count {
          761  +      SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY a;
          762  +    }
          763  +  } {12 123 scan 5 like 6}
          764  +  do_test like-10.13 {
          765  +    count {
          766  +      SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY a;
          767  +    }
          768  +  } {12 123 scan 5 like 6}
          769  +  do_test like-10.14 {
          770  +    count {
          771  +      SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY a;
          772  +    }
          773  +  } {12 123 scan 3 like 0}
          774  +  do_test like-10.15 {
          775  +    count {
          776  +      SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY a;
          777  +    }
          778  +  } {12 123 scan 5 like 6}
          779  +}
   780    780   
   781    781   # LIKE and GLOB where the default collating sequence is not appropriate
   782    782   # but an index with the appropriate collating sequence exists.
   783    783   #
   784    784   do_test like-11.0 {
   785    785     execsql {
   786    786       CREATE TABLE t11(