1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

:-) (CVS 82)

FossilOrigin-Name: 33355b2d8d23b51e917961b7fb336bc1d454497f
This commit is contained in:
drh
2000-06-08 16:26:24 +00:00
parent 4cfa793437
commit c837e70996
9 changed files with 167 additions and 34 deletions

View File

@@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.6 2000/06/07 15:23:56 drh Exp $
# $Id: expr.test,v 1.7 2000/06/08 16:26:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -144,6 +144,7 @@ test_expr expr-5.5b {t1='ac', t2='A%C'} {t1 LIKE t2} 1
test_expr expr-5.6 {t1='abxyzzyc', t2='A%C'} {t1 LIKE t2} 1
test_expr expr-5.7 {t1='abxyzzy', t2='A%C'} {t1 LIKE t2} 0
test_expr expr-5.8 {t1='abxyzzycx', t2='A%C'} {t1 LIKE t2} 0
test_expr expr-5.8b {t1='abxyzzycy', t2='A%CX'} {t1 LIKE t2} 0
test_expr expr-5.9 {t1='abc', t2='A%_C'} {t1 LIKE t2} 1
test_expr expr-5.9b {t1='ac', t2='A%_C'} {t1 LIKE t2} 0
test_expr expr-5.10 {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} 1
@@ -161,7 +162,20 @@ test_expr expr-6.8 {t1='abxyzzyc', t2='a*c'} {t1 GLOB t2} 1
test_expr expr-6.9 {t1='abxyzzy', t2='a*c'} {t1 GLOB t2} 0
test_expr expr-6.10 {t1='abxyzzycx', t2='a*c'} {t1 GLOB t2} 0
test_expr expr-6.11 {t1='abc', t2='xyz'} {t1 NOT GLOB t2} 1
test_expr expr-6.12 {t1='abc', t2='a?c'} {t1 NOT GLOB t2} 0
test_expr expr-6.12 {t1='abc', t2='abc'} {t1 NOT GLOB t2} 0
test_expr expr-6.13 {t1='abc', t2='a[bx]c'} {t1 GLOB t2} 1
test_expr expr-6.14 {t1='abc', t2='a[cx]c'} {t1 GLOB t2} 0
test_expr expr-6.15 {t1='abc', t2='a[a-d]c'} {t1 GLOB t2} 1
test_expr expr-6.16 {t1='abc', t2='a[^a-d]c'} {t1 GLOB t2} 0
test_expr expr-6.17 {t1='abc', t2='a[A-Dc]c'} {t1 GLOB t2} 0
test_expr expr-6.18 {t1='abc', t2='a[^A-Dc]c'} {t1 GLOB t2} 1
test_expr expr-6.19 {t1='abc', t2='a[]b]c'} {t1 GLOB t2} 1
test_expr expr-6.20 {t1='abc', t2='a[^]b]c'} {t1 GLOB t2} 0
test_expr expr-6.21 {t1='abcdefg', t2='a*[de]g'} {t1 GLOB t2} 0
test_expr expr-6.22 {t1='abcdefg', t2='a*[^de]g'} {t1 GLOB t2} 1
test_expr expr-6.23 {t1='abcdefg', t2='a*?g'} {t1 GLOB t2} 1
test_expr expr-6.24 {t1='ac', t2='a*c'} {t1 GLOB t2} 1
test_expr expr-6.25 {t1='ac', t2='a*?c'} {t1 GLOB t2} 0
# The sqliteExprIfFalse and sqliteExprIfTrue routines are only
# executed as part of a WHERE clause. Create a table suitable

View File

@@ -23,7 +23,7 @@
# 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.1 2000/06/07 15:11:27 drh Exp $
# $Id: main.test,v 1.2 2000/06/08 16:26:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -62,4 +62,49 @@ do_test main-2.0 {
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
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

View File

@@ -24,7 +24,7 @@
# focus of this file is testing aggregate functions and the
# GROUP BY and HAVING clauses of SELECT statements.
#
# $Id: select5.test,v 1.2 2000/06/08 11:25:01 drh Exp $
# $Id: select5.test,v 1.3 2000/06/08 16:26:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -59,4 +59,53 @@ do_test select5-1.3 {
execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y}
} {1 9 1 10 2 8 4 7 8 6 15 5}
# Some error messages associated with aggregates and GROUP BY
#
do_test select5-2.1 {
set v [catch {execsql {
SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y
}} msg]
lappend v $msg
} {1 {no such field: z}}
do_test select5-2.2 {
set v [catch {execsql {
SELECT y, count(*) FROM t1 GROUP BY z(y) ORDER BY y
}} msg]
lappend v $msg
} {1 {no such function: z}}
do_test select5-2.3 {
set v [catch {execsql {
SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<3 ORDER BY y
}} msg]
lappend v $msg
} {0 {8 2 9 1 10 1}}
do_test select5-2.4 {
set v [catch {execsql {
SELECT y, count(*) FROM t1 GROUP BY y HAVING z(y)<3 ORDER BY y
}} msg]
lappend v $msg
} {1 {no such function: z}}
do_test select5-2.5 {
set v [catch {execsql {
SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<z ORDER BY y
}} msg]
lappend v $msg
} {1 {no such field: z}}
# Get the Agg function to rehash in vdbe.c
#
do_test select5-3.1 {
execsql {
SELECT x, count(*), avg(y) FROM t1 GROUP BY x HAVING x<4 ORDER BY x
}
} {1 1 5 2 1 5 3 1 5}
# Run the AVG() function when the count is zero.
#
do_test select5-4.1 {
execsql {
SELECT avg(x) FROM t1 WHERE x>100
}
} {}
finish_test

View File

@@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the UPDATE statement.
#
# $Id: update.test,v 1.1 2000/05/30 03:12:22 drh Exp $
# $Id: update.test,v 1.2 2000/06/08 16:26:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -110,6 +110,32 @@ do_test update-3.12 {
execsql {SELECT * FROM test1 WHERE f1=1025}
} {1025 11}
# Error messages
#
do_test update-4.1 {
set v [catch {execsql {
UPDATE test1 SET x=11 WHERE f1=1025
}} msg]
lappend v $msg
} {1 {no such field: x}}
do_test update-4.2 {
set v [catch {execsql {
UPDATE test1 SET f1=x(11) WHERE f1=1025
}} msg]
lappend v $msg
} {1 {no such function: x}}
do_test update-4.3 {
set v [catch {execsql {
UPDATE test1 SET f1=11 WHERE x=1025
}} msg]
lappend v $msg
} {1 {no such field: x}}
do_test update-4.4 {
set v [catch {execsql {
UPDATE test1 SET f1=11 WHERE x(f1)=1025
}} msg]
lappend v $msg
} {1 {no such function: x}}