Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added additional tests. No new errors found. (CVS 653) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8924a7f5bab790ab552332d6359028d0 |
User & Date: | drh 2002-07-01 00:31:36.000 |
Context
2002-07-01
| ||
12:27 | Fix for tickets #90 and #89: Make the AS keyword optional again. (CVS 654) (check-in: 1f8a73b1c3 user: drh tags: trunk) | |
00:31 | Added additional tests. No new errors found. (CVS 653) (check-in: 8924a7f5ba user: drh tags: trunk) | |
2002-06-29
| ||
02:20 | Add a few more tests and fix a few bugs that the tests uncovered. (CVS 652) (check-in: 91c0db66c8 user: drh 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.11 2002/07/01 00:31:36 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> /* |
︙ | ︙ | |||
210 211 212 213 214 215 216 | } } } /* ** Implementation of the x_sqlite_exec() function. This function takes ** a single argument and attempts to execute that argument as SQL code. | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | } } } /* ** Implementation of the x_sqlite_exec() function. This function takes ** a single argument and attempts to execute that argument as SQL code. ** This is illegal and should set the SQLITE_MISUSE flag on the database. ** ** This routine simulates the effect of having two threads attempt to ** use the same database at the same time. */ static void sqliteExecFunc(sqlite_func *context, int argc, const char **argv){ sqlite_exec((sqlite*)sqlite_user_data(context), argv[0], 0, 0, 0); } |
︙ | ︙ | |||
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ char **argv /* Text of each argument */ ){ assert( interp==0 ); /* This will always fail */ return TCL_OK; } /* ** Register commands with the TCL interpreter. */ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite_search_count; Tcl_CreateCommand(interp, "sqlite_mprintf_int", sqlite_mprintf_int, 0, 0); Tcl_CreateCommand(interp, "sqlite_mprintf_str", sqlite_mprintf_str, 0, 0); Tcl_CreateCommand(interp, "sqlite_mprintf_double", sqlite_mprintf_double,0,0); Tcl_CreateCommand(interp, "sqlite_open", sqlite_test_open, 0, 0); Tcl_CreateCommand(interp, "sqlite_last_insert_rowid", test_last_rowid, 0, 0); Tcl_CreateCommand(interp, "sqlite_exec_printf", test_exec_printf, 0, 0); Tcl_CreateCommand(interp, "sqlite_get_table_printf", test_get_table_printf, 0, 0); Tcl_CreateCommand(interp, "sqlite_close", sqlite_test_close, 0, 0); Tcl_CreateCommand(interp, "sqlite_create_function", sqlite_test_create_function, 0, 0); Tcl_CreateCommand(interp, "sqlite_create_aggregate", sqlite_test_create_aggregate, 0, 0); Tcl_LinkVar(interp, "sqlite_search_count", (char*)&sqlite_search_count, TCL_LINK_INT); #ifdef MEMORY_DEBUG Tcl_CreateCommand(interp, "sqlite_malloc_fail", sqlite_malloc_fail, 0, 0); Tcl_CreateCommand(interp, "sqlite_malloc_stat", sqlite_malloc_stat, 0, 0); #endif Tcl_CreateCommand(interp, "sqlite_abort", sqlite_abort, 0, 0); return TCL_OK; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ char **argv /* Text of each argument */ ){ assert( interp==0 ); /* This will always fail */ return TCL_OK; } /* ** The following routine is a user-defined SQL function whose purpose ** is to test the sqlite_set_result() API. */ static void testFunc(sqlite_func *context, int argc, const char **argv){ while( argc>=2 ){ if( argv[0]==0 ){ sqlite_set_result_error(context, "first argument to test function " "may not be NULL", -1); }else if( sqliteStrICmp(argv[0],"string")==0 ){ sqlite_set_result_string(context, argv[1], -1); }else if( argv[1]==0 ){ sqlite_set_result_error(context, "2nd argument may not be NULL if the " "first argument is not \"string\"", -1); }else if( sqliteStrICmp(argv[0],"int")==0 ){ sqlite_set_result_int(context, atoi(argv[1])); }else if( sqliteStrICmp(argv[0],"double")==0 ){ sqlite_set_result_double(context, atof(argv[1])); }else{ sqlite_set_result_error(context,"first argument should be one of: " "string int double", -1); } argc -= 2; argv += 2; } } /* ** Usage: sqlite_register_test_function DB NAME ** ** Register the test SQL function on the database DB under the name NAME. */ static int sqlite_register_test_function( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ char **argv /* Text of each argument */ ){ sqlite *db; int rc; if( argc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB FUNCTION-NAME", 0); return TCL_ERROR; } db = (sqlite*)strtol(argv[1], 0, 0); rc = sqlite_create_function(db, argv[2], -1, testFunc, 0); if( rc!=0 ){ Tcl_AppendResult(interp, sqlite_error_string(rc), 0); return TCL_ERROR; } return TCL_OK; } /* ** Register commands with the TCL interpreter. */ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite_search_count; Tcl_CreateCommand(interp, "sqlite_mprintf_int", sqlite_mprintf_int, 0, 0); Tcl_CreateCommand(interp, "sqlite_mprintf_str", sqlite_mprintf_str, 0, 0); Tcl_CreateCommand(interp, "sqlite_mprintf_double", sqlite_mprintf_double,0,0); Tcl_CreateCommand(interp, "sqlite_open", sqlite_test_open, 0, 0); Tcl_CreateCommand(interp, "sqlite_last_insert_rowid", test_last_rowid, 0, 0); Tcl_CreateCommand(interp, "sqlite_exec_printf", test_exec_printf, 0, 0); Tcl_CreateCommand(interp, "sqlite_get_table_printf", test_get_table_printf, 0, 0); Tcl_CreateCommand(interp, "sqlite_close", sqlite_test_close, 0, 0); Tcl_CreateCommand(interp, "sqlite_create_function", sqlite_test_create_function, 0, 0); Tcl_CreateCommand(interp, "sqlite_create_aggregate", sqlite_test_create_aggregate, 0, 0); Tcl_CreateCommand(interp, "sqlite_register_test_function", sqlite_register_test_function, 0, 0); Tcl_LinkVar(interp, "sqlite_search_count", (char*)&sqlite_search_count, TCL_LINK_INT); #ifdef MEMORY_DEBUG Tcl_CreateCommand(interp, "sqlite_malloc_fail", sqlite_malloc_fail, 0, 0); Tcl_CreateCommand(interp, "sqlite_malloc_stat", sqlite_malloc_stat, 0, 0); #endif Tcl_CreateCommand(interp, "sqlite_abort", sqlite_abort, 0, 0); return TCL_OK; } |
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.14 2002/07/01 00:31:36 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test func-0.0 { |
︙ | ︙ | |||
268 269 270 271 272 273 274 275 276 | # How do you test the random() function in a meaningful, deterministic way? # do_test func-9.1 { execsql { SELECT random() is not null; } } {1} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | # How do you test the random() function in a meaningful, deterministic way? # do_test func-9.1 { execsql { SELECT random() is not null; } } {1} # Use the "sqlite_register_test_function" TCL command which is part of # the text fixture in order to verify correct operation of some of # the user-defined SQL function APIs that are not used by the built-in # functions. # 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 to test function may not be NULL}} do_test func-10.2 { execsql { SELECT testfunc( 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'int', 1234 ); } } {1234} do_test func-10.3 { execsql { SELECT testfunc( 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'string', NULL ); } } {{}} do_test func-10.4 { execsql { SELECT testfunc( 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'double', 1.234 ); } } {1.234} do_test func-10.5 { execsql { SELECT testfunc( 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'int', 1234, 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'string', NULL, 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'double', 1.234, 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'int', 1234, 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'string', NULL, 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'double', 1.234 ); } } {1.234} finish_test |
Changes to test/in.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 the IN and BETWEEN operator. # | | | 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 the IN and BETWEEN operator. # # $Id: in.test,v 1.7 2002/07/01 00:31:36 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Generate the test data we will need for the first squences of tests. # do_test in-1.0 { |
︙ | ︙ | |||
163 164 165 166 167 168 169 | CREATE TABLE ta(a INTEGER PRIMARY KEY, b); INSERT INTO ta VALUES(1,1); INSERT INTO ta VALUES(2,2); INSERT INTO ta VALUES(3,3); INSERT INTO ta VALUES(4,4); INSERT INTO ta VALUES(6,6); INSERT INTO ta VALUES(8,8); | > > | > > | | | | | < | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | CREATE TABLE ta(a INTEGER PRIMARY KEY, b); INSERT INTO ta VALUES(1,1); INSERT INTO ta VALUES(2,2); INSERT INTO ta VALUES(3,3); INSERT INTO ta VALUES(4,4); INSERT INTO ta VALUES(6,6); INSERT INTO ta VALUES(8,8); INSERT INTO ta VALUES(10, 'This is a key that is long enough to require a malloc in the VDBE'); SELECT * FROM ta WHERE a<10; } } {1 1 2 2 3 3 4 4 6 6 8 8} do_test in-6.2 { execsql { CREATE TABLE tb(a INTEGER PRIMARY KEY, b); INSERT INTO tb VALUES(1,1); INSERT INTO tb VALUES(2,2); INSERT INTO tb VALUES(3,3); INSERT INTO tb VALUES(5,5); INSERT INTO tb VALUES(7,7); INSERT INTO tb VALUES(9,9); INSERT INTO tb VALUES(11, 'This is a key that is long enough to require a malloc in the VDBE'); SELECT * FROM tb WHERE a<10; } } {1 1 2 2 3 3 5 5 7 7 9 9} do_test in-6.3 { execsql { SELECT a FROM ta WHERE b IN (SELECT a FROM tb); } } {1 2 3} do_test in-6.4 { execsql { SELECT a FROM ta WHERE b NOT IN (SELECT a FROM tb); } } {4 6 8 10} do_test in-6.5 { execsql { SELECT a FROM ta WHERE b IN (SELECT b FROM tb); } } {1 2 3 10} do_test in-6.6 { execsql { SELECT a FROM ta WHERE b NOT IN (SELECT b FROM tb); } } {4 6 8} do_test in-6.7 { execsql { SELECT a FROM ta WHERE a IN (SELECT a FROM tb); } } {1 2 3} do_test in-6.8 { execsql { SELECT a FROM ta WHERE a NOT IN (SELECT a FROM tb); } } {4 6 8 10} do_test in-6.9 { execsql { SELECT a FROM ta WHERE a IN (SELECT b FROM tb); } } {1 2 3} do_test in-6.10 { execsql { SELECT a FROM ta WHERE a NOT IN (SELECT b FROM tb); } } {4 6 8 10} finish_test |