1*8d2cb149Sdrh# Copyright (c) 1999, 2000 D. Richard Hipp 2*8d2cb149Sdrh# 3*8d2cb149Sdrh# This program is free software; you can redistribute it and/or 4*8d2cb149Sdrh# modify it under the terms of the GNU General Public 5*8d2cb149Sdrh# License as published by the Free Software Foundation; either 6*8d2cb149Sdrh# version 2 of the License, or (at your option) any later version. 7*8d2cb149Sdrh# 8*8d2cb149Sdrh# This program is distributed in the hope that it will be useful, 9*8d2cb149Sdrh# but WITHOUT ANY WARRANTY; without even the implied warranty of 10*8d2cb149Sdrh# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11*8d2cb149Sdrh# General Public License for more details. 12*8d2cb149Sdrh# 13*8d2cb149Sdrh# You should have received a copy of the GNU General Public 14*8d2cb149Sdrh# License along with this library; if not, write to the 15*8d2cb149Sdrh# Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16*8d2cb149Sdrh# Boston, MA 02111-1307, USA. 17*8d2cb149Sdrh# 18*8d2cb149Sdrh# Author contact information: 19*8d2cb149Sdrh# [email protected] 20*8d2cb149Sdrh# http://www.hwaci.com/drh/ 21*8d2cb149Sdrh# 22*8d2cb149Sdrh#*********************************************************************** 23*8d2cb149Sdrh# This file implements regression tests for SQLite library. The 24*8d2cb149Sdrh# focus of this file is testing expressions. 25*8d2cb149Sdrh# 26*8d2cb149Sdrh# $Id: expr.test,v 1.1 2000/05/30 03:28:36 drh Exp $ 27*8d2cb149Sdrh 28*8d2cb149Sdrhset testdir [file dirname $argv0] 29*8d2cb149Sdrhsource $testdir/tester.tcl 30*8d2cb149Sdrh 31*8d2cb149Sdrh# Create a table to work with. 32*8d2cb149Sdrh# 33*8d2cb149Sdrhexecsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)} 34*8d2cb149Sdrhexecsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')} 35*8d2cb149Sdrhproc test_expr {name settings expr result} { 36*8d2cb149Sdrh do_test $name [format { 37*8d2cb149Sdrh execsql {UPDATE test1 SET %s} 38*8d2cb149Sdrh execsql {SELECT %s FROM test1} 39*8d2cb149Sdrh } $settings $expr] $result 40*8d2cb149Sdrh} 41*8d2cb149Sdrh 42*8d2cb149Sdrhtest_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30 43*8d2cb149Sdrhtest_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10 44*8d2cb149Sdrhtest_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200 45*8d2cb149Sdrhtest_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0.5 46*8d2cb149Sdrhtest_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2 47*8d2cb149Sdrhtest_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0 48*8d2cb149Sdrhtest_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0 49*8d2cb149Sdrhtest_expr expr-1.8 {i1=10, i2=20} {i2>i1} 1 50*8d2cb149Sdrhtest_expr expr-1.9 {i1=10, i2=20} {i2>=i1} 1 51*8d2cb149Sdrhtest_expr expr-1.10 {i1=10, i2=20} {i2!=i1} 1 52*8d2cb149Sdrhtest_expr expr-1.11 {i1=10, i2=20} {i2=i1} 0 53*8d2cb149Sdrhtest_expr expr-1.12 {i1=10, i2=20} {i2<>i1} 1 54*8d2cb149Sdrhtest_expr expr-1.13 {i1=10, i2=20} {i2==i1} 0 55*8d2cb149Sdrhtest_expr expr-1.14 {i1=20, i2=20} {i2<i1} 0 56*8d2cb149Sdrhtest_expr expr-1.15 {i1=20, i2=20} {i2<=i1} 1 57*8d2cb149Sdrhtest_expr expr-1.16 {i1=20, i2=20} {i2>i1} 0 58*8d2cb149Sdrhtest_expr expr-1.17 {i1=20, i2=20} {i2>=i1} 1 59*8d2cb149Sdrhtest_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0 60*8d2cb149Sdrhtest_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1 61*8d2cb149Sdrhtest_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0 62*8d2cb149Sdrhtest_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1 63*8d2cb149Sdrhtest_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7} 64*8d2cb149Sdrhtest_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9} 65*8d2cb149Sdrh 66*8d2cb149Sdrh 67*8d2cb149Sdrhfinish_test 68