Annotation of embedaddon/sqlite3/test/fts3ai.test, revision 1.1.1.1

1.1       misho       1: # 2007 January 17
                      2: #
                      3: # The author disclaims copyright to this source code.
                      4: #
                      5: #*************************************************************************
                      6: # This file implements regression tests for SQLite fts3 library.  The
                      7: # focus here is testing handling of UPDATE when using UTF-16-encoded
                      8: # databases.
                      9: #
                     10: # $Id: fts3ai.test,v 1.1 2007/08/20 17:38:42 shess Exp $
                     11: #
                     12: 
                     13: set testdir [file dirname $argv0]
                     14: source $testdir/tester.tcl
                     15: 
                     16: # If SQLITE_ENABLE_FTS3 is defined, omit this file.
                     17: ifcapable !fts3 {
                     18:   finish_test
                     19:   return
                     20: }
                     21: 
                     22: # Return the UTF-16 representation of the supplied UTF-8 string $str.
                     23: # If $nt is true, append two 0x00 bytes as a nul terminator.
                     24: # NOTE(shess) Copied from capi3.test.
                     25: proc utf16 {str {nt 1}} {
                     26:   set r [encoding convertto unicode $str]
                     27:   if {$nt} {
                     28:     append r "\x00\x00"
                     29:   }
                     30:   return $r
                     31: }
                     32: 
                     33: db eval {
                     34:   PRAGMA encoding = "UTF-16le";
                     35:   CREATE VIRTUAL TABLE t1 USING fts3(content);
                     36: }
                     37: 
                     38: do_test fts3ai-1.0 {
                     39:   execsql {PRAGMA encoding}
                     40: } {UTF-16le}
                     41: 
                     42: do_test fts3ai-1.1 {
                     43:   execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
                     44:   execsql {SELECT content FROM t1 WHERE rowid = 1}
                     45: } {one}
                     46: 
                     47: do_test fts3ai-1.2 {
                     48:   set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')"
                     49:   set STMT [sqlite3_prepare $DB $sql -1 TAIL]
                     50:   sqlite3_step $STMT
                     51:   sqlite3_finalize $STMT
                     52:   execsql {SELECT content FROM t1 WHERE rowid = 2}
                     53: } {two}
                     54: 
                     55: do_test fts3ai-1.3 {
                     56:   set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')"
                     57:   set STMT [sqlite3_prepare $DB $sql -1 TAIL]
                     58:   sqlite3_step $STMT
                     59:   sqlite3_finalize $STMT
                     60:   set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3"
                     61:   set STMT [sqlite3_prepare $DB $sql -1 TAIL]
                     62:   sqlite3_step $STMT
                     63:   sqlite3_finalize $STMT
                     64:   execsql {SELECT content FROM t1 WHERE rowid = 3}
                     65: } {trois}
                     66: 
                     67: do_test fts3ai-1.4 {
                     68:   set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]
                     69:   set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
                     70:   sqlite3_step $STMT
                     71:   sqlite3_finalize $STMT
                     72:   execsql {SELECT content FROM t1 WHERE rowid = 4}
                     73: } {four}
                     74: 
                     75: do_test fts3ai-1.5 {
                     76:   set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]
                     77:   set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
                     78:   sqlite3_step $STMT
                     79:   sqlite3_finalize $STMT
                     80:   set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5"
                     81:   set STMT [sqlite3_prepare $DB $sql -1 TAIL]
                     82:   sqlite3_step $STMT
                     83:   sqlite3_finalize $STMT
                     84:   execsql {SELECT content FROM t1 WHERE rowid = 5}
                     85: } {cinq}
                     86: 
                     87: finish_test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>