mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Added new tests (CVS 206)
FossilOrigin-Name: 2507ec40610d8034ccf9dcb58a16934065e6f120
This commit is contained in:
11
Makefile.in
11
Makefile.in
@ -186,11 +186,16 @@ gdbmdump: $(TOP)/tool/gdbmdump.c
|
|||||||
$(TCC) $(GDBM_FLAGS) -o gdbmdump $(TOP)/tool/gdbmdump.c $(LIBGDBM)
|
$(TCC) $(GDBM_FLAGS) -o gdbmdump $(TOP)/tool/gdbmdump.c $(LIBGDBM)
|
||||||
|
|
||||||
tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
|
tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
|
||||||
$(TCC) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
|
$(TCC) $(TCL_FLAGS) -DTCLSH=1 -o sqlite_tester \
|
||||||
$(TOP)/src/tclsqlite.c libsqlite.a $(LIBGDBM) $(LIBTCL)
|
$(TOP)/src/tclsqlite.c libsqlite.a $(LIBGDBM) $(LIBTCL)
|
||||||
|
|
||||||
test: tclsqlite sqlite
|
sqlite_tester: $(TOP)/src/tclsqlite.c libsqlite.a $(TOP)/src/test1.c
|
||||||
./tclsqlite $(TOP)/test/all.test
|
$(TCC) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST1=1 -o sqlite_tester \
|
||||||
|
$(TOP)/src/test1.c $(TOP)/src/tclsqlite.c \
|
||||||
|
libsqlite.a $(LIBGDBM) $(LIBTCL)
|
||||||
|
|
||||||
|
test: sqlite_tester sqlite
|
||||||
|
./sqlite_tester $(TOP)/test/all.test
|
||||||
|
|
||||||
sqlite.tar.gz:
|
sqlite.tar.gz:
|
||||||
pwd=`pwd`; cd $(TOP)/..; tar czf $$pwd/sqlite.tar.gz sqlite
|
pwd=`pwd`; cd $(TOP)/..; tar czf $$pwd/sqlite.tar.gz sqlite
|
||||||
|
25
manifest
25
manifest
@ -1,9 +1,9 @@
|
|||||||
C Version\s1.0.30\s(CVS\s473)
|
C Added\snew\stests\s(CVS\s206)
|
||||||
D 2001-04-06T16:20:00
|
D 2001-04-07T15:24:33
|
||||||
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
|
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
|
||||||
F Makefile.in 25791375ce9f4f5b57d4cab67f0d58d772c96451
|
F Makefile.in 4775f7fd1ed543606bb24fa3fada1bc90a23a6b9
|
||||||
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
|
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
|
||||||
F VERSION 2670c932365e633f8552540db172fac18bd09b3a
|
F VERSION 71874cb7e2a53c2bd22bb6affa7d223dd94a7a13
|
||||||
F configure 260d3be664b6d9b4d2d985e66b6dae1ef723c86e x
|
F configure 260d3be664b6d9b4d2d985e66b6dae1ef723c86e x
|
||||||
F configure.in 6940e3f88bf3d28a10c73b06ab99fd3a7e039a61
|
F configure.in 6940e3f88bf3d28a10c73b06ab99fd3a7e039a61
|
||||||
F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47
|
F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47
|
||||||
@ -33,10 +33,11 @@ F src/random.c b36c3f57dc80c8f354e6bfbf39cf1e1de021d54a
|
|||||||
F src/select.c a6bfdaa92d4614e79bf18129283c5163faa291fc
|
F src/select.c a6bfdaa92d4614e79bf18129283c5163faa291fc
|
||||||
F src/shell.c c1785b4af18192056adbe894f8626a7e7bdf47aa
|
F src/shell.c c1785b4af18192056adbe894f8626a7e7bdf47aa
|
||||||
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
||||||
F src/sqlite.h.in 182336b2763d15d31ffd9ac1112e6ddd190c02e4
|
F src/sqlite.h.in 3e5906f72608f0fd4394dfbb1d7e8d35b8353677
|
||||||
F src/sqliteInt.h 97e2dd488ab433e27eda6e26f4c84a9a2684785c
|
F src/sqliteInt.h 054c00c2b3deaedf4034b85d69287abeb4c15c96
|
||||||
F src/table.c 5be76051a8ed6f6bfa641f4adc52529efa34fbf9
|
F src/table.c 5be76051a8ed6f6bfa641f4adc52529efa34fbf9
|
||||||
F src/tclsqlite.c 8b30b01d9fb814a5a358dafd697de16d968cb73e
|
F src/tclsqlite.c 83dcbf015ea0319c2a97514b8b812a12d621e40a
|
||||||
|
F src/test1.c 7d88c76725ce5b881cff2a283662fe068d792002
|
||||||
F src/tokenize.c 8fc3936eefad84f1fff19e0892ed0542eb9ac7b3
|
F src/tokenize.c 8fc3936eefad84f1fff19e0892ed0542eb9ac7b3
|
||||||
F src/update.c 8365b3922ea098330d1e20862d6e64911e4e03d0
|
F src/update.c 8365b3922ea098330d1e20862d6e64911e4e03d0
|
||||||
F src/util.c aec315b834bad444c9e0e90efd9d2eaeeb37c90c
|
F src/util.c aec315b834bad444c9e0e90efd9d2eaeeb37c90c
|
||||||
@ -55,6 +56,7 @@ F test/insert.test dbd3bd189edb61fddbe66c236694ef23352429f1
|
|||||||
F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6
|
F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6
|
||||||
F test/lock.test bca7d53de73138b1f670a2fbdb1f481ff7eaa45a
|
F test/lock.test bca7d53de73138b1f670a2fbdb1f481ff7eaa45a
|
||||||
F test/main.test da635f9e078cd21ddf074e727381a715064489ff
|
F test/main.test da635f9e078cd21ddf074e727381a715064489ff
|
||||||
|
F test/printf.test 18e44e4e154e13cba74d67b85202172d37ddb5ed
|
||||||
F test/rowid.test 128453599def7435e988216f7fe89c7450b8a9a3
|
F test/rowid.test 128453599def7435e988216f7fe89c7450b8a9a3
|
||||||
F test/select1.test 824d9d5007dffd6a45edde79e89c0a04c36e3ebe
|
F test/select1.test 824d9d5007dffd6a45edde79e89c0a04c36e3ebe
|
||||||
F test/select2.test 04ac3bd69298f58c7d0883159bab42ab9ad6021c
|
F test/select2.test 04ac3bd69298f58c7d0883159bab42ab9ad6021c
|
||||||
@ -64,6 +66,7 @@ F test/select5.test e2b9d51d88cbd6c307c2c05b0ef55fe7ba811ac2
|
|||||||
F test/sort.test 838cd862642ed9a2c47e1a17b5c33da452b4552e
|
F test/sort.test 838cd862642ed9a2c47e1a17b5c33da452b4552e
|
||||||
F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
|
F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
|
||||||
F test/table.test c1704fead1af27d67850a934d531848ce5bee4a7
|
F test/table.test c1704fead1af27d67850a934d531848ce5bee4a7
|
||||||
|
F test/tableapi.test 9ecb98590d1b6ebcb4b791697bd5275e73bba530
|
||||||
F test/tclsqlite.test d2aa55926874783b2401f0146e839f773c6796e1
|
F test/tclsqlite.test d2aa55926874783b2401f0146e839f773c6796e1
|
||||||
F test/tester.tcl dba25c97cc89f109a9350f12792f17b24202d65f
|
F test/tester.tcl dba25c97cc89f109a9350f12792f17b24202d65f
|
||||||
F test/trans.test 82556605d48f56ad4679e95478d70546a763f26a
|
F test/trans.test 82556605d48f56ad4679e95478d70546a763f26a
|
||||||
@ -83,7 +86,7 @@ F www/arch.fig 4f246003b7da23bd63b8b0af0618afb4ee3055c8
|
|||||||
F www/arch.png 8dae0766d42ed3de9ed013c1341a5792bcf633e6
|
F www/arch.png 8dae0766d42ed3de9ed013c1341a5792bcf633e6
|
||||||
F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be
|
F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be
|
||||||
F www/c_interface.tcl ddca19005c47dd5a15882addc02fff5de83d8ed9
|
F www/c_interface.tcl ddca19005c47dd5a15882addc02fff5de83d8ed9
|
||||||
F www/changes.tcl a522ee29c7e66205e76a2c34f3dc1363e251bfda
|
F www/changes.tcl 64e5779a681bda4b34d0403c33aaf8902d8cf056
|
||||||
F www/crosscompile.tcl c99efacb3aefaa550c6e80d91b240f55eb9fd33e
|
F www/crosscompile.tcl c99efacb3aefaa550c6e80d91b240f55eb9fd33e
|
||||||
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
|
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
|
||||||
F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9
|
F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9
|
||||||
@ -94,7 +97,7 @@ F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f
|
|||||||
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
|
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
|
||||||
F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
|
F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
|
||||||
F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
|
F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
|
||||||
P 5b65746383c509048c80b7aff536d1204fd1d127
|
P 8f0d98193e4ba913fa31d5f8d5adc46ad9d346a1
|
||||||
R f07b6ba51358f496162e586514c5cd88
|
R b4947cdaa9daf5e442bdf2c2d5dbb11c
|
||||||
U drh
|
U drh
|
||||||
Z ad8ecefbe3c2d25277befbe640696a09
|
Z 46e79499f1b58c1b58c6255886d7f82a
|
||||||
|
@ -1 +1 @@
|
|||||||
8f0d98193e4ba913fa31d5f8d5adc46ad9d346a1
|
2507ec40610d8034ccf9dcb58a16934065e6f120
|
@ -24,7 +24,7 @@
|
|||||||
** This header file defines the interface that the sqlite library
|
** This header file defines the interface that the sqlite library
|
||||||
** presents to client programs.
|
** presents to client programs.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqlite.h.in,v 1.12 2001/04/06 16:13:43 drh Exp $
|
** @(#) $Id: sqlite.h.in,v 1.13 2001/04/07 15:24:33 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE_H_
|
#ifndef _SQLITE_H_
|
||||||
#define _SQLITE_H_
|
#define _SQLITE_H_
|
||||||
@ -342,5 +342,4 @@ int sqlite_get_table_vprintf(
|
|||||||
va_list ap /* Arguments to the format string */
|
va_list ap /* Arguments to the format string */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _SQLITE_H_ */
|
#endif /* _SQLITE_H_ */
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.39 2001/04/04 21:10:19 drh Exp $
|
** @(#) $Id: sqliteInt.h,v 1.40 2001/04/07 15:24:33 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqlite.h"
|
#include "sqlite.h"
|
||||||
#include "dbbe.h"
|
#include "dbbe.h"
|
||||||
@ -432,3 +432,4 @@ char *sqliteDbbeNameToFile(const char*,const char*,const char*);
|
|||||||
void sqliteBeginTransaction(Parse*);
|
void sqliteBeginTransaction(Parse*);
|
||||||
void sqliteCommitTransaction(Parse*);
|
void sqliteCommitTransaction(Parse*);
|
||||||
void sqliteRollbackTransaction(Parse*);
|
void sqliteRollbackTransaction(Parse*);
|
||||||
|
char *sqlite_mprintf(const char *, ...);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** A TCL Interface to SQLite
|
** A TCL Interface to SQLite
|
||||||
**
|
**
|
||||||
** $Id: tclsqlite.c,v 1.16 2001/04/06 16:13:43 drh Exp $
|
** $Id: tclsqlite.c,v 1.17 2001/04/07 15:24:33 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
|
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
|
||||||
|
|
||||||
@ -507,6 +507,12 @@ int TCLSH_MAIN(int argc, char **argv){
|
|||||||
Tcl_FindExecutable(argv[0]);
|
Tcl_FindExecutable(argv[0]);
|
||||||
interp = Tcl_CreateInterp();
|
interp = Tcl_CreateInterp();
|
||||||
Sqlite_Init(interp);
|
Sqlite_Init(interp);
|
||||||
|
#ifdef SQLITE_TEST1
|
||||||
|
{
|
||||||
|
extern int Sqlitetest1_Init(Tcl_Interp*);
|
||||||
|
Sqlitetest1_Init(interp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if( argc>=2 ){
|
if( argc>=2 ){
|
||||||
int i;
|
int i;
|
||||||
Tcl_SetVar(interp,"argv0",argv[1],TCL_GLOBAL_ONLY);
|
Tcl_SetVar(interp,"argv0",argv[1],TCL_GLOBAL_ONLY);
|
||||||
|
283
src/test1.c
Normal file
283
src/test1.c
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
/*
|
||||||
|
** Copyright (c) 2001 D. Richard Hipp
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or
|
||||||
|
** modify it under the terms of the GNU General Public
|
||||||
|
** License as published by the Free Software Foundation; either
|
||||||
|
** version 2 of the License, or (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
** General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public
|
||||||
|
** License along with this library; if not, write to the
|
||||||
|
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
** Boston, MA 02111-1307, USA.
|
||||||
|
**
|
||||||
|
** Author contact information:
|
||||||
|
** drh@hwaci.com
|
||||||
|
** http://www.hwaci.com/drh/
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** 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.1 2001/04/07 15:24:33 drh Exp $
|
||||||
|
*/
|
||||||
|
#include "sqliteInt.h"
|
||||||
|
#include "tcl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_open filename
|
||||||
|
**
|
||||||
|
** Returns: The name of an open database.
|
||||||
|
*/
|
||||||
|
static int sqlite_test_open(
|
||||||
|
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;
|
||||||
|
char *zErr = 0;
|
||||||
|
char zBuf[100];
|
||||||
|
if( argc!=2 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" FILENAME\"", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
db = sqlite_open(argv[1], 0666, &zErr);
|
||||||
|
if( db==0 ){
|
||||||
|
Tcl_AppendResult(interp, zErr, 0);
|
||||||
|
free(zErr);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
sprintf(zBuf,"%d",(int)db);
|
||||||
|
Tcl_AppendResult(interp, zBuf, 0);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The callback routine for sqlite_exec_printf().
|
||||||
|
*/
|
||||||
|
static int exec_printf_cb(void *pArg, int argc, char **argv, char **name){
|
||||||
|
Tcl_DString *str = (Tcl_DString*)pArg;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if( Tcl_DStringLength(str)==0 ){
|
||||||
|
for(i=0; i<argc; i++){
|
||||||
|
Tcl_DStringAppendElement(str, name[i] ? name[i] : "NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(i=0; i<argc; i++){
|
||||||
|
Tcl_DStringAppendElement(str, argv[i] ? argv[i] : "NULL");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_exec_printf DB FORMAT STRING
|
||||||
|
**
|
||||||
|
** Invoke the sqlite_exec_printf() interface using the open database
|
||||||
|
** DB. The SQL is the string FORMAT. The format string should contain
|
||||||
|
** one %s or %q. STRING is the value inserted into %s or %q.
|
||||||
|
*/
|
||||||
|
static int test_exec_printf(
|
||||||
|
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;
|
||||||
|
Tcl_DString str;
|
||||||
|
int rc;
|
||||||
|
char *zErr = 0;
|
||||||
|
char zBuf[30];
|
||||||
|
if( argc!=4 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" DB FORMAT STRING", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
db = (sqlite*)atoi(argv[1]);
|
||||||
|
Tcl_DStringInit(&str);
|
||||||
|
rc = sqlite_exec_printf(db, argv[2], exec_printf_cb, &str, &zErr, argv[3]);
|
||||||
|
sprintf(zBuf, "%d", rc);
|
||||||
|
Tcl_AppendElement(interp, zBuf);
|
||||||
|
Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr);
|
||||||
|
Tcl_DStringFree(&str);
|
||||||
|
if( zErr ) free(zErr);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_get_table_printf DB FORMAT STRING
|
||||||
|
**
|
||||||
|
** Invoke the sqlite_get_table_printf() interface using the open database
|
||||||
|
** DB. The SQL is the string FORMAT. The format string should contain
|
||||||
|
** one %s or %q. STRING is the value inserted into %s or %q.
|
||||||
|
*/
|
||||||
|
static int test_get_table_printf(
|
||||||
|
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;
|
||||||
|
Tcl_DString str;
|
||||||
|
int rc;
|
||||||
|
char *zErr = 0;
|
||||||
|
int nRow, nCol;
|
||||||
|
char **aResult;
|
||||||
|
int i;
|
||||||
|
char zBuf[30];
|
||||||
|
if( argc!=4 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" DB FORMAT STRING", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
db = (sqlite*)atoi(argv[1]);
|
||||||
|
Tcl_DStringInit(&str);
|
||||||
|
rc = sqlite_get_table_printf(db, argv[2], &aResult, &nRow, &nCol,
|
||||||
|
&zErr, argv[3]);
|
||||||
|
sprintf(zBuf, "%d", rc);
|
||||||
|
Tcl_AppendElement(interp, zBuf);
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
sprintf(zBuf, "%d", nRow);
|
||||||
|
Tcl_AppendElement(interp, zBuf);
|
||||||
|
sprintf(zBuf, "%d", nCol);
|
||||||
|
Tcl_AppendElement(interp, zBuf);
|
||||||
|
for(i=0; i<(nRow+1)*nCol; i++){
|
||||||
|
Tcl_AppendElement(interp, aResult[i] ? aResult[i] : "NULL");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Tcl_AppendElement(interp, zErr);
|
||||||
|
}
|
||||||
|
sqlite_free_table(aResult);
|
||||||
|
if( zErr ) free(zErr);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_close DB
|
||||||
|
**
|
||||||
|
** Closes the database opened by sqlite_open.
|
||||||
|
*/
|
||||||
|
static int sqlite_test_close(
|
||||||
|
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;
|
||||||
|
if( argc!=2 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" FILENAME\"", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
db = (sqlite*)atoi(argv[1]);
|
||||||
|
sqlite_close(db);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_mprintf_int FORMAT INTEGER INTEGER INTEGER
|
||||||
|
**
|
||||||
|
** Call mprintf with three integer arguments
|
||||||
|
*/
|
||||||
|
static int sqlite_mprintf_int(
|
||||||
|
void *NotUsed,
|
||||||
|
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||||
|
int argc, /* Number of arguments */
|
||||||
|
char **argv /* Text of each argument */
|
||||||
|
){
|
||||||
|
int a[3], i;
|
||||||
|
char *z;
|
||||||
|
if( argc!=5 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" FORMAT INT INT INT\"", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
for(i=2; i<5; i++){
|
||||||
|
if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;
|
||||||
|
}
|
||||||
|
z = sqlite_mprintf(argv[1], a[0], a[1], a[2]);
|
||||||
|
Tcl_AppendResult(interp, z, 0);
|
||||||
|
sqliteFree(z);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_mprintf_str FORMAT INTEGER INTEGER STRING
|
||||||
|
**
|
||||||
|
** Call mprintf with two integer arguments and one string argument
|
||||||
|
*/
|
||||||
|
static int sqlite_mprintf_str(
|
||||||
|
void *NotUsed,
|
||||||
|
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||||
|
int argc, /* Number of arguments */
|
||||||
|
char **argv /* Text of each argument */
|
||||||
|
){
|
||||||
|
int a[3], i;
|
||||||
|
char *z;
|
||||||
|
if( argc!=5 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" FORMAT INT INT STRING\"", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
for(i=2; i<4; i++){
|
||||||
|
if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;
|
||||||
|
}
|
||||||
|
z = sqlite_mprintf(argv[1], a[0], a[1], argv[4]);
|
||||||
|
Tcl_AppendResult(interp, z, 0);
|
||||||
|
sqliteFree(z);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite_mprintf_str FORMAT INTEGER INTEGER DOUBLE
|
||||||
|
**
|
||||||
|
** Call mprintf with two integer arguments and one double argument
|
||||||
|
*/
|
||||||
|
static int sqlite_mprintf_double(
|
||||||
|
void *NotUsed,
|
||||||
|
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||||
|
int argc, /* Number of arguments */
|
||||||
|
char **argv /* Text of each argument */
|
||||||
|
){
|
||||||
|
int a[3], i;
|
||||||
|
double r;
|
||||||
|
char *z;
|
||||||
|
if( argc!=5 ){
|
||||||
|
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||||
|
" FORMAT INT INT STRING\"", 0);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
for(i=2; i<4; i++){
|
||||||
|
if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR;
|
||||||
|
z = sqlite_mprintf(argv[1], a[0], a[1], r);
|
||||||
|
Tcl_AppendResult(interp, z, 0);
|
||||||
|
sqliteFree(z);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Register commands with the TCL interpreter.
|
||||||
|
*/
|
||||||
|
int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||||
|
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_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);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
92
test/printf.test
Normal file
92
test/printf.test
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# Copyright (c) 2001 D. Richard Hipp
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public
|
||||||
|
# License along with this library; if not, write to the
|
||||||
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
# Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
# Author contact information:
|
||||||
|
# drh@hwaci.com
|
||||||
|
# http://www.hwaci.com/drh/
|
||||||
|
#
|
||||||
|
#***********************************************************************
|
||||||
|
# This file implements regression tests for SQLite library. The
|
||||||
|
# focus of this file is testing the sqlite_*_printf() interface.
|
||||||
|
#
|
||||||
|
# $Id: printf.test,v 1.1 2001/04/07 15:24:33 drh Exp $
|
||||||
|
|
||||||
|
set testdir [file dirname $argv0]
|
||||||
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
|
set n 1
|
||||||
|
foreach v {1 2 5 10 99 100 1000000 999999999 0 -1 -2 -5 -10 -99 -100 -9999999} {
|
||||||
|
do_test printf-1.$n.1 [subst {
|
||||||
|
sqlite_mprintf_int {Three integers: %d %x %o} $v $v $v
|
||||||
|
}] [format {Three integers: %d %x %o} $v $v $v]
|
||||||
|
do_test printf-1.$n.2 [subst {
|
||||||
|
sqlite_mprintf_int {Three integers: (%6d) (%6x) (%6o)} $v $v $v
|
||||||
|
}] [format {Three integers: (%6d) (%6x) (%6o)} $v $v $v]
|
||||||
|
do_test printf-1.$n.3 [subst {
|
||||||
|
sqlite_mprintf_int {Three integers: (%-6d) (%-6x) (%-6o)} $v $v $v
|
||||||
|
}] [format {Three integers: (%-6d) (%-6x) (%-6o)} $v $v $v]
|
||||||
|
incr n
|
||||||
|
}
|
||||||
|
|
||||||
|
set m 1
|
||||||
|
foreach {a b} {1 1 5 5 10 10 10 5} {
|
||||||
|
set n 1
|
||||||
|
foreach x {0.001 1.0e-20 1.0 0.0 100.0 9.99999 -0.00543 -1.0 -99.99999} {
|
||||||
|
do_test printf-2.$m.$n.1 [subst {
|
||||||
|
sqlite_mprintf_double {A double: %*.*f} $a $b $x
|
||||||
|
}] [format {A double: %*.*f} $a $b $x]
|
||||||
|
do_test printf-2.$m.$n.2 [subst {
|
||||||
|
sqlite_mprintf_double {A double: %*.*e} $a $b $x
|
||||||
|
}] [format {A double: %*.*e} $a $b $x]
|
||||||
|
do_test printf-2.$m.$n.3 [subst {
|
||||||
|
sqlite_mprintf_double {A double: %*.*g} $a $b $x
|
||||||
|
}] [format {A double: %*.*g} $a $b $x]
|
||||||
|
do_test printf-2.$m.$n.4 [subst {
|
||||||
|
sqlite_mprintf_double {A double: %d %d %g} $a $b $x
|
||||||
|
}] [format {A double: %d %d %g} $a $b $x]
|
||||||
|
do_test printf-2.$m.$n.5 [subst {
|
||||||
|
sqlite_mprintf_double {A double: %d %d %#g} $a $b $x
|
||||||
|
}] [format {A double: %d %d %#g} $a $b $x]
|
||||||
|
incr n
|
||||||
|
}
|
||||||
|
incr m
|
||||||
|
}
|
||||||
|
|
||||||
|
do_test printf-3.1 {
|
||||||
|
sqlite_mprintf_str {A String: (%*.*s)} 10 10 {This is the string}
|
||||||
|
} [format {A String: (%*.*s)} 10 10 {This is the string}]
|
||||||
|
do_test printf-3.2 {
|
||||||
|
sqlite_mprintf_str {A String: (%*.*s)} 10 5 {This is the string}
|
||||||
|
} [format {A String: (%*.*s)} 10 5 {This is the string}]
|
||||||
|
do_test printf-3.3 {
|
||||||
|
sqlite_mprintf_str {A String: (%*.*s)} -10 5 {This is the string}
|
||||||
|
} [format {A String: (%*.*s)} -10 5 {This is the string}]
|
||||||
|
do_test printf-3.4 {
|
||||||
|
sqlite_mprintf_str {%d %d A String: (%s)} 1 2 {This is the string}
|
||||||
|
} [format {%d %d A String: (%s)} 1 2 {This is the string}]
|
||||||
|
do_test printf-3.5 {
|
||||||
|
sqlite_mprintf_str {%d %d A String: (%30s)} 1 2 {This is the string}
|
||||||
|
} [format {%d %d A String: (%30s)} 1 2 {This is the string}]
|
||||||
|
do_test printf-3.6 {
|
||||||
|
sqlite_mprintf_str {%d %d A String: (%-30s)} 1 2 {This is the string}
|
||||||
|
} [format {%d %d A String: (%-30s)} 1 2 {This is the string}]
|
||||||
|
|
||||||
|
do_test printf-4.1 {
|
||||||
|
sqlite_mprintf_str {%d %d A quoted string: '%q'} 1 2 {Hi Y'all}
|
||||||
|
} {1 2 A quoted string: 'Hi Y''all'}
|
||||||
|
|
||||||
|
finish_test
|
56
test/tableapi.test
Normal file
56
test/tableapi.test
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# Copyright (c) 2001 D. Richard Hipp
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public
|
||||||
|
# License along with this library; if not, write to the
|
||||||
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
# Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
# Author contact information:
|
||||||
|
# drh@hwaci.com
|
||||||
|
# http://www.hwaci.com/drh/
|
||||||
|
#
|
||||||
|
#***********************************************************************
|
||||||
|
# This file implements regression tests for SQLite library. The
|
||||||
|
# focus of this file is testing the sqlite_exec_printf() and
|
||||||
|
# sqlite_get_table_printf() APIs.
|
||||||
|
#
|
||||||
|
# $Id: tableapi.test,v 1.1 2001/04/07 15:24:34 drh Exp $
|
||||||
|
|
||||||
|
set testdir [file dirname $argv0]
|
||||||
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
|
do_test tableapi-1.0 {
|
||||||
|
set ::dbx [sqlite_open testdb]
|
||||||
|
catch {sqlite_exec_printf $::dbx {DROP TABLE xyz} {}}
|
||||||
|
sqlite_exec_printf $::dbx {CREATE TABLE %s(a int, b text)} xyz
|
||||||
|
} {0 {}}
|
||||||
|
do_test tableapi-1.1 {
|
||||||
|
sqlite_exec_printf $::dbx {
|
||||||
|
INSERT INTO xyz VALUES(1,'%q')
|
||||||
|
} {Hi Y'all}
|
||||||
|
} {0 {}}
|
||||||
|
do_test tableapi-1.2 {
|
||||||
|
sqlite_exec_printf $::dbx {SELECT * FROM xyz} {}
|
||||||
|
} {0 {a b 1 {Hi Y'all}}}
|
||||||
|
|
||||||
|
do_test tableapi-2.1 {
|
||||||
|
sqlite_get_table_printf $::dbx {
|
||||||
|
SELECT * FROM xyz WHERE b='%q'
|
||||||
|
} {Hi Y'all}
|
||||||
|
} {0 1 2 a b 1 {Hi Y'all}}
|
||||||
|
|
||||||
|
do_test tableapi-99.0 {
|
||||||
|
sqlite_close $::dbx
|
||||||
|
} {}
|
||||||
|
|
||||||
|
finish_test
|
@ -17,6 +17,10 @@ proc chng {date desc} {
|
|||||||
puts "<DD><P><UL>$desc</UL></P></DD>"
|
puts "<DD><P><UL>$desc</UL></P></DD>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chng {2001 Apr 6 (1.0.31)} {
|
||||||
|
<li>New tests added to the test suite.</li>
|
||||||
|
}
|
||||||
|
|
||||||
chng {2001 Apr 6 (1.0.30)} {
|
chng {2001 Apr 6 (1.0.30)} {
|
||||||
<li>Remove the <b>sqlite_encoding</b> TCL variable that was introduced
|
<li>Remove the <b>sqlite_encoding</b> TCL variable that was introduced
|
||||||
in the previous version.</li>
|
in the previous version.</li>
|
||||||
|
Reference in New Issue
Block a user