Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add TCL test bindings and some more test cases for the new query API. (CVS 1467) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d72adf0c522b442d5e1663862bdd639c |
User & Date: | danielk1977 2004-05-27 01:04:07.000 |
Context
2004-05-27
| ||
01:49 | More test cases for the new query API. (CVS 1468) (check-in: 74097ecdb0 user: danielk1977 tags: trunk) | |
01:04 | Add TCL test bindings and some more test cases for the new query API. (CVS 1467) (check-in: d72adf0c52 user: danielk1977 tags: trunk) | |
2004-05-26
| ||
23:43 | Break Mem.flags into Mem.type and Mem.enc. (CVS 1466) (check-in: 68ef170286 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.60 2004/05/27 01:04:07 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
1311 1312 1313 1314 1315 1316 1317 | rc = sqlite3_step(pStmt); if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; Tcl_SetResult(interp, (char *)errorName(rc), 0); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 | rc = sqlite3_step(pStmt); if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; Tcl_SetResult(interp, (char *)errorName(rc), 0); return TCL_OK; } /* ** Usage: sqlite3_column_count STMT ** ** Return the number of columns returned by the sql statement STMT. */ static int test_column_count( void * clientData, |
︙ | ︙ | |||
1512 1513 1514 1515 1516 1517 1518 | assert(0); } return TCL_OK; } /* | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 | assert(0); } return TCL_OK; } /* ** Usage: sqlite3_column_int64 STMT column ** ** Return the data in column 'column' of the current row cast as an ** wide (64-bit) integer. */ static int test_column_int64( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int col; i64 iVal; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; iVal = sqlite3_column_int64(pStmt, col); Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iVal)); return TCL_OK; } /* ** Usage: sqlite3_column_double STMT column ** ** Return the data in column 'column' of the current row cast as a double. */ static int test_column_double( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int col; double rVal; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; rVal = sqlite3_column_double(pStmt, col); Tcl_SetObjResult(interp, Tcl_NewDoubleObj(iVal)); return TCL_OK; } /* ** Usage: sqlite3_data_count STMT ** ** Return the number of columns returned by the sql statement STMT. |
︙ | ︙ | |||
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 | return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; sqlite3ChangeCollatingFunction(db, "REVERSE", 7, 0, reverseCollatingFunc); return TCL_OK; } /* ** Register commands with the TCL interpreter. */ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_search_count; extern int sqlite3_interrupt_count; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 | return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; sqlite3ChangeCollatingFunction(db, "REVERSE", 7, 0, reverseCollatingFunc); return TCL_OK; } /* ** Usage: sqlite3_column_text STMT column ** ** Usage: sqlite3_column_decltype STMT column ** ** Usage: sqlite3_column_name STMT column */ static int test_stmt_utf8( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int col; const char *(xFunc *)(sqlite3_stmt*, int) = clientData; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; Tcl_SetResult(interp, (char *)xFunc(pStmt, col), 0); return TCL_OK; } /* ** Usage: sqlite3_column_text STMT column ** ** Usage: sqlite3_column_decltype STMT column ** ** Usage: sqlite3_column_name STMT column */ static int test_stmt_utf16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int col; Tcl_Obj *pRet; const void *zName16; const void *(xFunc *)(sqlite3_stmt*, int) = clientData; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; zName16 = xFunc(pStmt, col); pRet = Tcl_NewByteArrayObj(zName16, sqlite3utf16ByteLen(zName16, -1)+2); Tcl_SetObjResult(interp, pRet); return TCL_OK; } /* ** Usage: sqlite3_column_int STMT column ** ** Usage: sqlite3_column_bytes STMT column ** ** Usage: sqlite3_column_bytes16 STMT column ** */ static int test_stmt_int( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int col; int (xFunc *)(sqlite3_stmt*, int) = clientData; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; Tcl_SetObjResult(interp, Tcl_NewIntObj(xFunc(pStmt, col))); return TCL_OK; } /* ** Register commands with the TCL interpreter. */ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_search_count; extern int sqlite3_interrupt_count; |
︙ | ︙ | |||
1641 1642 1643 1644 1645 1646 1647 1648 | #endif { "sqlite_bind", (Tcl_CmdProc*)test_bind }, { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, }; static struct { char *zName; Tcl_ObjCmdProc *xProc; } aObjCmd[] = { | > | | | | | | | | | | < < | | > > > > | | | | | | | < | > > > | | > > > > > > > | | 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 | #endif { "sqlite_bind", (Tcl_CmdProc*)test_bind }, { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, }; static struct { char *zName; Tcl_ObjCmdProc *xProc; void *clientData; } aObjCmd[] = { { "sqlite3_bind_int32", test_bind_int32, 0 }, { "sqlite3_bind_int64", test_bind_int64 , 0 }, { "sqlite3_bind_double", test_bind_double, 0 }, { "sqlite3_bind_null", test_bind_null ,0 }, { "sqlite3_bind_text", test_bind_text ,0 }, { "sqlite3_bind_text16", test_bind_text16 ,0 }, { "sqlite3_bind_blob", test_bind_blob ,0 }, { "sqlite3_errcode", test_errcode ,0 }, { "sqlite3_errmsg", test_errmsg ,0 }, { "sqlite3_errmsg16", test_errmsg16 ,0 }, { "sqlite3_open", test_open ,0 }, { "sqlite3_open16", test_open16 ,0 }, { "add_reverse_collating_func", reverse_collfunc ,0 }, { "sqlite3_prepare", test_prepare ,0 }, { "sqlite3_prepare16", test_prepare16 ,0 }, { "sqlite3_finalize", test_finalize ,0 }, { "sqlite3_reset", test_reset ,0 }, { "sqlite3_step", test_step,0 }, /* sqlite3_column_*() API */ { "sqlite3_column_count", test_column_count ,0 }, { "sqlite3_data_count", test_data_count ,0 }, { "sqlite3_column_type", test_column_type ,0 }, { "sqlite3_column_blob", test_column_name ,0 }, { "sqlite3_column_double", test_column_double ,0 }, { "sqlite3_column_int64", test_column_int64 ,0 }, { "sqlite3_column_int", test_stmt_int ,sqlite3_column_int }, { "sqlite3_column_bytes", test_stmt_int ,sqlite3_column_bytes }, { "sqlite3_column_bytes16", test_stmt_int ,sqlite3_column_bytes16 }, { "sqlite3_column_text", test_stmt_utf8, sqlite3_column_text}, { "sqlite3_column_decltype", test_stmt_utf8, sqlite3_column_decltype}, { "sqlite3_column_name", test_stmt_utf8, sqlite3_column_name}, { "sqlite3_column_text16", test_stmt_utf16, sqlite3_column_text16}, { "sqlite3_column_decltype16", test_stmt_utf16,sqlite3_column_decltype16}, { "sqlite3_column_name16", test_stmt_utf16, sqlite3_column_name16}, }; int i; for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); } for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |
︙ | ︙ |
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.6 2004/05/27 01:04:07 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. |
︙ | ︙ | |||
158 159 160 161 162 163 164 | # The tests cases capi3-5.* test work as follows: # # capi3-5.0: Prepare a statement, and check we can retrieve the number of # columns (before the statement is executed). # capi3-5.1: Check we can retrieve column names (before statement execution) # capi3-5.2: Check we can retrieve column names in UTF-16 | > | | | | > | > > > | | | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | # The tests cases capi3-5.* test work as follows: # # capi3-5.0: Prepare a statement, and check we can retrieve the number of # columns (before the statement is executed). # capi3-5.1: Check we can retrieve column names (before statement execution) # capi3-5.2: Check we can retrieve column names in UTF-16 # # capi3-5.1.3: Step the statement. # capi3-5.1.4: Check the types of the values. # capi3-5.1.5: Check the values can be retrieved as integers. # capi3-5.1.6: Check the values can be retrieved as UTF-8 text. # capi3-5.1.7: Check the values can be retrieved as floats. # capi3-5.1.8: Check the values can be retrieved as UTF-16 text. # capi3-5.1.9: Check the values can be retrieved as integers. # capi3-5.1.10: Check the values can be retrieved as floats. # capi3-5.1.11: Check the values can still be retrieved as UTF-8 text. # capi3-5.1.12: Check that the types of the values have not been altered by # retrieving the values as text. # # Test cases capi3-5.2.3 - capi3-5.2.12 are a repeat of 1.3-1.12, with a # different row of data. # do_test capi3-5.0 { execsql { CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16)); INSERT INTO t1 VALUES(1, 2, 3); INSERT INTO t1 VALUES('one', 'two', NULL); |
︙ | ︙ | |||
194 195 196 197 198 199 200 | do_test capi3-5.2 { set cnamelist [list] foreach i {0 1 2} {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]} set cnamelist } {a b c} | | > | | | > | | > > > > > > > | > | > > > > > > > > > > > > > > > > > > > > > | 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 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 266 267 268 269 270 271 272 273 274 | do_test capi3-5.2 { set cnamelist [list] foreach i {0 1 2} {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]} set cnamelist } {a b c} do_test capi3-5.1.3 { sqlite3_step $STMT } SQLITE_ROW # types do_test capi3-5.1.4 { set types [list] foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]} set types } {INTEGER INTEGER TEXT} # Integers do_test capi3-5.1.5 { set ints [list] foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]} set ints } {1 2 3} # UTF-8 do_test capi3-5.1.6 { set utf8 [list] foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]} set utf8 } {1 2 3} # Floats do_test capi3-5.1.7 { set utf8 [list] foreach i {0 1 2} {lappend utf8 [sqlite3_column_double $STMT $i]} set utf8 } {1 2 3} # UTF-16 do_test capi3-5.1.8 { set utf8 [list] foreach i {0 1 2} {lappend utf8 [utf8 [sqlite3_column_data16 $STMT $i]]} set utf8 } {1 2 3} # Integers do_test capi3-5.1.9 { set ints [list] foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]} set ints } {1 2 3} # Floats do_test capi3-5.1.10 { set utf8 [list] foreach i {0 1 2} {lappend utf8 [sqlite3_column_double $STMT $i]} set utf8 } {1 2 3} # UTF-8 do_test capi3-5.1.11 { set utf8 [list] foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]} set utf8 } {1 2 3} # Types do_test capi3-5.1.12 { set types [list] foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]} set types } {INTEGER INTEGER TEXT} |
︙ | ︙ |