# Copyright (c) 1999, 2000 D. Richard Hipp # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # Author contact information: # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is exercising the code in main.c. # # $Id: main.test,v 1.4 2000/12/10 18:23:52 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Tests of the sqlite_complete() function. # do_test main-1.1 { db complete {This is a test} } {0} do_test main-1.2 { db complete { } } {0} do_test main-1.3 { db complete { -- a comment ; } } {0} do_test main-1.4 { db complete { -- a comment ; ; } } {1} do_test main-1.5 { db complete {DROP TABLE 'xyz;} } {0} do_test main-1.6 { db complete {DROP TABLE 'xyz';} } {1} do_test main-1.7 { db complete {DROP TABLE "xyz;} } {0} do_test main-1.8 { db complete {DROP TABLE "xyz';} } {0} do_test main-1.9 { db complete {DROP TABLE "xyz";} } {1} do_test main-1.10 { db complete {DROP TABLE xyz; hi} } {0} do_test main-1.11 { db complete {DROP TABLE xyz; } } {1} do_test main-1.12 { db complete {DROP TABLE xyz; -- hi } } {1} do_test main-1.13 { db complete {DROP TABLE xyz; -- hi } } {1} # Try to open a database with a corrupt master file. # do_test main-2.0 { catch {db close} file delete -force testdb file mkdir testdb set fd [open testdb/sqlite_master.tbl w] puts $fd hi! close $fd set v [catch {sqlite db testdb} msg] lappend v $msg } {0 {}} # Here are some tests for tokenize.c. # do_test main-3.1 { catch {db close} file delete -force testdb sqlite db testdb set v [catch {execsql {SELECT * from T1 where x!!5}} msg] lappend v $msg } {1 {unrecognized token: "!!"}} do_test main-3.2 { catch {db close} file delete -force testdb sqlite db testdb set v [catch {execsql {SELECT * from T1 where ~x}} msg] lappend v $msg } {1 {unrecognized token: "~"}} do_test main-3.3 { catch {db close} file delete -force testdb sqlite db testdb set v [catch {execsql {SELECT a|b from T1 where x}} msg] lappend v $msg } {1 {unrecognized token: "|"}} do_test main-3.3 { catch {db close} file delete -force testdb sqlite db testdb execsql { create table T1(X REAL); insert into T1 values(.5); insert into T1 values(0.5e2); insert into T1 values(0.5e-002); insert into T1 values(5e-002); insert into T1 values(-5.0e-2); insert into T1 values(-5.1e-2); insert into T1 values(.5e2); insert into T1 values(.5E+02); insert into T1 values(5E+02); insert into T1 values(5.E+03); select x*10 from T1 order by x*5; } } {-0.51 -0.5 0.05 0.5 5 500 500 500 5000 50000} do_test main-3.4 { set v [catch {execsql {create bogus}} msg] lappend v $msg } {1 {near "bogus": syntax error}} do_test main-3.5 { set v [catch {execsql {create}} msg] lappend v $msg } {1 {near "create": syntax error}} finish_test