Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | More coverage testing. (CVS 1754) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
332921041040b343b6b568685ff55d21 |
User & Date: | danielk1977 2004-06-28 13:09:11.000 |
Context
2004-06-29
| ||
03:29 | Try to get threads working again on Linux. (CVS 1755) (check-in: a8417cb83e user: drh tags: trunk) | |
2004-06-28
| ||
13:09 | More coverage testing. (CVS 1754) (check-in: 3329210410 user: danielk1977 tags: trunk) | |
11:52 | Get all tests working under win2k. (CVS 1753) (check-in: 168112c8b7 user: drh tags: trunk) | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: func.c,v 1.77 2004/06/28 13:09:11 danielk1977 Exp $ */ #include <ctype.h> #include <math.h> #include <stdlib.h> #include <assert.h> #include "sqliteInt.h" #include "vdbeInt.h" |
︙ | ︙ | |||
790 791 792 793 794 795 796 797 798 799 | } static void test_destructor( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ char *zVal; test_destructor_count_var++; assert( nArg==1 ); if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; | > > > > | > > | > | > > > > > | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | } static void test_destructor( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ char *zVal; int len; sqlite *db = sqlite3_user_data(pCtx); test_destructor_count_var++; assert( nArg==1 ); if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; len = sqlite3ValueBytes(argv[0], db->enc); zVal = sqliteMalloc(len+3); zVal[len] = 0; zVal[len-1] = 0; assert( zVal ); zVal++; memcpy(zVal, sqlite3ValueText(argv[0], db->enc), len); if( db->enc==SQLITE_UTF8 ){ sqlite3_result_text(pCtx, zVal, -1, destructor); }else if( db->enc==SQLITE_UTF16LE ){ sqlite3_result_text16le(pCtx, zVal, -1, destructor); }else{ sqlite3_result_text16be(pCtx, zVal, -1, destructor); } } static void test_destructor_count( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ sqlite3_result_int(pCtx, test_destructor_count_var); |
︙ | ︙ | |||
1006 1007 1008 1009 1010 1011 1012 | ** functions. This should be the only routine in this file with ** external linkage. */ void sqlite3RegisterBuiltinFunctions(sqlite *db){ static struct { char *zName; signed char nArg; | | | | | | | | | | > | | | | | | | | | | | < | | | | | | | | | | | | 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 | ** functions. This should be the only routine in this file with ** external linkage. */ void sqlite3RegisterBuiltinFunctions(sqlite *db){ static struct { char *zName; signed char nArg; u8 argType; /* 0: none. 1: db 2: (-1) */ u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */ u8 needCollSeq; void (*xFunc)(sqlite3_context*,int,sqlite3_value **); } aFuncs[] = { { "min", -1, 0, SQLITE_UTF8, 1, minmaxFunc }, { "min", 0, 0, SQLITE_UTF8, 1, 0 }, { "max", -1, 2, SQLITE_UTF8, 1, minmaxFunc }, { "max", 0, 2, SQLITE_UTF8, 1, 0 }, { "typeof", 1, 0, SQLITE_UTF8, 0, typeofFunc }, { "length", 1, 0, SQLITE_UTF8, 0, lengthFunc }, { "substr", 3, 0, SQLITE_UTF8, 0, substrFunc }, { "substr", 3, 0, SQLITE_UTF16LE, 0, sqlite3utf16Substr }, { "abs", 1, 0, SQLITE_UTF8, 0, absFunc }, { "round", 1, 0, SQLITE_UTF8, 0, roundFunc }, { "round", 2, 0, SQLITE_UTF8, 0, roundFunc }, { "upper", 1, 0, SQLITE_UTF8, 0, upperFunc }, { "lower", 1, 0, SQLITE_UTF8, 0, lowerFunc }, { "coalesce", -1, 0, SQLITE_UTF8, 0, ifnullFunc }, { "coalesce", 0, 0, SQLITE_UTF8, 0, 0 }, { "coalesce", 1, 0, SQLITE_UTF8, 0, 0 }, { "ifnull", 2, 0, SQLITE_UTF8, 1, ifnullFunc }, { "random", -1, 0, SQLITE_UTF8, 0, randomFunc }, { "like", 2, 0, SQLITE_UTF8, 0, likeFunc }, { "glob", 2, 0, SQLITE_UTF8, 0, globFunc }, { "nullif", 2, 0, SQLITE_UTF8, 0, nullifFunc }, { "sqlite_version", 0, 0, SQLITE_UTF8, 0, versionFunc}, { "quote", 1, 0, SQLITE_UTF8, 0, quoteFunc }, { "last_insert_rowid", 0, 1, SQLITE_UTF8, 0, last_insert_rowid }, { "changes", 0, 1, SQLITE_UTF8, 0, changes }, { "total_changes", 0, 1, SQLITE_UTF8, 0, total_changes }, #ifdef SQLITE_SOUNDEX { "soundex", 1, 0, SQLITE_UTF8, 0, soundexFunc}, #endif #ifdef SQLITE_TEST { "randstr", 2, 0, SQLITE_UTF8, 0, randStr }, { "test_destructor", 1, 1, SQLITE_UTF8, 0, test_destructor}, { "test_destructor_count", 0, 0, SQLITE_UTF8, 0, test_destructor_count}, { "test_auxdata", -1, 0, SQLITE_UTF8, 0, test_auxdata}, #endif }; static struct { char *zName; signed char nArg; u8 argType; u8 needCollSeq; |
︙ | ︙ |
Changes to src/sqliteInt.h.
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. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 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. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.302 2004/06/28 13:09:11 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ #include "config.h" #include "sqlite3.h" #include "hash.h" |
︙ | ︙ | |||
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | CollSeq *sqlite3FindCollSeq(sqlite *,u8 enc, const char *,int,int); CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName); CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr); int sqlite3CheckCollSeq(Parse *, CollSeq *); int sqlite3CheckIndexCollSeq(Parse *, Index *); int sqlite3CheckObjectName(Parse *, const char *); void sqlite3VdbeSetChanges(sqlite3 *, int); const void *sqlite3ValueText(sqlite3_value*, u8); int sqlite3ValueBytes(sqlite3_value*, u8); void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, void(*)(void*)); void sqlite3ValueFree(sqlite3_value*); sqlite3_value *sqlite3ValueNew(); sqlite3_value *sqlite3GetTransientValue(sqlite *db); #endif | > | 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 | CollSeq *sqlite3FindCollSeq(sqlite *,u8 enc, const char *,int,int); CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName); CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr); int sqlite3CheckCollSeq(Parse *, CollSeq *); int sqlite3CheckIndexCollSeq(Parse *, Index *); int sqlite3CheckObjectName(Parse *, const char *); void sqlite3VdbeSetChanges(sqlite3 *, int); void sqlite3utf16Substr(sqlite3_context *,int,sqlite3_value **); const void *sqlite3ValueText(sqlite3_value*, u8); int sqlite3ValueBytes(sqlite3_value*, u8); void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, void(*)(void*)); void sqlite3ValueFree(sqlite3_value*); sqlite3_value *sqlite3ValueNew(); sqlite3_value *sqlite3GetTransientValue(sqlite *db); #endif |
Changes to src/utf.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.26 2004/06/28 13:09:11 danielk1977 Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx |
︙ | ︙ | |||
205 206 207 208 209 210 211 212 213 214 215 216 217 218 | c += (*zIn++); \ if( c>=0xD800 && c<=0xE000 ){ \ int c2 = ((*zIn++)<<8); \ c2 += (*zIn++); \ c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ } \ } /* ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). */ /* #define TRANSLATE_TRACE 1 */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | c += (*zIn++); \ if( c>=0xD800 && c<=0xE000 ){ \ int c2 = ((*zIn++)<<8); \ c2 += (*zIn++); \ c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ } \ } #define SKIP_UTF16BE(zIn){ \ if( *zIn>=0xD8 && (*zIn<0xE0 || (*zIn==0xE0 && *(zIn+1)==0x00)) ){ \ zIn += 4; \ }else{ \ zIn += 2; \ } \ } #define SKIP_UTF16LE(zIn){ \ zIn++; \ if( *zIn>=0xD8 && (*zIn<0xE0 || (*zIn==0xE0 && *(zIn-1)==0x00)) ){ \ zIn += 3; \ }else{ \ zIn += 1; \ } \ } #define RSKIP_UTF16LE(zIn){ \ if( *zIn>=0xD8 && (*zIn<0xE0 || (*zIn==0xE0 && *(zIn-1)==0x00)) ){ \ zIn -= 4; \ }else{ \ zIn -= 2; \ } \ } #define RSKIP_UTF16BE(zIn){ \ zIn--; \ if( *zIn>=0xD8 && (*zIn<0xE0 || (*zIn==0xE0 && *(zIn+1)==0x00)) ){ \ zIn -= 3; \ }else{ \ zIn -= 1; \ } \ } /* ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). */ /* #define TRANSLATE_TRACE 1 */ |
︙ | ︙ | |||
502 503 504 505 506 507 508 509 510 511 512 513 514 515 | zString++; break; } } } return *zString==0; } #if defined(SQLITE_TEST) /* ** This routine is called from the TCL test function "translate_selftest". ** It checks that the primitives for serializing and deserializing ** characters in each encoding are inverses of each other. */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | zString++; break; } } } return *zString==0; } /* ** UTF-16 implementation of the substr() */ void sqlite3utf16Substr( sqlite3_context *context, int argc, sqlite3_value **argv ){ int y, z; unsigned char const *zStr; unsigned char const *zStrEnd; unsigned char const *zStart; unsigned char const *zEnd; int i; zStr = (unsigned char const *)sqlite3_value_text16(argv[0]); zStrEnd = &zStr[sqlite3_value_bytes16(argv[0])]; y = sqlite3_value_int(argv[1]); z = sqlite3_value_int(argv[2]); if( y>0 ){ y = y-1; zStart = zStr; if( SQLITE_UTF16BE==SQLITE_UTF16NATIVE ){ for(i=0; i<y && zStart<zStrEnd; i++) SKIP_UTF16BE(zStart); }else{ for(i=0; i<y && zStart<zStrEnd; i++) SKIP_UTF16LE(zStart); } }else{ zStart = zStrEnd; if( SQLITE_UTF16BE==SQLITE_UTF16NATIVE ){ for(i=y; i<0 && zStart>zStr; i++) RSKIP_UTF16BE(zStart); }else{ for(i=y; i<0 && zStart>zStr; i++) RSKIP_UTF16LE(zStart); } for(; i<0; i++) z -= 1; } zEnd = zStart; if( SQLITE_UTF16BE==SQLITE_UTF16NATIVE ){ for(i=0; i<z && zEnd<zStrEnd; i++) SKIP_UTF16BE(zEnd); }else{ for(i=0; i<z && zEnd<zStrEnd; i++) SKIP_UTF16LE(zEnd); } sqlite3_result_text16(context, zStart, zEnd-zStart, SQLITE_TRANSIENT); } #if defined(SQLITE_TEST) /* ** This routine is called from the TCL test function "translate_selftest". ** It checks that the primitives for serializing and deserializing ** characters in each encoding are inverses of each other. */ |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.393 2004/06/28 13:09:11 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* |
︙ | ︙ | |||
1284 1285 1286 1287 1288 1289 1290 | sqlite3VdbeChangeEncoding(&ctx.s, db->enc); *pTos = ctx.s; if( pTos->flags & MEM_Short ){ pTos->z = pTos->zShort; } /* If the function returned an error, throw an exception */ if( ctx.isError ){ | > | > | > > | 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | sqlite3VdbeChangeEncoding(&ctx.s, db->enc); *pTos = ctx.s; if( pTos->flags & MEM_Short ){ pTos->z = pTos->zShort; } /* If the function returned an error, throw an exception */ if( ctx.isError ){ if( !(pTos->flags&MEM_Str) ){ sqlite3SetString(&p->zErrMsg, "user function error", (char*)0); }else{ sqlite3SetString(&p->zErrMsg, sqlite3_value_text(pTos), (char*)0); sqlite3VdbeChangeEncoding(pTos, db->enc); } rc = SQLITE_ERROR; } break; } /* Opcode: BitAnd * * * ** |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
337 338 339 340 341 342 343 | ** statement pStmt. */ const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){ Vdbe *p = (Vdbe *)pStmt; Mem *pColName; if( N>=sqlite3_column_count(pStmt) || N<0 ){ | < < < < | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | ** statement pStmt. */ const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){ Vdbe *p = (Vdbe *)pStmt; Mem *pColName; if( N>=sqlite3_column_count(pStmt) || N<0 ){ return 0; } pColName = &(p->aColName[N]); return sqlite3_value_text(pColName); } /* ** Return the name of the 'i'th column of the result set of SQL statement ** pStmt, encoded as UTF-16. */ const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){ Vdbe *p = (Vdbe *)pStmt; Mem *pColName; if( N>=sqlite3_column_count(pStmt) || N<0 ){ return 0; } pColName = &(p->aColName[N]); return sqlite3_value_text16(pColName); } /* ** Return the column declaration type (if applicable) of the 'i'th column ** of the result set of SQL statement pStmt, encoded as UTF-8. */ const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){ Vdbe *p = (Vdbe *)pStmt; Mem *pColName; if( N>=sqlite3_column_count(pStmt) || N<0 ){ return 0; } pColName = &(p->aColName[N+sqlite3_column_count(pStmt)]); return sqlite3_value_text(pColName); } /* ** Return the column declaration type (if applicable) of the 'i'th column ** of the result set of SQL statement pStmt, encoded as UTF-16. */ const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){ Vdbe *p = (Vdbe *)pStmt; Mem *pColName; if( N>=sqlite3_column_count(pStmt) || N<0 ){ return 0; } pColName = &(p->aColName[N+sqlite3_column_count(pStmt)]); return sqlite3_value_text16(pColName); } |
︙ | ︙ | |||
455 456 457 458 459 460 461 | int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ int rc; Vdbe *p = (Vdbe *)pStmt; rc = vdbeUnbind(p, i); if( rc==SQLITE_OK ){ sqlite3VdbeMemSetDouble(&p->apVar[i-1], rValue); } | | | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ int rc; Vdbe *p = (Vdbe *)pStmt; rc = vdbeUnbind(p, i); if( rc==SQLITE_OK ){ sqlite3VdbeMemSetDouble(&p->apVar[i-1], rValue); } return rc; } int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){ return sqlite3_bind_int64(p, i, (i64)iValue); } int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){ int rc; Vdbe *p = (Vdbe *)pStmt; |
︙ | ︙ |
Changes to src/vdbemem.c.
︙ | ︙ | |||
493 494 495 496 497 498 499 | */ assert( !pColl || pColl->xCmp ); if( pColl ){ if( pMem1->enc==pColl->enc ){ return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); }else{ | > | > > > > > | 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 | */ assert( !pColl || pColl->xCmp ); if( pColl ){ if( pMem1->enc==pColl->enc ){ return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); }else{ u8 origEnc = pMem1->enc; rc = pColl->xCmp( pColl->pUser, sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc), sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc), sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc), sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc) ); sqlite3ValueBytes((sqlite3_value*)pMem1, origEnc); sqlite3ValueText((sqlite3_value*)pMem1, origEnc); sqlite3ValueBytes((sqlite3_value*)pMem2, origEnc); sqlite3ValueText((sqlite3_value*)pMem2, origEnc); return rc; } } /* If a NULL pointer was passed as the collate function, fall through ** to the blob case and use memcmp(). */ } /* Both values must be blobs. Compare using memcmp(). */ |
︙ | ︙ |
Changes to test/bind.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 September 6 # # 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 script testing the sqlite_bind API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 September 6 # # 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 script testing the sqlite_bind API. # # $Id: bind.test,v 1.14 2004/06/28 13:09:11 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt N VALS COLS} { upvar VALS vals |
︙ | ︙ | |||
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | do_test bind-8.6 { sqlite3_errmsg $DB } {bind index out of range} do_test bind-8.7 { encoding convertfrom unicode [sqlite3_errmsg16 $DB] } {bind index out of range} do_test bind-9.99 { sqlite3_finalize $VM } SQLITE_OK finish_test | > > > > > > > > > > > > > > > > > > > > > > > > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | do_test bind-8.6 { sqlite3_errmsg $DB } {bind index out of range} do_test bind-8.7 { encoding convertfrom unicode [sqlite3_errmsg16 $DB] } {bind index out of range} do_test bind-8.8 { catch { sqlite3_bind_blob $VM 0 "abc" 3 } } {1} do_test bind-8.9 { catch { sqlite3_bind_blob $VM 4 "abc" 3 } } {1} do_test bind-8.10 { catch { sqlite3_bind_text $VM 0 "abc" 3 } } {1} do_test bind-8.11 { catch { sqlite3_bind_text16 $VM 4 "abc" 2 } } {1} do_test bind-8.12 { catch { sqlite3_bind_int $VM 0 5 } } {1} do_test bind-8.13 { catch { sqlite3_bind_int $VM 4 5 } } {1} do_test bind-8.14 { catch { sqlite3_bind_double $VM 0 5.0 } } {1} do_test bind-8.15 { catch { sqlite3_bind_double $VM 4 6.0 } } {1} do_test bind-9.99 { sqlite3_finalize $VM } SQLITE_OK finish_test |
Changes to test/capi3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # 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 script testing the callback-free C/C++ API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 January 29 # # 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 script testing the callback-free C/C++ API. # # $Id: capi3.test,v 1.14 2004/06/28 13:09:11 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
177 178 179 180 181 182 183 | # proc check_header {STMT test names decltypes} { # Use the return value of sqlite3_column_count() to build # a list of column indexes. i.e. If sqlite3_column_count # is 3, build the list {0 1 2}. set ::idxlist [list] | | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | # proc check_header {STMT test names decltypes} { # Use the return value of sqlite3_column_count() to build # a list of column indexes. i.e. If sqlite3_column_count # is 3, build the list {0 1 2}. set ::idxlist [list] set ::numcols [sqlite3_column_count $STMT] for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i} # Column names in UTF-8 do_test $test.1 { set cnamelist [list] foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} set cnamelist } $names |
︙ | ︙ | |||
228 229 230 231 232 233 234 235 236 237 238 239 240 241 | set cnamelist [list] foreach i $idxlist { lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]] } set cnamelist } $decltypes } # This proc is used to test the following APIs: # # sqlite3_data_count # sqlite3_column_type # sqlite3_column_int | > > > > > > > > > > > > > > | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | set cnamelist [list] foreach i $idxlist { lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]] } set cnamelist } $decltypes # Test some out of range conditions: do_test $test.7 { list \ [sqlite3_column_name $STMT -1] \ [sqlite3_column_name16 $STMT -1] \ [sqlite3_column_decltype $STMT -1] \ [sqlite3_column_decltype16 $STMT -1] \ [sqlite3_column_name $STMT $numcols] \ [sqlite3_column_name16 $STMT $numcols] \ [sqlite3_column_decltype $STMT $numcols] \ [sqlite3_column_decltype16 $STMT $numcols] } {{} {} {} {} {} {} {} {}} } # This proc is used to test the following APIs: # # sqlite3_data_count # sqlite3_column_type # sqlite3_column_int |
︙ | ︙ | |||
271 272 273 274 275 276 277 | foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]} set types } $types # Integers do_test $test.2 { set ints [list] | | | > > > > | > | > > | | | > > > > | > | > > | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > | 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 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]} set types } $types # Integers do_test $test.2 { set ints [list] foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]} set ints } $ints # bytes set lens [list] foreach i $::idxlist { lappend lens [string length [lindex $strings $i]] } do_test $test.3 { set bytes [list] set lens [list] foreach i $idxlist { lappend bytes [sqlite3_column_bytes $STMT $i] } set bytes } $lens # bytes16 set lens [list] foreach i $::idxlist { lappend lens [expr 2 * [string length [lindex $strings $i]]] } do_test $test.4 { set bytes [list] set lens [list] foreach i $idxlist { lappend bytes [sqlite3_column_bytes16 $STMT $i] } set bytes } $lens # Blob do_test $test.5 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]} set utf8 } $strings # UTF-8 do_test $test.6 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]} set utf8 } $strings # Floats do_test $test.7 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]} set utf8 } $doubles # UTF-16 do_test $test.8 { set utf8 [list] foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]} set utf8 } $strings # Integers do_test $test.9 { set ints [list] foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]} set ints } $ints # Floats do_test $test.10 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]} set utf8 } $doubles # UTF-8 do_test $test.11 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]} set utf8 } $strings # Types do_test $test.12 { set types [list] foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]} set types } $types # Test that an out of range request returns the equivalent of NULL do_test $test.13 { sqlite3_column_int $STMT -1 } {0} do_test $test.13 { sqlite3_column_text $STMT -1 } {} } do_test capi3-5.0 { execsql { CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16)); INSERT INTO t1 VALUES(1, 2, 3); |
︙ | ︙ |
Added test/utf16.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # 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 runs all tests. # # $Id: utf16.test,v 1.1 2004/06/28 13:09:11 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl rename finish_test really_finish_test2 proc finish_test {} {} set ISQUICK 1 set FILES { func.test } rename sqlite3 real_sqlite3 proc sqlite3 {args} { set r [eval "real_sqlite3 $args"] if { [llength $args] == 2 } { [lindex $args 0] eval {pragma encoding = 'UTF-16'} } set r } rename do_test really_do_test proc do_test {args} { set sc [concat really_do_test "utf16-[lindex $args 0]" [lrange $args 1 end]] eval $sc } foreach f $FILES { set testfile $testdir/$f source $testfile catch {db close} if {$sqlite_open_file_count>0} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail } } rename sqlite3 "" rename real_sqlite3 sqlite3 rename finish_test "" rename really_finish_test2 finish_test rename do_test "" rename really_do_test do_test |