blob: 7e8801eda4a58e98011fcab3ca52cf9a760bf5b3 [file] [log] [blame]
drhacf4ac92003-12-17 23:57:34 +00001# 2003 December 17
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library.
12#
13# This file implements tests for miscellanous features that were
14# left out of other test files.
15#
drh93a5c6b2003-12-23 02:17:35 +000016# $Id: misc3.test,v 1.2 2003/12/23 02:17:35 drh Exp $
drhacf4ac92003-12-17 23:57:34 +000017
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21# Ticket #529. Make sure an ABORT does not damage the in-memory cache
22# that will be used by subsequent statements in the same transaction.
23#
24do_test misc3-1.1 {
25 execsql {
26 CREATE TABLE t1(a UNIQUE,b);
27 INSERT INTO t1
28 VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
29 UPDATE t1 SET b=b||b;
30 UPDATE t1 SET b=b||b;
31 UPDATE t1 SET b=b||b;
32 UPDATE t1 SET b=b||b;
33 UPDATE t1 SET b=b||b;
34 INSERT INTO t1 VALUES(2,'x');
35 UPDATE t1 SET b=substr(b,1,500);
36 BEGIN;
37 }
38 catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';}
39 execsql {
40 CREATE TABLE t2(x,y);
41 COMMIT;
42 PRAGMA integrity_check;
43 }
44} ok
45do_test misc3-1.2 {
46 execsql {
47 DROP TABLE t1;
48 DROP TABLE t2;
49 VACUUM;
50 CREATE TABLE t1(a UNIQUE,b);
51 INSERT INTO t1
52 VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
53 INSERT INTO t1 SELECT a+1, b||b FROM t1;
54 INSERT INTO t1 SELECT a+2, b||b FROM t1;
55 INSERT INTO t1 SELECT a+4, b FROM t1;
56 INSERT INTO t1 SELECT a+8, b FROM t1;
57 INSERT INTO t1 SELECT a+16, b FROM t1;
58 INSERT INTO t1 SELECT a+32, b FROM t1;
59 INSERT INTO t1 SELECT a+64, b FROM t1;
60
61 BEGIN;
62 }
63 catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';}
64 execsql {
65 INSERT INTO t1 VALUES(200,'hello out there');
66 COMMIT;
67 PRAGMA integrity_check;
68 }
69} ok
70
drh93a5c6b2003-12-23 02:17:35 +000071# Tests of the sqliteAtoF() function in util.c
72#
73do_test misc3-2.1 {
74 execsql {SELECT 2e-25*0.5e25}
75} 1
76do_test misc3-2.2 {
77 execsql {SELECT 2.0e-25*000000.500000000000000000000000000000e+00025}
78} 1
79do_test misc3-2.3 {
80 execsql {SELECT 000000000002e-0000000025*0.5e25}
81} 1
82do_test misc3-2.4 {
83 execsql {SELECT 2e-25*0.5e250}
84} 1e+225
85do_test misc3-2.5 {
86 execsql {SELECT 2.0e-250*0.5e25}
87} 1e-225
88do_test misc3-2.6 {
89 execsql {SELECT '-2.0e-127' * '-0.5e27'}
90} 1e-100
91do_test misc3-2.7 {
92 execsql {SELECT '+2.0e-127' * '-0.5e27'}
93} -1e-100
94do_test misc3-2.8 {
95 execsql {SELECT 2.0e-27 * '+0.5e+127'}
96} 1e+100
97do_test misc3-2.9 {
98 execsql {SELECT 2.0e-27 * '+0.000005e+132'}
99} 1e+100
100
101
drhacf4ac92003-12-17 23:57:34 +0000102finish_test