gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/intreal.test (about) 1 # 2019-05-03 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 # Tests to exercise the MEM_IntReal representation of Mem objects. 12 # 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 set ::testprefix intreal 16 17 sqlite3_create_function db 18 do_execsql_test 100 { 19 SELECT intreal(5); 20 } {5.0} 21 do_execsql_test 110 { 22 SELECT intreal(5)=5, 6=intreal(6); 23 } {1 1} 24 do_execsql_test 120 { 25 SELECT intreal(7)=7.0, 8.0=intreal(8); 26 } {1 1} 27 do_execsql_test 130 { 28 SELECT typeof(intreal(9)); 29 } {real} 30 do_execsql_test 140 { 31 SELECT 'a'||intreal(11)||'z'; 32 } {a11.0z} 33 34 do_execsql_test 150 { 35 SELECT max(1.0,intreal(2),3.0), max(1,intreal(2),3); 36 } {3.0 3} 37 do_execsql_test 160 { 38 SELECT max(1.0,intreal(4),3.0), max(1,intreal(4),3); 39 } {4.0 4.0} 40 do_execsql_test 170 { 41 SELECT max(1.0,intreal(2),intreal(3),4.0), 42 max(1,intreal(2),intreal(3),4); 43 } {4.0 4} 44 do_execsql_test 180 { 45 SELECT max(1.0,intreal(5),intreal(3),4.0), 46 max(1,intreal(5),intreal(3),4); 47 } {5.0 5.0} 48 49 #------------------------------------------------------------------------- 50 do_execsql_test 2.1 { 51 CREATE TABLE t2(a REAL); 52 INSERT INTO t2 VALUES( 836627109860825358 ); 53 SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL); 54 } {8.36} 55 56 do_execsql_test 2.2 { 57 CREATE INDEX i2 ON t2(a); 58 SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL); 59 } {8.36} 60 61 do_execsql_test 2.3 { 62 CREATE TABLE t0 (c0); 63 CREATE TABLE t1 (c1 REAL); 64 INSERT INTO t1(c1) VALUES (8366271098608253588); 65 INSERT INTO t0(c0) VALUES ('a'); 66 } 67 set D [db one {SELECT c1 FROM t1}] 68 69 do_execsql_test 2.4 { 70 SELECT * FROM t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL)); 71 } $D 72 73 do_execsql_test 2.5 { 74 SELECT * FROM t0, t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL)); 75 } [list a $D] 76 77 do_execsql_test 2.6 { 78 SELECT * FROM t0, t1 79 WHERE ( 80 t1.c1 >= CAST(8366271098608253588 AS REAL) 81 AND t1.c1 <= CAST(8366271098608253588 AS REAL) 82 ); 83 } [list a $D] 84 85 # 2019-07-29 ticket ba2f4585cf495231 86 # 87 db close 88 sqlite3 db :memory: 89 do_execsql_test 3.0 { 90 CREATE TABLE t0 (c0 REAL, c1); 91 CREATE UNIQUE INDEX i0 ON t0(c1, 0 | c0); 92 INSERT INTO t0(c0) VALUES (4750228396194493326), (0); 93 UPDATE OR REPLACE t0 SET c0 = 'a', c1 = ''; 94 SELECT * FROM t0 ORDER BY t0.c1; 95 PRAGMA integrity_check; 96 } {a {} ok} 97 98 finish_test