| OLD | NEW |
| (Empty) |
| 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 ifcapable !utf16 { | |
| 23 finish_test | |
| 24 return | |
| 25 } | |
| 26 | |
| 27 # Return the UTF-16 representation of the supplied UTF-8 string $str. | |
| 28 # If $nt is true, append two 0x00 bytes as a nul terminator. | |
| 29 # NOTE(shess) Copied from capi3.test. | |
| 30 proc utf16 {str {nt 1}} { | |
| 31 set r [encoding convertto unicode $str] | |
| 32 if {$nt} { | |
| 33 append r "\x00\x00" | |
| 34 } | |
| 35 return $r | |
| 36 } | |
| 37 | |
| 38 db eval { | |
| 39 PRAGMA encoding = "UTF-16le"; | |
| 40 CREATE VIRTUAL TABLE t1 USING fts3(content); | |
| 41 } | |
| 42 | |
| 43 do_test fts3ai-1.0 { | |
| 44 execsql {PRAGMA encoding} | |
| 45 } {UTF-16le} | |
| 46 | |
| 47 do_test fts3ai-1.1 { | |
| 48 execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')} | |
| 49 execsql {SELECT content FROM t1 WHERE rowid = 1} | |
| 50 } {one} | |
| 51 | |
| 52 do_test fts3ai-1.2 { | |
| 53 set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')" | |
| 54 set STMT [sqlite3_prepare $DB $sql -1 TAIL] | |
| 55 sqlite3_step $STMT | |
| 56 sqlite3_finalize $STMT | |
| 57 execsql {SELECT content FROM t1 WHERE rowid = 2} | |
| 58 } {two} | |
| 59 | |
| 60 do_test fts3ai-1.3 { | |
| 61 set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')" | |
| 62 set STMT [sqlite3_prepare $DB $sql -1 TAIL] | |
| 63 sqlite3_step $STMT | |
| 64 sqlite3_finalize $STMT | |
| 65 set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3" | |
| 66 set STMT [sqlite3_prepare $DB $sql -1 TAIL] | |
| 67 sqlite3_step $STMT | |
| 68 sqlite3_finalize $STMT | |
| 69 execsql {SELECT content FROM t1 WHERE rowid = 3} | |
| 70 } {trois} | |
| 71 | |
| 72 do_test fts3ai-1.4 { | |
| 73 set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}] | |
| 74 set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL] | |
| 75 sqlite3_step $STMT | |
| 76 sqlite3_finalize $STMT | |
| 77 execsql {SELECT content FROM t1 WHERE rowid = 4} | |
| 78 } {four} | |
| 79 | |
| 80 do_test fts3ai-1.5 { | |
| 81 set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}] | |
| 82 set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL] | |
| 83 sqlite3_step $STMT | |
| 84 sqlite3_finalize $STMT | |
| 85 set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5" | |
| 86 set STMT [sqlite3_prepare $DB $sql -1 TAIL] | |
| 87 sqlite3_step $STMT | |
| 88 sqlite3_finalize $STMT | |
| 89 execsql {SELECT content FROM t1 WHERE rowid = 5} | |
| 90 } {cinq} | |
| 91 | |
| 92 finish_test | |
| OLD | NEW |