diff options
author | drh <drh@noemail.net> | 2006-03-19 13:00:25 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-03-19 13:00:25 +0000 |
commit | 05a82983382a9a2b708abf73f5a95d8b7941668b (patch) | |
tree | 90d79c75b408dea80464d87ef935949809719400 /src | |
parent | f8875400e417ec7e777baf665f34ccdff41edf4f (diff) | |
download | sqlite-05a82983382a9a2b708abf73f5a95d8b7941668b.tar.gz sqlite-05a82983382a9a2b708abf73f5a95d8b7941668b.zip |
Increase test coverage to above 98%. (CVS 3144)
FossilOrigin-Name: 8ae6ccc715b081cd422e847cd9e5cc22b04d8512
Diffstat (limited to 'src')
-rw-r--r-- | src/printf.c | 26 | ||||
-rw-r--r-- | src/shell.c | 4 | ||||
-rw-r--r-- | src/test1.c | 27 |
3 files changed, 34 insertions, 23 deletions
diff --git a/src/printf.c b/src/printf.c index 7c4b6b007..801db5a83 100644 --- a/src/printf.c +++ b/src/printf.c @@ -65,15 +65,14 @@ #define etDYNSTRING 7 /* Dynamically allocated strings. %z */ #define etPERCENT 8 /* Percent symbol. %% */ #define etCHARX 9 /* Characters. %c */ -#define etERROR 10 /* Used to indicate no such conversion type */ /* The rest are extensions, not normally found in printf() */ -#define etCHARLIT 11 /* Literal characters. %' */ -#define etSQLESCAPE 12 /* Strings with '\'' doubled. %q */ -#define etSQLESCAPE2 13 /* Strings with '\'' doubled and enclosed in '', +#define etCHARLIT 10 /* Literal characters. %' */ +#define etSQLESCAPE 11 /* Strings with '\'' doubled. %q */ +#define etSQLESCAPE2 12 /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ -#define etTOKEN 14 /* a pointer to a Token structure */ -#define etSRCLIST 15 /* a pointer to a SrcList */ -#define etPOINTER 16 /* The %p conversion */ +#define etTOKEN 13 /* a pointer to a Token structure */ +#define etSRCLIST 14 /* a pointer to a SrcList */ +#define etPOINTER 15 /* The %p conversion */ /* @@ -329,7 +328,6 @@ static int vxprintf( } /* Fetch the info entry for the field */ infop = 0; - xtype = etERROR; for(idx=0; idx<etNINFO; idx++){ if( c==fmtinfo[idx].fmttype ){ infop = &fmtinfo[idx]; @@ -625,7 +623,8 @@ static int vxprintf( if( needQuote ) bufpt[j++] = '\''; bufpt[j] = 0; length = j; - if( precision>=0 && precision<length ) length = precision; + /* The precision is ignored on %q and %Q */ + /* if( precision>=0 && precision<length ) length = precision; */ break; } case etTOKEN: { @@ -649,15 +648,6 @@ static int vxprintf( length = width = 0; break; } - case etERROR: - buf[0] = '%'; - buf[1] = c; - errorflag = 0; - idx = 1+(c!=0); - (*func)(arg,"%",idx); - count += idx; - if( c==0 ) fmt--; - break; }/* End switch over the format type */ /* ** The text of the conversion is pointed to by "bufpt" and is diff --git a/src/shell.c b/src/shell.c index a8fdb7144..6c0f6f46a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -12,7 +12,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.134 2006/03/06 20:55:46 drh Exp $ +** $Id: shell.c,v 1.135 2006/03/19 13:00:25 drh Exp $ */ #include <stdlib.h> #include <string.h> @@ -1490,7 +1490,7 @@ static void process_input(struct callback_data *p, FILE *in){ open_db(p); rc = sqlite3_exec(p->db, zSql, callback, p, &zErrMsg); if( rc || zErrMsg ){ - if( in!=0 && !p->echoOn ) printf("%s\n",zSql); + /* if( in!=0 && !p->echoOn ) printf("%s\n",zSql); */ if( zErrMsg!=0 ){ printf("SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); diff --git a/src/test1.c b/src/test1.c index ffcecc46b..01dc6d782 100644 --- a/src/test1.c +++ b/src/test1.c @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** Code for testing the printf() interface to SQLite. This code +** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.208 2006/03/16 16:19:56 drh Exp $ +** $Id: test1.c,v 1.209 2006/03/19 13:00:25 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -230,7 +230,7 @@ static int test_exec_printf( /* ** Usage: sqlite3_mprintf_z_test SEPARATOR ARG0 ARG1 ... ** -** Test the %z format of mprintf(). Use multiple mprintf() calls to +** Test the %z format of sqliteMPrintf(). Use multiple mprintf() calls to ** concatenate arg0 through argn using separator as the separator. ** Return the result. */ @@ -252,6 +252,26 @@ static int test_mprintf_z( } /* +** Usage: sqlite3_mprintf_n_test STRING +** +** Test the %n format of sqliteMPrintf(). Return the length of the +** input string. +*/ +static int test_mprintf_n( + void *NotUsed, + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int argc, /* Number of arguments */ + char **argv /* Text of each argument */ +){ + char *zStr; + int n = 0; + zStr = sqlite3MPrintf("%s%n", argv[1], &n); + sqliteFree(zStr); + Tcl_SetObjResult(interp, Tcl_NewIntObj(n)); + return TCL_OK; +} + +/* ** Usage: sqlite3_get_table_printf DB FORMAT STRING ** ** Invoke the sqlite3_get_table_printf() interface using the open database @@ -3541,6 +3561,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_mprintf_scaled", (Tcl_CmdProc*)sqlite3_mprintf_scaled }, { "sqlite3_mprintf_hexdouble", (Tcl_CmdProc*)sqlite3_mprintf_hexdouble}, { "sqlite3_mprintf_z_test", (Tcl_CmdProc*)test_mprintf_z }, + { "sqlite3_mprintf_n_test", (Tcl_CmdProc*)test_mprintf_n }, { "sqlite3_last_insert_rowid", (Tcl_CmdProc*)test_last_rowid }, { "sqlite3_exec_printf", (Tcl_CmdProc*)test_exec_printf }, { "sqlite3_get_table_printf", (Tcl_CmdProc*)test_get_table_printf }, |