1# 2015-06-02 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. The 12# focus of this file is type affinity in comparison operations. 13# 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17 18do_execsql_test affinity2-100 { 19 CREATE TABLE t1( 20 xi INTEGER, 21 xr REAL, 22 xb BLOB, 23 xn NUMERIC, 24 xt TEXT 25 ); 26 INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(1,1,1,1,1,1); 27 INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(2,'2','2','2','2','2'); 28 INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(3,'03','03','03','03','03'); 29 30} {} 31do_execsql_test affinity2-110 { 32 SELECT xi, typeof(xi) FROM t1 ORDER BY rowid; 33} {1 integer 2 integer 3 integer} 34do_execsql_test affinity2-120 { 35 SELECT xr, typeof(xr) FROM t1 ORDER BY rowid; 36} {1.0 real 2.0 real 3.0 real} 37do_execsql_test affinity2-130 { 38 SELECT xb, typeof(xb) FROM t1 ORDER BY rowid; 39} {1 integer 2 text 03 text} 40do_execsql_test affinity2-140 { 41 SELECT xn, typeof(xn) FROM t1 ORDER BY rowid; 42} {1 integer 2 integer 3 integer} 43do_execsql_test affinity2-150 { 44 SELECT xt, typeof(xt) FROM t1 ORDER BY rowid; 45} {1 text 2 text 03 text} 46 47do_execsql_test affinity2-200 { 48 SELECT rowid, xi==xt, xi==xb, xi==+xt FROM t1 ORDER BY rowid; 49} {1 1 1 1 2 1 1 1 3 1 1 1} 50do_execsql_test affinity2-210 { 51 SELECT rowid, xr==xt, xr==xb, xr==+xt FROM t1 ORDER BY rowid; 52} {1 1 1 1 2 1 1 1 3 1 1 1} 53do_execsql_test affinity2-220 { 54 SELECT rowid, xn==xt, xn==xb, xn==+xt FROM t1 ORDER BY rowid; 55} {1 1 1 1 2 1 1 1 3 1 1 1} 56 57do_execsql_test affinity2-300 { 58 SELECT rowid, xt==+xi, xt==xi, xt==xb FROM t1 ORDER BY rowid; 59} {1 1 1 0 2 1 1 1 3 0 1 1} 60 61finish_test 62