3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script testing the callback-free C/C++ API.
14 # $Id: capi3e.test,v 1.70 2009/01/09 02:49:32 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 # Make sure the system encoding is utf-8. Otherwise, if the system encoding
21 # is other than utf-8, [file isfile $x] may not refer to the same file
24 # This is no longer needed here because it should be done within the test
25 # fixture executable itself, via Tcl_SetSystemEncoding.
27 # encoding system utf-8
29 # Do not use a codec for tests in this file, as the database file is
30 # manipulated directly using tcl scripts (using the [hexio_write] command).
34 # Return the UTF-16 representation of the supplied UTF-8 string $str.
35 # If $nt is true, append two 0x00 bytes as a nul terminator.
36 proc utf16 {str {nt 1}} {
37 set r [encoding convertto unicode $str]
44 # Return the UTF-8 representation of the supplied UTF-16 string $str.
46 # If $str ends in two 0x00 0x00 bytes, knock these off before
47 # converting to UTF-8 using TCL.
48 binary scan $str \c* vals
49 if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
50 set str [binary format \c* [lrange $vals 0 end-2]]
53 set r [encoding convertfrom unicode $str]
57 # These tests complement those in capi2.test. They are organized
60 # capi3e-1.*: Test sqlite3_open with various UTF8 filenames
61 # capi3e-2.*: Test sqlite3_open16 with various UTF8 filenames
62 # capi3e-3.*: Test ATTACH with various UTF8 filenames
66 # here's the list of file names we're testing
67 set names {t 1 t. 1. t.d 1.d t-1 1-1 t.db ä.db ë.db ö.db ü.db ÿ.db}
72 do_test capi3e-1.1.$i {
73 set db2 [sqlite3_open $name {}]
76 do_test capi3e-1.2.$i {
79 do_test capi3e-1.3.$i {
88 do_test capi3e-2.1.$i {
89 set db2 [sqlite3_open16 [utf16 $name] {}]
92 do_test capi3e-2.2.$i {
95 do_test capi3e-2.3.$i {
106 foreach name $names {
108 do_test capi3e-3.2.$i {
109 db2 eval "ATTACH DATABASE '$name' AS db$i;"
111 do_test capi3e-3.3.$i {
112 db2 eval "DETACH DATABASE db$i;"
122 foreach name $names {