-C Explicitly\stest\ssome\serror\scases\sthat\sup\suntil\snow\shave\snot\sbeen\schecked.\s(CVS\s3742)
-D 2007-03-29T12:19:12
+C Explicitly\stest\ssome\serror\scases\sthat\sup\suntil\snow\shave\snot\sbeen\schecked.\s(CVS\s3743)
+D 2007-03-29T12:24:17
F Makefile.in 2f2c3bf69faf0ae7b8e8af4f94f1986849034530
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/test6.c 5957d249d437e4db74045ce2f1f661648d94bf94
F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
F src/test8.c 628ec89f9fbf3bfb9c58a503d845a0719595d0ad
+F src/test9.c ba1c39ce4301673653c31a4a31c2ba634dc04ac4
F src/test_async.c 9d326ceda4306bcab252b8f7e8e480ed45d7ccb6
F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P ad4a6b1a91bcefd8a4c75e8dc99c1153c72c31a3
-R e9b410d1b1f8ee8dc2faf517d9c114ed
+P f26b014109b1b20367044c5d3fcb347af73d07aa
+R 05e6a5fcf08315b0a9bf7ee42168681e
U danielk1977
-Z d48e5c7352b07b65203e408c728b3bfc
+Z 03aaa5fc945d2c2de509f107c57e4b90
--- /dev/null
+/*
+** 2007 March 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 contains obscure tests of the C-interface required
+** for completeness. Test code is written in C for these cases
+** as there is not much point in binding to Tcl.
+**
+** $Id: test9.c,v 1.1 2007/03/29 12:24:17 danielk1977 Exp $
+*/
+#include "sqliteInt.h"
+#include "tcl.h"
+#include "os.h"
+#include <stdlib.h>
+#include <string.h>
+
+/*
+** c_collation_test
+*/
+static int c_collation_test(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ void *p;
+ const char *zErrFunction = "N/A";
+ sqlite3 *db;
+
+ int rc;
+ if( objc!=1 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "");
+ return TCL_ERROR;
+ }
+
+ /* Open a database. */
+ rc = sqlite3_open(":memory:", &db);
+ if( rc!=SQLITE_OK ){
+ zErrFunction = "sqlite3_open";
+ goto error_out;
+ }
+
+ rc = sqlite3_create_collation(db, "collate", 456, 0, 0);
+ if( rc!=SQLITE_ERROR ){
+ sqlite3_close(db);
+ zErrFunction = "sqlite3_create_collation";
+ goto error_out;
+ }
+
+ sqlite3_close(db);
+ return TCL_OK;
+
+error_out:
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
+ return TCL_ERROR;
+}
+
+/*
+** c_realloc_test
+*/
+static int c_realloc_test(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ void *p;
+ const char *zErrFunction = "N/A";
+
+ sqlite3 *db;
+ int rc;
+ if( objc!=1 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "");
+ return TCL_ERROR;
+ }
+
+ p = sqlite3_malloc(5);
+ if( !p ){
+ zErrFunction = "sqlite3_malloc";
+ goto error_out;
+ }
+
+ /* Test that realloc()ing a block of memory to a negative size is
+ ** the same as free()ing that memory.
+ */
+ p = sqlite3_realloc(p, -1);
+ if( p ){
+ zErrFunction = "sqlite3_realloc";
+ goto error_out;
+ }
+
+ return TCL_OK;
+
+error_out:
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
+ return TCL_ERROR;
+}
+
+
+/*
+** c_misuse_test
+*/
+static int c_misuse_test(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ const char *zErrFunction = "N/A";
+ sqlite3 *db = 0;
+ int rc;
+
+ if( objc!=1 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "");
+ return TCL_ERROR;
+ }
+
+ /* Open a database. Then close it again. We need to do this so that
+ ** we have a "closed database handle" to pass to various API functions.
+ */
+ rc = sqlite3_open(":memory:", &db);
+ if( rc!=SQLITE_OK ){
+ zErrFunction = "sqlite3_open";
+ goto error_out;
+ }
+ sqlite3_close(db);
+
+ rc = sqlite3_collation_needed16(db, 0, 0);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_collation_needed16";
+ goto error_out;
+ }
+
+ rc = sqlite3_collation_needed(db, 0, 0);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_collation_needed";
+ goto error_out;
+ }
+
+ rc = sqlite3_create_collation(db, 0, 0, 0, 0);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_create_collation";
+ goto error_out;
+ }
+
+ rc = sqlite3_create_function(db, 0, 0, 0, 0, 0, 0, 0);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_create_function";
+ goto error_out;
+ }
+
+ rc = sqlite3_busy_handler(db, 0, 0);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_busy_handler";
+ goto error_out;
+ }
+
+ rc = sqlite3_errcode(db);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_busy_handler";
+ goto error_out;
+ }
+
+ rc = sqlite3_prepare16(db, 0, 0, 0, 0);
+ if( rc!=SQLITE_MISUSE ){
+ zErrFunction = "sqlite3_prepare16";
+ goto error_out;
+ }
+
+ return TCL_OK;
+
+error_out:
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
+ return TCL_ERROR;
+}
+
+/*
+** Register commands with the TCL interpreter.
+*/
+int Sqlitetest9_Init(Tcl_Interp *interp){
+ static struct {
+ char *zName;
+ Tcl_ObjCmdProc *xProc;
+ void *clientData;
+ } aObjCmd[] = {
+ { "c_misuse_test", c_misuse_test, 0 },
+ { "c_realloc_test", c_realloc_test, 0 },
+ { "c_collation_test", c_collation_test, 0 },
+ };
+ int i;
+ for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
+ Tcl_CreateObjCommand(interp, aObjCmd[i].zName,
+ aObjCmd[i].xProc, aObjCmd[i].clientData, 0);
+ }
+ return TCL_OK;
+}
+