SQLite

Check-in [7d5fc35b5d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added printf-4.(2-4) test cases to test new %Q format specifier. (CVS 622)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7d5fc35b5d38230230344b4f70763f75940ab908
User & Date: chw 2002-06-16 04:56:37.000
Context
2002-06-16
04:57
Added explanation and examples for %Q format specifier. (CVS 623) (check-in: 633ce4dd25 user: chw tags: trunk)
04:56
Added printf-4.(2-4) test cases to test new %Q format specifier. (CVS 622) (check-in: 7d5fc35b5d user: chw tags: trunk)
04:55
Added %Q format specifier: like %q but automatic enclosing in single quotes, NULL pointers replaced by NULL w/o single-quotes. (CVS 621) (check-in: b9c7ecc2f9 user: chw tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/printf.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# 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 implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite_*_printf() interface.
#
# $Id: printf.test,v 1.4 2001/09/20 01:44:43 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 {













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# 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 implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite_*_printf() interface.
#
# $Id: printf.test,v 1.5 2002/06/16 04:56:37 chw 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 {
86
87
88
89
90
91
92









93
94
95
96
97
98
99
100
101
102
103
104
105
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'}










do_test printf-5.1 {
  set x [sqlite_mprintf_str {%d %d %100000s} 0 0 {Hello}]
  string length $x
} {994}
do_test printf-5.2 {
  sqlite_mprintf_str {%d %d (%-10.10s) %} -9 -10 {HelloHelloHello}
} {-9 -10 (HelloHello) %}
do_test printf-5.3 {
  sqlite_mprintf_str {%% %d %d (%=10s)} 5 6 Hello
} {% 5 6 (  Hello   )}

finish_test







>
>
>
>
>
>
>
>
>













86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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'}
do_test printf-4.2 {
  sqlite_mprintf_str {%d %d A NULL pointer in %%q: '%q'} 1 2
} {1 2 A NULL pointer in %q: '(NULL)'}
do_test printf-4.3 {
  sqlite_mprintf_str {%d %d A quoted string: %Q} 1 2 {Hi Y'all}
} {1 2 A quoted string: 'Hi Y''all'}
do_test printf-4.4 {
  sqlite_mprintf_str {%d %d A NULL pointer in %%Q: %Q} 1 2
} {1 2 A NULL pointer in %Q: NULL}

do_test printf-5.1 {
  set x [sqlite_mprintf_str {%d %d %100000s} 0 0 {Hello}]
  string length $x
} {994}
do_test printf-5.2 {
  sqlite_mprintf_str {%d %d (%-10.10s) %} -9 -10 {HelloHelloHello}
} {-9 -10 (HelloHello) %}
do_test printf-5.3 {
  sqlite_mprintf_str {%% %d %d (%=10s)} 5 6 Hello
} {% 5 6 (  Hello   )}

finish_test