]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the C function used to test sqlite3_create_function() from Tcl. (CVS 1476)
authordanielk1977 <danielk1977@noemail.net>
Thu, 27 May 2004 14:23:36 +0000 (14:23 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Thu, 27 May 2004 14:23:36 +0000 (14:23 +0000)
FossilOrigin-Name: c85e5f1528d098ea330ed0cf7e3c01cf9be93c10

manifest
manifest.uuid
src/test1.c
test/func.test

index d37a5397c6a9076b17158afcb6b7b6322cbcf065..4bed021c5d6a228cb93853a3dba4b4e2ee79ea66 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Test\ssqlite3_bind_blob().\s(CVS\s1475)
-D 2004-05-27T13:55:27
+C Enhance\sthe\sC\sfunction\sused\sto\stest\ssqlite3_create_function()\sfrom\sTcl.\s(CVS\s1476)
+D 2004-05-27T14:23:36
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -59,7 +59,7 @@ F src/sqlite.h.in cda883efb11c6f767eaf3fea06b3e3419d9cfe7f
 F src/sqliteInt.h 9c528cc7a41efafb0443655d29eafd10d8378952
 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
 F src/tclsqlite.c 877d0b96013a25b03ed6bd2d32917c42e84403bc
-F src/test1.c 70bf9b1702123ad5085337e302679a02382dad09
+F src/test1.c 32934478366531503d634968db414df17cb38238
 F src/test2.c 6195a1ca2c8d0d2d93644e86da3289b403486872
 F src/test3.c 5e4a6d596f982f6f47a5f9f75ede9b4a3b739968
 F src/test4.c 34848a9fd31aa65857b20a8bfc03aff77d8c3426
@@ -102,7 +102,7 @@ F test/enc2.test 669f46b4e298a22fb515cb52c55eb8dca57d8b4a
 F test/expr.test 8b62f3fcac64fbd5c3d43d7a7984245743dcbe65
 F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
 F test/format3.test 149cc166c97923fa60def047e90dd3fb32bba916
-F test/func.test 0ef8b2ae7ecc53067cd17cc1484a4a43392760d5
+F test/func.test b6d87075ff65babd6466b8a8dfc0d44f6a92df0c
 F test/hook.test 1a67ce0cd64a6455d016962542f2822458dccc49
 F test/in.test 0de39b02ceeca90993b096822fb5a884661c5b47
 F test/index.test 3d50e19807186682de60c53f507a831c1b4a38a2
@@ -206,7 +206,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 6d552af67cf6fa6935373ba39de5c47ebf613eb9
-R b03d381cd4bf5f980eaccd167389fb15
+P 42247b2fb0c94e75a432b3e067fff9a1be328fc8
+R 7d62fd5bc03776e1e9a987c53ee143b8
 U danielk1977
-Z 09411564a306f0b03eed4cc55d237508
+Z b23a568694419f227d6a8be83fed4002
index 96adfd961d4687205687c62d511620eb6ff67353..f909effd993f159067289a4d68b8cef4cf5eb91c 100644 (file)
@@ -1 +1 @@
-42247b2fb0c94e75a432b3e067fff9a1be328fc8
\ No newline at end of file
+c85e5f1528d098ea330ed0cf7e3c01cf9be93c10
\ No newline at end of file
index 0687bc3d23ea3cf519fe48f3ddb0467c901cd5c9..bf33d8bb64d7ddcb25a2c1080b45352427f69fde 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.64 2004/05/27 13:55:27 danielk1977 Exp $
+** $Id: test1.c,v 1.65 2004/05/27 14:23:36 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -672,26 +672,33 @@ static int sqlite_abort(
 static void testFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
   while( argc>=2 ){
     const char *zArg0 = sqlite3_value_text(argv[0]);
-    const char *zArg1 = sqlite3_value_text(argv[1]);
-    if( zArg0==0 ){
-      sqlite3_result_error(context, "first argument to test function "
-         "may not be NULL", -1);
-    }else if( sqlite3StrICmp(zArg0,"string")==0 ){
-      sqlite3_result_text(context, zArg1, -1, 1);
-    }else if( zArg1==0 ){
-      sqlite3_result_error(context, "2nd argument may not be NULL if the "
-         "first argument is not \"string\"", -1);
-    }else if( sqlite3StrICmp(zArg0,"int")==0 ){
-      sqlite3_result_int(context, atoi(zArg1));
-    }else if( sqlite3StrICmp(zArg0,"double")==0 ){
-      sqlite3_result_double(context, sqlite3AtoF(zArg1, 0));
+    if( zArg0 ){
+      if( 0==sqlite3StrICmp(zArg0, "int") ){
+        sqlite3_result_int(context, sqlite3_value_int(argv[1]));
+      }else if( sqlite3StrICmp(zArg0,"int64")==0 ){
+        sqlite3_result_int64(context, sqlite3_value_int64(argv[1]));
+      }else if( sqlite3StrICmp(zArg0,"string")==0 ){
+        sqlite3_result_text(context, sqlite3_value_text(argv[1]), -1, 1);
+      }else if( sqlite3StrICmp(zArg0,"double")==0 ){
+        sqlite3_result_double(context, sqlite3_value_double(argv[1]));
+      }else if( sqlite3StrICmp(zArg0,"null")==0 ){
+        sqlite3_result_null(context);
+      }else if( sqlite3StrICmp(zArg0,"value")==0 ){
+        sqlite3_result_value(context, argv[sqlite3_value_int(argv[1])]);
+      }else{
+        goto error_out;
+      }
     }else{
-      sqlite3_result_error(context,"first argument should be one of: "
-          "string int double", -1);
+      goto error_out;
     }
     argc -= 2;
     argv += 2;
   }
+  return;
+
+error_out:
+  sqlite3_result_error(context,"first argument should be one of: "
+      "int int64 string double null value", -1);
 }
 
 /*
index c3c84cead44b0857a7694c692d9bfff55cd99d3c..2636ffb64c8c58a712548c39dccf389d900b990e 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing built-in functions.
 #
-# $Id: func.test,v 1.18 2004/05/27 10:31:12 danielk1977 Exp $
+# $Id: func.test,v 1.19 2004/05/27 14:23:36 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -285,7 +285,7 @@ do_test func-10.1 {
   catchsql {
     SELECT testfunc(NULL,NULL);
   }
-} {1 {first argument to test function may not be NULL}}
+} {1 {first argument should be one of: int int64 string double null value}}
 do_test func-10.2 {
   execsql {
     SELECT testfunc(