]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Increase test coverage to above 98%. (CVS 3144)
authordrh <drh@noemail.net>
Sun, 19 Mar 2006 13:00:25 +0000 (13:00 +0000)
committerdrh <drh@noemail.net>
Sun, 19 Mar 2006 13:00:25 +0000 (13:00 +0000)
FossilOrigin-Name: 8ae6ccc715b081cd422e847cd9e5cc22b04d8512

manifest
manifest.uuid
src/printf.c
src/shell.c
src/test1.c
test/async.test
test/btree.test
test/btree2.test
test/pragma.test
test/printf.test

index 491bbfaeba882e395fd49d79c7e356064a600b94..024aff7c50a41ce9235fbed0ac72983eacdcb27a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Miscellaneous\scode\scleanup.\s(CVS\s3143)
-D 2006-03-17T13:56:34
+C Increase\stest\scoverage\sto\sabove\s98%.\s(CVS\s3144)
+D 2006-03-19T13:00:25
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -64,16 +64,16 @@ F src/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818
 F src/parse.y ee1887ce0e6eea15cc728913ad3462898f88e9b0
 F src/pragma.c 27d5e395c5d950931c7ac4fe610e7c2993e2fa55
 F src/prepare.c 6afd730cc8851c0920b5f9050294646b1c2ab28c
-F src/printf.c 341e488b549b1a41f83b05a69ce1d7a8258b624c
+F src/printf.c 6801501273c060ffe58160a2aa9a7ff7d0ac162f
 F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
 F src/select.c eefb46a67c8d154aa87e9fad2ffb0671f1fe4027
 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
-F src/shell.c 7a4b16f85d8f6f25d917cdc3d0f7e18f84867adf
+F src/shell.c 5cce3dabcad1f61fa80f8cbcd29bcb5776bda585
 F src/sqlite.h.in 0bf6f03f9a14dde5f3a4f87471840803acaa4497
 F src/sqliteInt.h 18a99e57fd6c8fc4a309107230bcb05556f2194e
 F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e
 F src/tclsqlite.c d20bdf1822c47e367f5acd37823ffe67df40301c
-F src/test1.c d1f210f3a295670e5d82d620bea46fabc73bb0ea
+F src/test1.c becd9202b733debc607b5aec43002769730e1f71
 F src/test2.c ca74a1d8aeb7d9606e8f6b762c5daf85c1a3f92b
 F src/test3.c 86e99724ee898b119ed575ef9f98618afe7e5e5d
 F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
@@ -105,7 +105,7 @@ F test/alter2.test cc0b8832e4e98605dbc26910efd4bb89abe59cb2
 F test/alter3.test a6eec8f454be9b6ce73d8d7dc711453675a10ce7
 F test/altermalloc.test 6e1f404ec021eb2ba6582e3c77b0a35cf206b7af
 F test/analyze.test 2f55535aa335785db1a2f97d3f3831c16c09f8b0
-F test/async.test ae59f861f17f3e9076cd557cd93677b7c77e57b5
+F test/async.test 464dc7c7ccb144e8c82ecca429e6d7cd1c96bd6e
 F test/async2.test 81e4a1fd010c903eb3b763fdb4c4cad7a99afb14
 F test/attach.test 036315207c477211470168bf121b1c493f781515
 F test/attach2.test 0e6a7c54343c85dd877a1e86073a05176043ed40
@@ -124,8 +124,8 @@ F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
 F test/bind.test 238612427136404738a5a74323885923991d7dad
 F test/bindxfer.test b76bfb7df68bb0b238039f4543a84e9612291b54
 F test/blob.test 28c3b25150684ee3d108bb78cfb67a472deef2f0
-F test/btree.test 8aa7424aeec844df990273fe36447e5d7e407261
-F test/btree2.test dbce930b549d5ac883a7d8905c976209ea241db3
+F test/btree.test b1957e39f4858b0722dc0f70f926a2143d3b25f9
+F test/btree2.test 4b56a2a4a4f84d68c77aef271223a713bf5ebafc
 F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4
 F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
@@ -212,8 +212,8 @@ F test/pager.test 6ee95e90ee8295e376e39a6c6566ef6df993601a
 F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e
 F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
 F test/pagesize.test 05c74ea49f790734ec1e9ab765d9bf1cce79b8f2
-F test/pragma.test 745f51617fc8e72c9f202a1149b2b362d030a67c
-F test/printf.test c89f60e789b0fd9452182a05ed906d417f759ddb
+F test/pragma.test 2ca8f71989dc4b9ad68210d1943040321c663a19
+F test/printf.test cdd8e20dd901382a385afcbaa777b9377815c2ad
 F test/progress.test 16496001da445e6534afb94562c286708316d82f x
 F test/quick.test e220b3b6e62fe4fb4e2a703ab2ba730fedfe0424
 F test/quote.test 5891f2338980916cf7415484b4ce785294044adb
@@ -355,7 +355,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P f3fbe72733b49264a6e0a91bf65c7fd80c7b65ea
-R 7b1aa054fc6b49f4e8c9600b3bfb5da8
+P 8f60139f688903f0e635b0a904ab9ca401fbe71f
+R 707703c2ca060ba4895ca4d552db9f64
 U drh
-Z 586be5c0c2d47198993602b46076379e
+Z 3e0248fc76ba37aacd5663fd5b64af16
index b901a5318b9a20c1a6fd7957ad8e1ae794a6c8e5..b293573e85606ebf37eae58599d75ea012a87674 100644 (file)
@@ -1 +1 @@
-8f60139f688903f0e635b0a904ab9ca401fbe71f
\ No newline at end of file
+8ae6ccc715b081cd422e847cd9e5cc22b04d8512
\ No newline at end of file
index 7c4b6b007124e585b01c458b8bd690ef4c6f280a..801db5a837f281d8790624293172c7470b0777f1 100644 (file)
 #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
index a8fdb7144d0536387acae4a190fba288b6866b5d..6c0f6f46a19a5cf4b73b5129055c9a1585d0db62 100644 (file)
@@ -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);
index ffcecc46b5f577dfae367abe09d42cb17e93165c..01dc6d7821225ef49e2132e50098b1e2d9915915 100644 (file)
@@ -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.
 */
@@ -251,6 +251,26 @@ static int test_mprintf_z(
   return TCL_OK;
 }
 
+/*
+** 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
 **
@@ -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 },
index f87d395e4ed225c3df1ed2da9b6b0f3e35203ecd..2a723be975eb73715457babbfb7c970998ba8263 100644 (file)
@@ -6,7 +6,7 @@
 #***********************************************************************
 # This file runs all tests.
 #
-# $Id: async.test,v 1.6 2006/02/14 10:48:40 danielk1977 Exp $
+# $Id: async.test,v 1.7 2006/03/19 13:00:25 drh Exp $
 
 
 if {[catch {sqlite3async_enable}]} {
@@ -53,10 +53,12 @@ foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
 
 # Flush the write-queue and disable asynchronous IO. This should ensure
 # all allocated memory is cleaned up.
+set sqlite3async_trace 1
 sqlite3async_halt idle
 sqlite3async_start
 sqlite3async_wait
 sqlite3async_enable 0
+set sqlite3async_trace 0
 
 really_finish_test
 rename really_do_test do_test
index 8e882951d9ad7a95ce6fd012c43dc2f8f7289d75..ae1b78ffbe815ef9733907e511e3c2dfd50551e9 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is btree database backend
 #
-# $Id: btree.test,v 1.35 2005/01/11 10:25:07 danielk1977 Exp $
+# $Id: btree.test,v 1.36 2006/03/19 13:00:25 drh Exp $
 
 
 set testdir [file dirname $argv0]
@@ -537,108 +537,6 @@ do_test btree-7.1 {
 } {}
 catch {unset key}
 catch {unset data}
-if 0 {
-do_test btree-7.2 {
-  # Each record will be 10 bytes in size.
-  #   + 100 bytes of database header
-  #   + 8 bytes of table header
-  #   + 91*10=910 bytes of cells
-  # Totals 1018 bytes.  6 bytes left over
-  # Keys are 1000 through 1090.
-  for {set i 1000} {$i<1091} {incr i} {
-    set key $i
-    set data [format %5d $i]
-    btree_insert $::c1 $key $data
-  }
-  lrange [btree_cursor_info $::c1] 4 5
-} {6 0}
-#btree_tree_dump $::b1 1
-do_test btree-7.3 {
-  for {set i 1001} {$i<1091} {incr i 2} {
-    btree_move_to $::c1 $i
-    btree_delete $::c1
-  }
-  # Freed 45 blocks.  Total freespace is 456
-  # Keys remaining are even numbers between 1000 and 1090, inclusive
-  lrange [btree_cursor_info $::c1] 4 5
-} {456 45}
-#btree_tree_dump $::b1 1
-do_test btree-7.4 {
-  # The largest free block is 8 bytes long.  But there is also a
-  # huge hole between the cell pointer array and the cellcontent.
-  # But if we insert a large enough record, it should force a defrag.
-  set data 123456789_
-  append data $data
-  append data $data
-  append data $data
-  append data $data
-  append data $data
-  btree_insert $::c1 2000 $data
-  btree_move_to $::c1 2000
-  btree_key $::c1
-} {2000}
-do_test btree-7.5 {
-  lrange [btree_cursor_info $::c1] 4 5
-} {343 0}
-#btree_tree_dump $::b1 1
-
-# Delete an entry to make a hole of a known size, then immediately recreate
-# that entry.  This tests the path into allocateSpace where the hole exactly
-# matches the size of the desired space.
-#
-# Keys are even numbers between 1000 and 1090 and one record of 2000.
-# There are 47 keys total.
-#
-do_test btree-7.6 {
-  btree_move_to $::c1 1006
-  btree_delete $::c1
-  btree_move_to $::c1 1010
-  btree_delete $::c1
-} {}
-do_test btree-7.7 {
-  lrange [btree_cursor_info $::c1] 4 5
-} {363 2}   ;# Create two new holes of 10 bytes each
-#btree_page_dump $::b1 1
-do_test btree-7.8 {
-  btree_insert $::c1 1006 { 1006}
-  lrange [btree_cursor_info $::c1] 4 5
-} {353 1}   ;# Filled in the first hole
-btree_page_dump $::b1 1
-
-# Make sure the freeSpace() routine properly coaleses adjacent memory blocks
-#
-do_test btree-7.9 {
-  btree_move_to $::c1 1012
-  btree_delete $::c1
-  lrange [btree_cursor_info $::c1] 4 5
-} {363 2}  ;# Coalesce with the hole before
-btree_page_dump $::b1 1
-exit
-do_test btree-7.10 {
-  btree_move_to $::c1 1008
-  btree_delete $::c1
-  lrange [btree_cursor_info $::c1] 4 5
-} {468 2}  ;# Coalesce with whole after
-do_test btree-7.11 {
-  btree_move_to $::c1 1030
-  btree_delete $::c1
-  lrange [btree_cursor_info $::c1] 4 5
-} {478 3}   ;# Make a new hole
-do_test btree-7.13 {
-  btree_move_to $::c1 1034
-  btree_delete $::c1
-  lrange [btree_cursor_info $::c1] 4 5
-} {488 4}   ;# Make another hole
-do_test btree-7.14 {
-  btree_move_to $::c1 1032
-  btree_delete $::c1
-  lrange [btree_cursor_info $::c1] 4 5
-} {498 3}   ;# The freed space should coalesce on both ends
-#btree_page_dump $::b1 2
-do_test btree-7.15 {
-  lindex [btree_pager_stats $::b1] 1
-} {1}
-} ;# endif
 
 # Check to see that data on overflow pages work correctly.
 #
@@ -648,7 +546,9 @@ do_test btree-8.1 {
   set ::data $data
   btree_insert $::c1 2020 $data
 } {}
-#btree_page_dump $::b1 1
+btree_page_dump $::b1 1
+btree_page_dump $::b1 2
+btree_page_dump $::b1 3
 do_test btree-8.1.1 {
   lindex [btree_pager_stats $::b1] 1
 } {1}
index 515ba8e76a9e491aef332dac333bdf318eac1d49..35263c1d83da77889be1c30087a2148ac550604f 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is btree database backend
 #
-# $Id: btree2.test,v 1.14 2005/01/11 10:25:07 danielk1977 Exp $
+# $Id: btree2.test,v 1.15 2006/03/19 13:00:25 drh Exp $
 
 
 set testdir [file dirname $argv0]
@@ -370,6 +370,11 @@ foreach {N L} {
     lindex [btree_pager_stats $::b] 1
   } {6}
   do_test btree2-$testno.6  {
+    btree_cursor_info $::c2
+    btree_cursor_info $::c3
+    btree_cursor_info $::c4
+    btree_cursor_info $::c5
+    btree_cursor_info $::c6
     btree_close_cursor $::c2
     btree_close_cursor $::c3
     btree_close_cursor $::c4
index 52fdf72b27cf6571e0c235fd2a86f8a22cb4efb1..55bb7b1818e957df87539fb3ce165e46a64d9e11 100644 (file)
@@ -12,7 +12,7 @@
 #
 # This file implements tests for the PRAGMA command.
 #
-# $Id: pragma.test,v 1.41 2006/03/03 21:20:17 drh Exp $
+# $Id: pragma.test,v 1.42 2006/03/19 13:00:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -33,6 +33,11 @@ source $testdir/tester.tcl
 # pragma-11.*: Test the collation_list pragma.
 #
 
+ifcapable !pragma {
+  finish_test
+  return
+}
+
 # Delete the preexisting database to avoid the special setup
 # that the "all.test" script does.
 #
@@ -798,6 +803,28 @@ ifcapable schema_pragmas&&tempdb {
   db2 close
 }
 
+do_test pragma-13.1 {
+  execsql {
+    DROP TABLE IF EXISTS t4;
+    PRAGMA vdbe_trace=on;
+    PRAGMA vdbe_listing=on;
+    PRAGMA sql_trace=on;
+    CREATE TABLE t4(a INTEGER PRIMARY KEY,b);
+    INSERT INTO t4(b) VALUES(x'0123456789abcdef0123456789abcdef0123456789');
+    INSERT INTO t4(b) VALUES(randstr(30,30));
+    INSERT INTO t4(b) VALUES(1.23456);
+    INSERT INTO t4(b) VALUES(NULL);
+    INSERT INTO t4(b) VALUES(0);
+    INSERT INTO t4(b) SELECT b||b||b||b FROM t4;
+    SELECT * FROM t4;
+  }
+  execsql {
+    PRAGMA vdbe_trace=off;
+    PRAGMA vdbe_listing=off;
+    PRAGMA sql_trace=off;
+  }
+} {}
+
 # Reset the sqlite3_temp_directory variable for the next run of tests:
 sqlite3 dbX :memory:
 dbX eval {PRAGMA temp_store_directory = ""}
index b3eb225e96a202e772628337a4ccdd13c0504869..bd0a230972326b938126759faaba411dde9c914d 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the sqlite_*_printf() interface.
 #
-# $Id: printf.test,v 1.20 2006/03/06 20:55:46 drh Exp $
+# $Id: printf.test,v 1.21 2006/03/19 13:00:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -231,5 +231,12 @@ do_test printf-13.3 {
   sqlite3_mprintf_hexdouble %.20f 4693b8b5b5056e17
 } {100000000000000000000000000000000.00000000000000000000}
 
+do_test printf-14.1 {
+  sqlite3_mprintf_str {abc-%y-123} 0 0 {not used}
+} {abc-}
+do_test printf-14.2 {
+  sqlite3_mprintf_n_test {xyzzy}
+} 5
+
 
 finish_test