OLD | NEW |
1 # 2001 September 15 | 1 # 2001 September 15 |
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 # This file implements regression tests for TCL interface to the | 11 # This file implements regression tests for TCL interface to the |
12 # SQLite library. | 12 # SQLite library. |
13 # | 13 # |
14 # Actually, all tests are based on the TCL interface, so the main | 14 # Actually, all tests are based on the TCL interface, so the main |
15 # interface is pretty well tested. This file contains some addition | 15 # interface is pretty well tested. This file contains some addition |
16 # tests for fringe issues that the main test suite does not cover. | 16 # tests for fringe issues that the main test suite does not cover. |
17 # | 17 # |
18 # $Id: tclsqlite.test,v 1.73 2009/03/16 13:19:36 danielk1977 Exp $ | 18 # $Id: tclsqlite.test,v 1.73 2009/03/16 13:19:36 danielk1977 Exp $ |
19 | 19 |
20 set testdir [file dirname $argv0] | 20 set testdir [file dirname $argv0] |
21 source $testdir/tester.tcl | 21 source $testdir/tester.tcl |
22 | 22 |
23 # Check the error messages generated by tclsqlite | 23 # Check the error messages generated by tclsqlite |
24 # | 24 # |
| 25 set r "sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create B
OOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?" |
25 if {[sqlite3 -has-codec]} { | 26 if {[sqlite3 -has-codec]} { |
26 set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?" | 27 append r " ?-key CODECKEY?" |
27 } else { | |
28 set r "sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create
BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?" | |
29 } | 28 } |
30 do_test tcl-1.1 { | 29 do_test tcl-1.1 { |
31 set v [catch {sqlite3 bogus} msg] | 30 set v [catch {sqlite3 bogus} msg] |
32 regsub {really_sqlite3} $msg {sqlite3} msg | 31 regsub {really_sqlite3} $msg {sqlite3} msg |
33 lappend v $msg | 32 lappend v $msg |
34 } [list 1 "wrong # args: should be \"$r\""] | 33 } [list 1 "wrong # args: should be \"$r\""] |
35 do_test tcl-1.2 { | 34 do_test tcl-1.2 { |
36 set v [catch {db bogus} msg] | 35 set v [catch {db bogus} msg] |
37 lappend v $msg | 36 lappend v $msg |
38 } {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, clos
e, collate, collation_needed, commit_hook, complete, copy, enable_load_extension
, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nul
lvalue, onecolumn, profile, progress, rekey, restore, rollback_hook, status, tim
eout, total_changes, trace, transaction, unlock_notify, update_hook, version, or
wal_hook}} | 37 } {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, clos
e, collate, collation_needed, commit_hook, complete, copy, enable_load_extension
, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nul
lvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook,
status, timeout, total_changes, trace, trace_v2, transaction, unlock_notify, upd
ate_hook, version, or wal_hook}} |
39 do_test tcl-1.2.1 { | 38 do_test tcl-1.2.1 { |
40 set v [catch {db cache bogus} msg] | 39 set v [catch {db cache bogus} msg] |
41 lappend v $msg | 40 lappend v $msg |
42 } {1 {bad option "bogus": must be flush or size}} | 41 } {1 {bad option "bogus": must be flush or size}} |
43 do_test tcl-1.2.2 { | 42 do_test tcl-1.2.2 { |
44 set v [catch {db cache} msg] | 43 set v [catch {db cache} msg] |
45 lappend v $msg | 44 lappend v $msg |
46 } {1 {wrong # args: should be "db cache option ?arg?"}} | 45 } {1 {wrong # args: should be "db cache option ?arg?"}} |
47 do_test tcl-1.3 { | 46 do_test tcl-1.3 { |
48 execsql {CREATE TABLE t1(a int, b int)} | 47 execsql {CREATE TABLE t1(a int, b int)} |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 db func xCall xCall | 628 db func xCall xCall |
630 proc xCall {} { return "value" } | 629 proc xCall {} { return "value" } |
631 do_execsql_test tcl-14.1 { | 630 do_execsql_test tcl-14.1 { |
632 CREATE TABLE t6(x); | 631 CREATE TABLE t6(x); |
633 INSERT INTO t6 VALUES(1); | 632 INSERT INTO t6 VALUES(1); |
634 } | 633 } |
635 do_test tcl-14.2 { | 634 do_test tcl-14.2 { |
636 db one {SELECT x FROM t6 WHERE xCall()!='value'} | 635 db one {SELECT x FROM t6 WHERE xCall()!='value'} |
637 } {} | 636 } {} |
638 | 637 |
| 638 # Verify that the "exists" and "onecolumn" methods work when |
| 639 # a "profile" is registered. |
| 640 # |
| 641 catch {db close} |
| 642 sqlite3 db :memory: |
| 643 proc noop-profile {args} { |
| 644 return |
| 645 } |
| 646 do_test tcl-15.0 { |
| 647 db eval {CREATE TABLE t1(a); INSERT INTO t1 VALUES(1),(2),(3);} |
| 648 db onecolumn {SELECT a FROM t1 WHERE a>2} |
| 649 } {3} |
| 650 do_test tcl-15.1 { |
| 651 db exists {SELECT a FROM t1 WHERE a>2} |
| 652 } {1} |
| 653 do_test tcl-15.2 { |
| 654 db exists {SELECT a FROM t1 WHERE a>3} |
| 655 } {0} |
| 656 db profile noop-profile |
| 657 do_test tcl-15.3 { |
| 658 db onecolumn {SELECT a FROM t1 WHERE a>2} |
| 659 } {3} |
| 660 do_test tcl-15.4 { |
| 661 db exists {SELECT a FROM t1 WHERE a>2} |
| 662 } {1} |
| 663 do_test tcl-15.5 { |
| 664 db exists {SELECT a FROM t1 WHERE a>3} |
| 665 } {0} |
| 666 |
| 667 |
| 668 |
| 669 |
| 670 |
639 | 671 |
640 | 672 |
641 finish_test | 673 finish_test |
OLD | NEW |