1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-05 15:21:19 +03:00
Files
sqlite/test/main.test
drh c22bd47d55 Improvements to the SQLITE_MISUSE detection logic. Also added test cases
for this logic, including the new test file "misuse.test". (CVS 559)

FossilOrigin-Name: f42907ce457e012592f8c043dc6c915e87258b35
2002-05-10 13:14:07 +00:00

135 lines
3.2 KiB
Plaintext

# 2001 September 15
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# 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.10 2002/05/10 13:14:08 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}
do_test main-1.14 {
db complete {SELECT a-b FROM t1; }
} {1}
do_test main-1.15 {
db complete {SELECT a-b FROM t1 }
} {0}
# Try to open a database with a corrupt database file.
#
do_test main-2.0 {
catch {db close}
file delete -force test.db
set fd [open test.db w]
puts $fd hi!
close $fd
set v [catch {sqlite db test.db} msg]
if {$v} {lappend v $msg} {lappend v {}}
} {0 {}}
# Here are some tests for tokenize.c.
#
do_test main-3.1 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
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}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
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}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
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