Enhance the C function used to test sqlite3_create_function() from Tcl. (CVS 1476)

FossilOrigin-Name: c85e5f1528d098ea330ed0cf7e3c01cf9be93c10
This commit is contained in:
danielk1977 2004-05-27 14:23:36 +00:00
parent 49e4643ee8
commit 6d88bad4f9
4 changed files with 33 additions and 26 deletions

View File

@ -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

View File

@ -1 +1 @@
42247b2fb0c94e75a432b3e067fff9a1be328fc8
c85e5f1528d098ea330ed0cf7e3c01cf9be93c10

View 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);
}
/*

View 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(