1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
# 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.9 2001/10/13 02:59:09 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]
lappend v $msg
} {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
|