Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Increased test coverage on trigger.c and printf.c. (CVS 2601) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
842a80bd8f18d6fd046604f9a057bcd7 |
User & Date: | drh 2005-08-19 02:26:27.000 |
Context
2005-08-19
| ||
03:03 | Additional tests for better coverage. (CVS 2602) (check-in: 4281a838f2 user: drh tags: trunk) | |
02:26 | Increased test coverage on trigger.c and printf.c. (CVS 2601) (check-in: 842a80bd8f user: drh tags: trunk) | |
01:07 | More test coverage enhancements. (CVS 2600) (check-in: 0b6cd5acc0 user: drh tags: trunk) | |
Changes
Changes to main.mk.
︙ | ︙ | |||
554 555 556 557 558 559 560 | # install: sqlite3 libsqlite3.a sqlite3.h mv sqlite3 /usr/bin mv libsqlite3.a /usr/lib mv sqlite3.h /usr/include clean: | | | 554 555 556 557 558 559 560 561 562 563 564 565 | # install: sqlite3 libsqlite3.a sqlite3.h mv sqlite3 /usr/bin mv libsqlite3.a /usr/lib mv sqlite3.h /usr/include clean: rm -f *.o sqlite3 libsqlite3.a sqlite3.h opcodes.* crashtest rm -f lemon lempar.c parse.* sqlite*.tar.gz mkkeywordhash keywordhash.h rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out rm -rf tsrc |
Changes to src/printf.c.
︙ | ︙ | |||
415 416 417 418 419 420 421 | break; case etFLOAT: case etEXP: case etGENERIC: realvalue = va_arg(ap,double); #ifndef etNOFLOATINGPOINT if( precision<0 ) precision = 6; /* Set default precision */ | | | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | break; case etFLOAT: case etEXP: case etGENERIC: realvalue = va_arg(ap,double); #ifndef etNOFLOATINGPOINT if( precision<0 ) precision = 6; /* Set default precision */ if( precision>etBUFSIZE/2-10 ) precision = etBUFSIZE/2-10; if( realvalue<0.0 ){ realvalue = -realvalue; prefix = '-'; }else{ if( flag_plussign ) prefix = '+'; else if( flag_blanksign ) prefix = ' '; else prefix = 0; |
︙ | ︙ | |||
468 469 470 471 472 473 474 | }else{ precision = precision - exp; xtype = etFLOAT; } }else{ flag_rtz = 0; } | < < < < < < | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | }else{ precision = precision - exp; xtype = etFLOAT; } }else{ flag_rtz = 0; } if( xtype==etEXP ){ e2 = 0; }else{ e2 = exp; } nsd = 0; flag_dp = (precision>0) | flag_alternateform | flag_altform2; |
︙ | ︙ | |||
587 588 589 590 591 592 593 | }else if( xtype==etDYNSTRING ){ zExtra = bufpt; } length = strlen(bufpt); if( precision>=0 && precision<length ) length = precision; break; case etSQLESCAPE: | | < | | | | | | | | | | | | | | | | | | | | | | | | | | < > | 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | }else if( xtype==etDYNSTRING ){ zExtra = bufpt; } length = strlen(bufpt); if( precision>=0 && precision<length ) length = precision; break; case etSQLESCAPE: case etSQLESCAPE2: { int i, j, n, c, isnull; int needQuote; char *arg = va_arg(ap,char*); isnull = arg==0; if( isnull ) arg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)"); for(i=n=0; (c=arg[i])!=0; i++){ if( c=='\'' ) n++; } needQuote = !isnull && xtype==etSQLESCAPE2; n += i + 1 + needQuote*2; if( n>etBUFSIZE ){ bufpt = zExtra = sqliteMalloc( n ); if( bufpt==0 ) return -1; }else{ bufpt = buf; } j = 0; if( needQuote ) bufpt[j++] = '\''; for(i=0; (c=arg[i])!=0; i++){ bufpt[j++] = c; if( c=='\'' ) bufpt[j++] = c; } if( needQuote ) bufpt[j++] = '\''; bufpt[j] = 0; length = j; if( precision>=0 && precision<length ) length = precision; break; } case etTOKEN: { Token *pToken = va_arg(ap, Token*); if( pToken && pToken->z ){ (*func)(arg, pToken->z, pToken->n); } length = width = 0; break; |
︙ | ︙ |
Changes to test/printf.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 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. # | | | 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.17 2005/08/19 02:26:27 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} { set v32 [expr {$v&0xffffffff}] |
︙ | ︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | do_test printf-9.2 { sqlite3_mprintf_int {%*.*c} -4 1 66 } {B } do_test printf-9.3 { sqlite3_mprintf_int {%*.*c} 4 1 67 } { C} do_test printf-9.4 { sqlite3_mprintf_int {%yhello} 0 0 0 } {%} # Ticket #812 # do_test printf-10.1 { sqlite3_mprintf_stronly %s {} | > > > > > > > > | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | do_test printf-9.2 { sqlite3_mprintf_int {%*.*c} -4 1 66 } {B } do_test printf-9.3 { sqlite3_mprintf_int {%*.*c} 4 1 67 } { C} do_test printf-9.4 { sqlite3_mprintf_int {%d %d %c} 4 1 67 } {4 1 C} set ten { } set fifty $ten$ten$ten$ten$ten do_test printf-9.5 { sqlite3_mprintf_int {%d %*c} 1 -201 67 } "1 C$fifty$fifty$fifty$fifty" do_test printf-9.6 { sqlite3_mprintf_int {%yhello} 0 0 0 } {%} # Ticket #812 # do_test printf-10.1 { sqlite3_mprintf_stronly %s {} |
︙ | ︙ | |||
201 202 203 204 205 206 207 | do_test printf-11.6 { sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e10 } {1 1 10000000000.0} do_test printf-11.7 { sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e300 } {1 1 1.0e+300} | > | > > > > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | do_test printf-11.6 { sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e10 } {1 1 10000000000.0} do_test printf-11.7 { sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e300 } {1 1 1.0e+300} # Additional tests for coverage # do_test printf-12.1 { sqlite3_mprintf_double {%d %d %.2000g} 1 1 1.0 } {1 1 1} finish_test |
Added test/trigger7.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 115 116 117 118 119 120 121 | # 2005 August 18 # # 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. # # This file implements tests to increase coverage of trigger.c. # # $Id: trigger7.test,v 1.1 2005/08/19 02:26:27 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!trigger} { finish_test return } # Error messages resulting from qualified trigger names. # do_test trigger7-1.1 { execsql { CREATE TABLE t1(x, y); } catchsql { CREATE TEMP TRIGGER main.r1 AFTER INSERT ON t1 BEGIN SELECT 'no nothing'; END } } {1 {temporary trigger may not have qualified name}} do_test trigger7-1.2 { catchsql { CREATE TRIGGER not_a_db.r1 AFTER INSERT ON t1 BEGIN SELECT 'no nothing'; END } } {1 {unknown database not_a_db}} # When the UPDATE OF syntax is used, no code is generated for triggers # that do not match the update columns. # ifcapable explain { do_test trigger7-2.1 { execsql { CREATE TRIGGER r1 AFTER UPDATE OF x ON t1 BEGIN SELECT '___update_t1.x___'; END; CREATE TRIGGER r2 AFTER UPDATE OF y ON t1 BEGIN SELECT '___update_t1.y___'; END; } set txt [db eval {EXPLAIN UPDATE t1 SET x=5}] string match *___update_t1.x___* $txt } 1 do_test trigger7-2.2 { set txt [db eval {EXPLAIN UPDATE t1 SET x=5}] string match *___update_t1.y___* $txt } 0 do_test trigger7-2.3 { set txt [db eval {EXPLAIN UPDATE t1 SET y=5}] string match *___update_t1.x___* $txt } 0 do_test trigger7-2.4 { set txt [db eval {EXPLAIN UPDATE t1 SET y=5}] string match *___update_t1.y___* $txt } 1 do_test trigger7-2.5 { set txt [db eval {EXPLAIN UPDATE t1 SET rowid=5}] string match *___update_t1.x___* $txt } 0 do_test trigger7-2.6 { set txt [db eval {EXPLAIN UPDATE t1 SET rowid=5}] string match *___update_t1.x___* $txt } 0 } # Test the ability to create many triggers on the same table, then # selectively drop those triggers. # do_test trigger7-3.1 { execsql { CREATE TABLE t2(x,y,z); CREATE TRIGGER t2r1 AFTER INSERT ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r2 BEFORE INSERT ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r3 AFTER UPDATE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r4 BEFORE UPDATE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r5 AFTER DELETE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r6 BEFORE DELETE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r7 AFTER INSERT ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r8 BEFORE INSERT ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r9 AFTER UPDATE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r10 BEFORE UPDATE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r11 AFTER DELETE ON t2 BEGIN SELECT 1; END; CREATE TRIGGER t2r12 BEFORE DELETE ON t2 BEGIN SELECT 1; END; DROP TRIGGER t2r6; } } {} # This test corrupts the database file so it must be the last test # in the series. # do_test trigger7-99.1 { execsql { PRAGMA writable_schema=on; UPDATE sqlite_master SET sql='nonsense'; } db close sqlite3 db test.db catchsql { DROP TRIGGER t2r5 } } {1 {malformed database schema - near "nonsense": syntax error}} finish_test |