Add evidence marks and additional test cases for the printf() SQL function.

FossilOrigin-Name: 93121d3097a43997af3c0de65bd9bd7663845fa2
This commit is contained in:
drh 2013-12-17 16:32:56 +00:00
parent afa5af807c
commit 3a8aec5e13
3 changed files with 49 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\sprintf()\sSQL\sfunction.
D 2013-12-17T16:10:57.193
C Add\sevidence\smarks\sand\sadditional\stest\scases\sfor\sthe\sprintf()\sSQL\sfunction.
D 2013-12-17T16:32:56.710
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -739,7 +739,7 @@ F test/permutations.test af3278cbea3a19e025d5169be8193ff48dc3f862
F test/pragma.test e882183ecd21d064cec5c7aaea174fbd36293429
F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/printf2.test 2f0978059768bb039d3ee09466bdcd06fc7a6a86
F test/printf2.test 414fcba6d6c10e0a5e58efd213811e5ead4635a0
F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca
@ -1147,8 +1147,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 5716fc2341ddd8cf64139e7168597f864da4e10b 3375571a5e267744c19a7c310840256cec57a242
R 2f73ea36e182ebaad881490b3d78bb71
T +closed 3375571a5e267744c19a7c310840256cec57a242
P a1bb62f91a85af0584100c3ad77877a949c30cca
R 69f0b68d0886123f335b52e69a6c748f
U drh
Z 3980fde025c24face9a02012ab95cda1
Z 3ce3ba9d696aa32fcf98b10717e459c0

View File

@ -1 +1 @@
a1bb62f91a85af0584100c3ad77877a949c30cca
93121d3097a43997af3c0de65bd9bd7663845fa2

View File

@ -11,13 +11,23 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the printf() SQL function.
#
#
# EVIDENCE-OF: R-63057-40065 The printf(FORMAT,...) SQL function works
# like the sqlite3_mprintf() C-language function and the printf()
# function from the standard C library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# EVIDENCE-OF: R-40086-60101 If the FORMAT argument is missing or NULL
# then the result is NULL.
#
do_execsql_test printf2-1.1 {
SELECT printf();
} {{}}
SELECT quote(printf()), quote(printf(NULL,1,2,3));
} {NULL NULL}
do_execsql_test printf2-1.2 {
SELECT printf('hello');
} {hello}
@ -48,6 +58,9 @@ do_execsql_test printf2-1.10 {
do_execsql_test printf2-1.11 {
SELECT printf('%lld%n',314159.2653,'hi');
} {314159}
# EVIDENCE-OF: R-20555-31089 The %z format is interchangable with %s.
#
do_execsql_test printf2-1.12 {
SELECT printf('%.*z',5,'abcdefghijklmnop');
} {abcde}
@ -55,5 +68,32 @@ do_execsql_test printf2-1.13 {
SELECT printf('%c','abcdefghijklmnop');
} {a}
# EVIDENCE-OF: R-02347-27622 The %n format is silently ignored and does
# not consume an argument.
#
do_execsql_test printf2-2.1 {
CREATE TABLE t1(a,b,c);
INSERT INTO t1 VALUES(1,2,3);
INSERT INTO t1 VALUES(-1,-2,-3);
INSERT INTO t1 VALUES('abc','def','ghi');
INSERT INTO t1 VALUES(1.5,2.25,3.125);
SELECT printf('(%s)-%n-(%s)',a,b,c) FROM t1 ORDER BY rowid;
} {(1)--(2) (-1)--(-2) (abc)--(def) (1.5)--(2.25)}
# EVIDENCE-OF: R-56064-04001 The %p format is an alias for %X.
#
do_execsql_test printf2-2.2 {
SELECT printf('%s=(%p)',a,a) FROM t1 ORDER BY a;
} {-1=(FFFFFFFFFFFFFFFF) 1=(1) 1.5=(1) abc=(0)}
# EVIDENCE-OF: R-29410-53018 If there are too few arguments in the
# argument list, missing arguments are assumed to have a NULL value,
# which is translated into 0 or 0.0 for numeric formats or an empty
# string for %s.
#
do_execsql_test printf2-2.3 {
SELECT printf('%s=(%d/%g/%s)',a) FROM t1 ORDER BY a;
} {-1=(0/0/) 1=(0/0/) 1.5=(0/0/) abc=(0/0/)}
finish_test