⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expr.test

📁 最新的sqlite3.6.2源代码
💻 TEST
📖 第 1 页 / 共 3 页
字号:
	{ CASE WHEN i1 < 5 THEN 'low' 	       WHEN i1 < 10 THEN 'medium'                WHEN i1 < 15 THEN 'high' ELSE 'error' END} medium# The sqliteExprIfFalse and sqliteExprIfTrue routines are only# executed as part of a WHERE clause.  Create a table suitable# for testing these functions.#execsql {DROP TABLE test1}execsql {CREATE TABLE test1(a int, b int);}for {set i 1} {$i<=20} {incr i} {  execsql "INSERT INTO test1 VALUES($i,[expr {1<<$i}])"}execsql "INSERT INTO test1 VALUES(NULL,0)"do_test expr-7.1 {  execsql {SELECT * FROM test1 ORDER BY a}} {{} 0 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024 11 2048 12 4096 13 8192 14 16384 15 32768 16 65536 17 131072 18 262144 19 524288 20 1048576}proc test_expr2 {name expr result} {  do_test $name [format {    execsql {SELECT a FROM test1 WHERE %s ORDER BY a}  } $expr] $result}test_expr2 expr-7.2  {a<10 AND a>8}                  {9}test_expr2 expr-7.3  {a<=10 AND a>=8}                {8 9 10}test_expr2 expr-7.4  {a>=8 AND a<=10}                {8 9 10}test_expr2 expr-7.5  {a>=20 OR a<=1}                 {1 20}test_expr2 expr-7.6  {b!=4 AND a<=3}                 {1 3}test_expr2 expr-7.7  {b==8 OR b==16 OR b==32}        {3 4 5}test_expr2 expr-7.8  {NOT b<>8 OR b==1024}           {3 10}test_expr2 expr-7.9  {b LIKE '10%'}                  {10 20}test_expr2 expr-7.10 {b LIKE '_4'}                   {6}test_expr2 expr-7.11 {a GLOB '1?'}            {10 11 12 13 14 15 16 17 18 19}test_expr2 expr-7.12 {b GLOB '1*4'}                  {10 14}test_expr2 expr-7.13 {b GLOB '*1[456]'}              {4}test_expr2 expr-7.14 {a ISNULL}                      {{}}test_expr2 expr-7.15 {a NOTNULL AND a<3}             {1 2}test_expr2 expr-7.16 {a AND a<3}                     {1 2}test_expr2 expr-7.17 {NOT a}                         {}test_expr2 expr-7.18 {a==11 OR (b>1000 AND b<2000)}  {10 11}test_expr2 expr-7.19 {a<=1 OR a>=20}                 {1 20}test_expr2 expr-7.20 {a<1 OR a>20}                   {}test_expr2 expr-7.21 {a>19 OR a<1}                   {20}test_expr2 expr-7.22 {a!=1 OR a=100} \                         {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}test_expr2 expr-7.23 {(a notnull AND a<4) OR a==8}   {1 2 3 8}test_expr2 expr-7.24 {a LIKE '2_' OR a==8}           {8 20}test_expr2 expr-7.25 {a GLOB '2?' OR a==8}           {8 20}test_expr2 expr-7.26 {a isnull OR a=8}               {{} 8}test_expr2 expr-7.27 {a notnull OR a=8} \                          {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}test_expr2 expr-7.28 {a<0 OR b=0} {{}}test_expr2 expr-7.29 {b=0 OR a<0} {{}}test_expr2 expr-7.30 {a<0 AND b=0} {}test_expr2 expr-7.31 {b=0 AND a<0} {}test_expr2 expr-7.32 {a IS NULL AND (a<0 OR b=0)} {{}}test_expr2 expr-7.33 {a IS NULL AND (b=0 OR a<0)} {{}}test_expr2 expr-7.34 {a IS NULL AND (a<0 AND b=0)} {}test_expr2 expr-7.35 {a IS NULL AND (b=0 AND a<0)} {}test_expr2 expr-7.32 {(a<0 OR b=0) AND a IS NULL} {{}}test_expr2 expr-7.33 {(b=0 OR a<0) AND a IS NULL} {{}}test_expr2 expr-7.34 {(a<0 AND b=0) AND a IS NULL} {}test_expr2 expr-7.35 {(b=0 AND a<0) AND a IS NULL} {}test_expr2 expr-7.36 {a<2 OR (a<0 OR b=0)} {{} 1}test_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}test_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}test_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}test_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}test_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}test_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}test_expr2 expr-7.44 {123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a BETWEEN '123a' AND '123b'} {}test_expr2 expr-7.45 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123b')<0} {}test_expr2 expr-7.46 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123z')>0} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}test_expr2 expr-7.50 {((a between 1 and 2 OR 0) AND 1) OR 0} {1 2}test_expr2 expr-7.51 {((a not between 3 and 100 OR 0) AND 1) OR 0} {1 2}ifcapable subquery {  test_expr2 expr-7.52 {((a in (1,2) OR 0) AND 1) OR 0} {1 2}  test_expr2 expr-7.53 \      {((a not in (3,4,5,6,7,8,9,10) OR 0) AND a<11) OR 0} {1 2}}test_expr2 expr-7.54 {((a>0 OR 0) AND a<3) OR 0} {1 2}ifcapable subquery {  test_expr2 expr-7.55 {((a in (1,2) OR 0) IS NULL AND 1) OR 0} {{}}  test_expr2 expr-7.56 \      {((a not in (3,4,5,6,7,8,9,10) IS NULL OR 0) AND 1) OR 0} {{}}}test_expr2 expr-7.57 {((a>0 IS NULL OR 0) AND 1) OR 0} {{}}test_expr2 expr-7.58  {(a||'')<='1'}                  {1}test_expr2 expr-7.59 {LIKE('10%',b)}                  {10 20}test_expr2 expr-7.60 {LIKE('_4',b)}                   {6}test_expr2 expr-7.61 {GLOB('1?',a)}            {10 11 12 13 14 15 16 17 18 19}test_expr2 expr-7.62 {GLOB('1*4',b)}                  {10 14}test_expr2 expr-7.63 {GLOB('*1[456]',b)}              {4}breakpointtest_expr2 expr-7.64 {b = abs(-2)}                    {1}test_expr2 expr-7.65 {b = abs(+-2)}                   {1}test_expr2 expr-7.66 {b = abs(++-2)}                  {1}test_expr2 expr-7.67 {b = abs(+-+-2)}                 {1}test_expr2 expr-7.68 {b = abs(+-++-2)}                {1}test_expr2 expr-7.69 {b = abs(++++-2)}                {1}test_expr2 expr-7.70 {b = 5 - abs(+3)}                {1}test_expr2 expr-7.71 {b = 5 - abs(-3)}                {1}test_expr2 expr-7.72 {b = abs(-2.0)}                  {1}test_expr2 expr-7.73 {b = 6 - abs(-a)}                {2}test_expr2 expr-7.74 {b = abs(8.0)}                   {3}# Test the CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP expressions.#set sqlite_current_time 1157124849do_test expr-8.1 {  execsql {SELECT CURRENT_TIME}} {15:34:09}do_test expr-8.2 {  execsql {SELECT CURRENT_DATE}} {2006-09-01}do_test expr-8.3 {  execsql {SELECT CURRENT_TIMESTAMP}} {{2006-09-01 15:34:09}}ifcapable datetime {  do_test expr-8.4 {    execsql {SELECT CURRENT_TIME==time('now');}  } 1  do_test expr-8.5 {    execsql {SELECT CURRENT_DATE==date('now');}  } 1  do_test expr-8.6 {    execsql {SELECT CURRENT_TIMESTAMP==datetime('now');}  } 1}set sqlite_current_time 0do_test expr-9.1 {  execsql {SELECT round(-('-'||'123'))}} 123.0# Test an error message that can be generated by the LIKE expressiondo_test expr-10.1 {  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE ''}} {1 {ESCAPE expression must be a single character}}do_test expr-10.2 {  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE 'ab'}} {1 {ESCAPE expression must be a single character}}# If we specify an integer constant that is bigger than the largest# possible integer, code the integer as a real number.#do_test expr-11.1 {  execsql {SELECT typeof(9223372036854775807)}} {integer}do_test expr-11.2 {  execsql {SELECT typeof(00000009223372036854775807)}} {integer}do_test expr-11.3 {  execsql {SELECT typeof(+9223372036854775807)}} {integer}do_test expr-11.4 {  execsql {SELECT typeof(+000000009223372036854775807)}} {integer}do_test expr-11.5 {  execsql {SELECT typeof(9223372036854775808)}} {real}do_test expr-11.6 {  execsql {SELECT typeof(00000009223372036854775808)}} {real}do_test expr-11.7 {  execsql {SELECT typeof(+9223372036854775808)}} {real}do_test expr-11.8 {  execsql {SELECT typeof(+0000009223372036854775808)}} {real}do_test expr-11.11 {  execsql {SELECT typeof(-9223372036854775808)}} {integer}do_test expr-11.12 {  execsql {SELECT typeof(-00000009223372036854775808)}} {integer}do_test expr-11.13 {  execsql {SELECT typeof(-9223372036854775809)}} {real}do_test expr-11.14 {  execsql {SELECT typeof(-00000009223372036854775809)}} {real}# These two statements used to leak memory (because of missing %destructor# directives in parse.y).do_test expr-12.1 {  catchsql {    SELECT (CASE a>4 THEN 1 ELSE 0 END) FROM test1;  }} {1 {near "THEN": syntax error}}do_test expr-12.2 {  catchsql {    SELECT (CASE WHEN a>4 THEN 1 ELSE 0) FROM test1;  }} {1 {near ")": syntax error}}do_test expr-13.1 {  execsql {    SELECT 12345678901234567890;  }} {1.23456789012346e+19}# Implicit String->Integer conversion is used when possible.#do_test expr-13.2 {  execsql {    SELECT 0+'9223372036854775807'  }} {9223372036854775807}do_test expr-13.3 {  execsql {    SELECT '9223372036854775807'+0  }} {9223372036854775807}# If the value is too large, use String->Float conversion.#do_test expr-13.4 {  execsql {    SELECT 0+'9223372036854775808'  }} {9.22337203685478e+18}do_test expr-13.5 {  execsql {    SELECT '9223372036854775808'+0  }} {9.22337203685478e+18}# Use String->float conversion if the value is explicitly a floating# point value.#do_test expr-13.6 {  execsql {    SELECT 0+'9223372036854775807.0'  }} {9.22337203685478e+18}do_test expr-13.7 {  execsql {    SELECT '9223372036854775807.0'+0  }} {9.22337203685478e+18}finish_test

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -