blob: fd1f37af0eea06f20aa9f677dd173800606b74b7 [file] [log] [blame]
drh960e8c62001-04-03 16:53:21 +00001# Copyright (c) 1999, 2000 D. Richard Hipp
2#
3# This program is free software; you can redistribute it and/or
4# modify it under the terms of the GNU General Public
5# License as published by the Free Software Foundation; either
6# version 2 of the License, or (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11# General Public License for more details.
12#
13# You should have received a copy of the GNU General Public
14# License along with this library; if not, write to the
15# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16# Boston, MA 02111-1307, USA.
17#
18# Author contact information:
19# drh@hwaci.com
20# http://www.hwaci.com/drh/
21#
22#***********************************************************************
23# This file implements regression tests for TCL interface to the
24# SQLite library.
25#
26# Actually, all tests are based on the TCL interface, so the main
27# interface is pretty well tested. This file contains some addition
28# tests for fringe issues that the main test suite does not cover.
29#
30# $Id: tclsqlite.test,v 1.1 2001/04/03 16:53:22 drh Exp $
31
32set testdir [file dirname $argv0]
33source $testdir/tester.tcl
34
35# Check the error messages generated by tclsqlite
36#
37do_test tcl-1.1 {
38 set v [catch {sqlite bogus} msg]
39 lappend v $msg
40} {1 {wrong # args: should be "sqlite HANDLE FILENAME ?MODE?"}}
41do_test tcl-1.2 {
42 set v [catch {db bogus} msg]
43 lappend v $msg
44} {1 {bad option "bogus": must be busy, close, complete, eval, or timeout}}
45do_test tcl-1.3 {
46 execsql {CREATE TABLE t1(a int, b int)}
47 execsql {INSERT INTO t1 VALUES(10,20)}
48 set v [catch {
49 db eval {SELECT * FROM t1} data {
50 error "The error message"
51 }
52 } msg]
53 lappend v $msg
54} {1 {The error message}}
55do_test tcl-1.4 {
56 set v [catch {
57 db eval {SELECT * FROM t2} data {
58 error "The error message"
59 }
60 } msg]
61 lappend v $msg
62} {1 {no such table: t2}}
63do_test tcl-1.5 {
64 set v [catch {
65 db eval {SELECT * FROM t1} data {
66 break
67 }
68 } msg]
69 lappend v $msg
70} {0 {}}
71do_test tcl-1.6 {
72 set v [catch {
73 db eval {SELECT * FROM t1} data {
74 expr x*
75 }
76 } msg]
77 lappend v $msg
78} {1 {syntax error in expression "x*"}}
79
80finish_test