]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Additional test cases and requirements marks for the unlikely(),
authordrh <drh@noemail.net>
Fri, 11 Oct 2013 16:35:49 +0000 (16:35 +0000)
committerdrh <drh@noemail.net>
Fri, 11 Oct 2013 16:35:49 +0000 (16:35 +0000)
likelihood() and instr() functions.

FossilOrigin-Name: 5f01cd36ee8678a07b79f9e01855daffb6bb8c43

manifest
manifest.uuid
src/resolve.c
src/shell.c
test/func.test
test/func3.test
test/instr.test

index 11c834a877ce7ddd107ea40f54a782bac3b32853..e7be7f74a7390c8dc1164e51e79d2ddad086cb45 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\svarious\sharmless\scompiler\swarnings.\s\sChange\sthe\s"warnings.sh"\sscript\sto\nwork\swith\sSTAT4\sinstead\sof\sSTAT3.
-D 2013-10-11T15:05:05.066
+C Additional\stest\scases\sand\srequirements\smarks\sfor\sthe\sunlikely(),\nlikelihood()\sand\sinstr()\sfunctions.
+D 2013-10-11T16:35:49.710
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -215,10 +215,10 @@ F src/pragma.c f4ff6e29c316d06bf7dffca0c8cee7c229cae42e
 F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f
 F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
 F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
-F src/resolve.c 7459801d02997b07e8b8da85ef255392ba1d022b
+F src/resolve.c 5f15b00644c36a1610b87857abf42db38c07519c
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 F src/select.c 15127b54cc11defb2cddef6914e1f384501a61c4
-F src/shell.c 5ee50ca3e35453bbd6ccdf1bdd0f6bbe9738e9fb
+F src/shell.c 6f11f0e9ded63d48e306f2c6858c521e568a47bb
 F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5
 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
@@ -566,9 +566,9 @@ F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584
 F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057
 F test/fts4unicode.test ebd937061e1ce096240d2352feb424587f2187b9
 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
-F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84
+F test/func.test c7e80a44eebac8604397eb2ad83d0d5d9d541237
 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
-F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a
+F test/func3.test dbccee9133cfef1473c59ec07b5f0262b9d72f9a
 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74
 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6
 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167
@@ -609,7 +609,7 @@ F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435
 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
 F test/insert4.test 87f6798f31d60c4e177622fcc3663367e6ecbd90
 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6
-F test/instr.test a34e1d46a9eefb098a7167ef0e730a4a3d82fba0
+F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2
 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4
 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc
 F test/intpkey.test a9674fc6195e0952e4e6105a9981ce1e48e7f215
@@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 03593817ab5abdd4bbaa5e47e2e4745eef025af9
-R 69bfe11e608e913aa8e62a6f442097f3
+P 7df06684ab36bfdad9e9aca6940b7a665c2a0cb5
+R 4f6661cda267d0bd057e23bc72d2b257
 U drh
-Z 351cca8cdf907d3e0b7192caaf766811
+Z 03f2ce5f38a3f7315fba8a787fd51abf
index 106229245a5599bcce0c7b7d7cde96d0d937facb..6b65ca082a286ed14608c258d5ff649ef66da682 100644 (file)
@@ -1 +1 @@
-7df06684ab36bfdad9e9aca6940b7a665c2a0cb5
\ No newline at end of file
+5f01cd36ee8678a07b79f9e01855daffb6bb8c43
\ No newline at end of file
index eacffc540636f4bef5c8b20acac10393c551ff38..dfe4b84c47d9dfd1ae71a75b9c37ee9039f17cf1 100644 (file)
@@ -707,6 +707,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
               pNC->nErr++;
             }
           }else{
+            /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
+            ** likelihood(X, 0.0625).
+            ** EVIDENCE-OF: R-35738-39582 The unlikely(X) fucntion is short-hand for
+            ** likelihood(X,0.0625). */
             pExpr->iTable = 62;  /* TUNING:  Default 2nd arg to unlikely() is 0.0625 */
           }             
         }
index 9f0e3530bc151c620e4747b1641338083bee26f3..41ea56492e71884843a56a4c4c65ab18864e1f26 100644 (file)
@@ -1204,7 +1204,7 @@ static int shell_exec(
               /* extract the data and data types */
               for(i=0; i<nCol; i++){
                 aiTypes[i] = x = sqlite3_column_type(pStmt, i);
-                if( x==SQLITE_BLOB && pArg->mode==MODE_Insert ){
+                if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){
                   azVals[i] = "";
                 }else{
                   azVals[i] = (char*)sqlite3_column_text(pStmt, i);
index d8303f8bf389e0ca09cd036ae08716019d383c83..7c7d55e1b706a9c16bd321cb3e3f4f0722645e4c 100644 (file)
@@ -1319,6 +1319,14 @@ do_test func-29.6 {
   set x
 } {1}
 
+# EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric
+# unicode code point corresponding to the first character of the string
+# X.
+#
+# EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a
+# string composed of characters having the unicode code point values of
+# integers X1 through XN, respectively.
+#
 do_execsql_test func-30.1 {SELECT unicode('$');} 36
 do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162
 do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364
index d5a462fe33e44f0e7fecf26576656d10d5ea70b2..2a2b7be4f463b76efe7ed36eef293571177096e7 100644 (file)
@@ -70,4 +70,87 @@ do_test func3-4.1 {
 } {1 SQLITE_MISUSE}
 do_test func3-4.2 { set destroyed } 1
 
+# EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns
+# argument X unchanged.
+#
+do_execsql_test func3-5.1 {
+  SELECT likelihood(9223372036854775807, 0.5);
+} {9223372036854775807}
+do_execsql_test func3-5.2 {
+  SELECT likelihood(-9223372036854775808, 0.5);
+} {-9223372036854775808}
+do_execsql_test func3-5.3 {
+  SELECT likelihood(14.125, 0.5);
+} {14.125}
+do_execsql_test func3-5.4 {
+  SELECT likelihood(NULL, 0.5);
+} {{}}
+do_execsql_test func3-5.5 {
+  SELECT likelihood('test-string', 0.5);
+} {test-string}
+do_execsql_test func3-5.6 {
+  SELECT quote(likelihood(x'010203000405', 0.5));
+} {X'010203000405'}
+
+# EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a
+# floating point constant between 0.0 and 1.0, inclusive.
+#
+do_execsql_test func3-5.7 {
+  SELECT likelihood(123, 1.0), likelihood(456, 0.0);
+} {123 456}
+do_test func3-5.8 {
+  catchsql {
+    SELECT likelihood(123, 1.000001);
+  }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_test func3-5.9 {
+  catchsql {
+    SELECT likelihood(123, -0.000001);
+  }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_test func3-5.10 {
+  catchsql {
+    SELECT likelihood(123, 0.5+0.3);
+  }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+
+# EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that
+# the code generator optimizes away so that it consumes no CPU cycles
+# during run-time (that is, during calls to sqlite3_step()).
+#
+do_test func3-5.20 {
+  db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)}
+} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
+
+
+# EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the
+# argument X unchanged.
+#
+do_execsql_test func3-5.30 {
+  SELECT unlikely(9223372036854775807);
+} {9223372036854775807}
+do_execsql_test func3-5.31 {
+  SELECT unlikely(-9223372036854775808);
+} {-9223372036854775808}
+do_execsql_test func3-5.32 {
+  SELECT unlikely(14.125);
+} {14.125}
+do_execsql_test func3-5.33 {
+  SELECT unlikely(NULL);
+} {{}}
+do_execsql_test func3-5.34 {
+  SELECT unlikely('test-string');
+} {test-string}
+do_execsql_test func3-5.35 {
+  SELECT quote(unlikely(x'010203000405'));
+} {X'010203000405'}
+
+# EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that
+# the code generator optimizes away so that it consumes no CPU cycles at
+# run-time (that is, during calls to sqlite3_step()).
+#
+do_test func3-5.40 {
+  db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))}
+} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
+
 finish_test
index b328cd1d2dc1cbd7a0dea1eff8718f5ad049c980..c8be4862b930641b2c73411467b57d97e91a4370 100644 (file)
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the built-in INSTR() functions.
 #
+# EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first
+# occurrence of string Y within string X and returns the number of prior
+# characters plus 1, or 0 if Y is nowhere found within X.
+#
+
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -199,12 +204,48 @@ do_test instr-1.54 {
 do_test instr-1.55 {
   db eval {SELECT instr(x'78c3a4e282ac79','y');}
 } {4}
-do_test instr-1.56 {
+
+# EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then
+# instr(X,Y) returns one more than the number bytes prior to the first
+# occurrence of Y, or 0 if Y does not occur anywhere within X.
+#
+do_test instr-1.56.1 {
   db eval {SELECT instr(x'78c3a4e282ac79',x'79');}
 } {7}
-do_test instr-1.57 {
+do_test instr-1.56.2 {
+  db eval {SELECT instr(x'78c3a4e282ac79',x'7a');}
+} {0}
+do_test instr-1.56.3 {
+  db eval {SELECT instr(x'78c3a4e282ac79',x'78');}
+} {1}
+do_test instr-1.56.3 {
+  db eval {SELECT instr(x'78c3a4e282ac79',x'a4');}
+} {3}
+
+# EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are
+# non-NULL and are not BLOBs then both are interpreted as strings.
+#
+do_test instr-1.57.1 {
   db eval {SELECT instr('xä€y',x'79');}
 } {4}
+do_test instr-1.57.2 {
+  db eval {SELECT instr('xä€y',x'a4');}
+} {0}
+do_test instr-1.57.3 {
+  db eval {SELECT instr(x'78c3a4e282ac79','y');}
+} {4}
 
+# EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y)
+# then the result is NULL.
+#
+do_execsql_test instr-1.60 {
+  SELECT coalesce(instr(NULL,'abc'), 999);
+} {999}
+do_execsql_test instr-1.61 {
+  SELECT coalesce(instr('abc',NULL), 999);
+} {999}
+do_execsql_test instr-1.62 {
+  SELECT coalesce(instr(NULL,NULL), 999);
+} {999}
 
 finish_test