1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add a new test command, sqlite3_mprintf_long, for testing the behavior

of "long integer" printf formatting.  Ticket #3621. (CVS 6224)

FossilOrigin-Name: 3ba1a17b1306bc61b9861ec8d3b239e16a3081ba
This commit is contained in:
drh
2009-02-01 00:21:09 +00:00
parent 565911e912
commit c5cad1e350
4 changed files with 44 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Make\sthe\sTO\skeyword\savailable\seven\sif\sSQLITE_OMIT_ALTERTABLE\sis\sdefined.\r\nTicket\s#3622.\s(CVS\s6223) C Add\sa\snew\stest\scommand,\ssqlite3_mprintf_long,\sfor\stesting\sthe\sbehavior\nof\s"long\sinteger"\sprintf\sformatting.\s\sTicket\s#3621.\s(CVS\s6224)
D 2009-02-01T00:00:46 D 2009-02-01T00:21:10
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52 F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -163,7 +163,7 @@ F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 332ab0ea691e63862e2a8bdfe2c0617ee61062a3 F src/table.c 332ab0ea691e63862e2a8bdfe2c0617ee61062a3
F src/tclsqlite.c 7d77c3899d0244804d2773c9157e783788627762 F src/tclsqlite.c 7d77c3899d0244804d2773c9157e783788627762
F src/test1.c 4a06b801c6167f18b8b2108de8f2754f2a6de116 F src/test1.c 72ed8f7cabea905401691a836d578b8317b4d76e
F src/test2.c 9689e7d3b7791da8c03f9acd1ea801802cb83c17 F src/test2.c 9689e7d3b7791da8c03f9acd1ea801802cb83c17
F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14 F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14
F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
@ -483,7 +483,7 @@ F test/pcache2.test 46efd980a89f737847b99327bda19e08fe11e402
F test/permutations.test 2e777ae1eeb11b777b31aad929c4351464758441 F test/permutations.test 2e777ae1eeb11b777b31aad929c4351464758441
F test/pragma.test a35b0be36542477183168cdb8b743f5c0d883c4d F test/pragma.test a35b0be36542477183168cdb8b743f5c0d883c4d
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef F test/printf.test 47e9e5bbec8509023479d54ceb71c9d05a95308a
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/quick.test 9ab91798b047684f0dd26ee698920dbb69a30a10 F test/quick.test 9ab91798b047684f0dd26ee698920dbb69a30a10
@ -693,7 +693,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 9cd43c82a3c123829806aa7bf14efdd29f4424d8 P 3890985ca6750584876596fd0a124f47ee032075
R c837b874eda97feb44e3ddcebddfe5a4 R 01401eed13c10e23eb0e903de34beac8
U drh U drh
Z 7f87a792868ba843d85460fd8f16ca72 Z cd9d69a9bd245a1f043eb0c9f0fc7010

View File

@ -1 +1 @@
3890985ca6750584876596fd0a124f47ee032075 3ba1a17b1306bc61b9861ec8d3b239e16a3081ba

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.344 2009/01/30 05:59:11 shane Exp $ ** $Id: test1.c,v 1.345 2009/02/01 00:21:10 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@ -1259,6 +1259,38 @@ static int sqlite3_mprintf_int64(
return TCL_OK; return TCL_OK;
} }
/*
** Usage: sqlite3_mprintf_long FORMAT INTEGER INTEGER INTEGER
**
** Call mprintf with three long integer arguments. This might be the
** same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on
** platform.
*/
static int sqlite3_mprintf_long(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
int i;
long int a[3];
int b[3];
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], &b[i-2]) ) return TCL_ERROR;
a[i-2] = (long int)b[i-2];
}
z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]);
Tcl_AppendResult(interp, z, 0);
sqlite3_free(z);
return TCL_OK;
}
/* /*
** Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING ** Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING
** **
@ -4807,6 +4839,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "db_leave", (Tcl_CmdProc*)db_leave }, { "db_leave", (Tcl_CmdProc*)db_leave },
{ "sqlite3_mprintf_int", (Tcl_CmdProc*)sqlite3_mprintf_int }, { "sqlite3_mprintf_int", (Tcl_CmdProc*)sqlite3_mprintf_int },
{ "sqlite3_mprintf_int64", (Tcl_CmdProc*)sqlite3_mprintf_int64 }, { "sqlite3_mprintf_int64", (Tcl_CmdProc*)sqlite3_mprintf_int64 },
{ "sqlite3_mprintf_long", (Tcl_CmdProc*)sqlite3_mprintf_long },
{ "sqlite3_mprintf_str", (Tcl_CmdProc*)sqlite3_mprintf_str }, { "sqlite3_mprintf_str", (Tcl_CmdProc*)sqlite3_mprintf_str },
{ "sqlite3_snprintf_str", (Tcl_CmdProc*)sqlite3_snprintf_str }, { "sqlite3_snprintf_str", (Tcl_CmdProc*)sqlite3_snprintf_str },
{ "sqlite3_mprintf_stronly", (Tcl_CmdProc*)sqlite3_mprintf_stronly}, { "sqlite3_mprintf_stronly", (Tcl_CmdProc*)sqlite3_mprintf_stronly},

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing the sqlite_*_printf() interface. # focus of this file is testing the sqlite_*_printf() interface.
# #
# $Id: printf.test,v 1.30 2008/07/09 16:51:52 drh Exp $ # $Id: printf.test,v 1.31 2009/02/01 00:21:10 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -3540,7 +3540,7 @@ do_test printf-8.1 {
sqlite3_mprintf_int {%u %u %u} 0x7fffffff 0x80000000 0xffffffff sqlite3_mprintf_int {%u %u %u} 0x7fffffff 0x80000000 0xffffffff
} {2147483647 2147483648 4294967295} } {2147483647 2147483648 4294967295}
do_test printf-8.2 { do_test printf-8.2 {
sqlite3_mprintf_int {%lu %lu %lu} 0x7fffffff 0x80000000 0xffffffff sqlite3_mprintf_long {%lu %lu %lu} 0x7fffffff 0x80000000 0xffffffff
} {2147483647 2147483648 4294967295} } {2147483647 2147483648 4294967295}
do_test printf-8.3 { do_test printf-8.3 {
sqlite3_mprintf_int64 {%llu %llu %llu} 2147483647 2147483648 4294967296 sqlite3_mprintf_int64 {%llu %llu %llu} 2147483647 2147483648 4294967296