Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Enhance the C function used to test sqlite3_create_function() from Tcl. (CVS 1476) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c85e5f1528d098ea330ed0cf7e3c01cf |
User & Date: | danielk1977 2004-05-27 14:23:36.000 |
Context
2004-05-27
| ||
17:22 | Remove the COPY command. (CVS 1477) (check-in: 287f86731c user: drh tags: trunk) | |
14:23 | Enhance the C function used to test sqlite3_create_function() from Tcl. (CVS 1476) (check-in: c85e5f1528 user: danielk1977 tags: trunk) | |
13:55 | Test sqlite3_bind_blob(). (CVS 1475) (check-in: 42247b2fb0 user: danielk1977 tags: trunk) | |
Changes
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.65 2004/05/27 14:23:36 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
668 669 670 671 672 673 674 | /* ** The following routine is a user-defined SQL function whose purpose ** is to test the sqlite_set_result() API. */ static void testFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ while( argc>=2 ){ const char *zArg0 = sqlite3_value_text(argv[0]); | < | > | | > | | | | < | | | | | | > > | > > > > > | 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | /* ** The following routine is a user-defined SQL function whose purpose ** is to test the sqlite_set_result() API. */ static void testFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ while( argc>=2 ){ const char *zArg0 = sqlite3_value_text(argv[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{ 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); } /* ** Usage: sqlite_register_test_function DB NAME ** ** Register the test SQL function on the database DB under the name NAME. */ |
︙ | ︙ |
Changes to test/func.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # # $Id: func.test,v 1.19 2004/05/27 14:23:36 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test func-0.0 { |
︙ | ︙ | |||
281 282 283 284 285 286 287 | db close set ::DB [sqlite db test.db] sqlite_register_test_function $::DB testfunc do_test func-10.1 { catchsql { SELECT testfunc(NULL,NULL); } | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | db close set ::DB [sqlite db test.db] sqlite_register_test_function $::DB testfunc do_test func-10.1 { catchsql { SELECT testfunc(NULL,NULL); } } {1 {first argument should be one of: int int64 string double null value}} do_test func-10.2 { execsql { SELECT testfunc( 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'int', 1234 ); } |
︙ | ︙ |