/ Check-in [fde6142b]
Login

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

Overview
Comment:Test sqlite3_bind_zeroblob(). Only include sqlite3Utf8To8 in builds if SQLITE_DEBUG is defined. (CVS 4363)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fde6142b7bb33198b3d6b65cfbddfad61694b1fb
User & Date: danielk1977 2007-09-01 11:04:26
Context
2007-09-01
16:16
Remove the syncOk argument to pager_recycle. Now that sqlite3_memory_release uses a global lru list of page, it is no longer required. (CVS 4364) check-in: fb27692a user: danielk1977 tags: trunk
11:04
Test sqlite3_bind_zeroblob(). Only include sqlite3Utf8To8 in builds if SQLITE_DEBUG is defined. (CVS 4363) check-in: fde6142b user: danielk1977 tags: trunk
10:01
Allow sqlite3GetInt32 to recognize 10-digit decimal numbers as 32-bit. (CVS 4362) check-in: 7571345d user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing all sorts of SQLite interfaces.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.273 2007/09/01 09:02:54 danielk1977 Exp $
           16  +** $Id: test1.c,v 1.274 2007/09/01 11:04:26 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   /*
................................................................................
  2458   2458   ){
  2459   2459     sqlite3_stmt *pStmt;
  2460   2460     int idx;
  2461   2461     int n;
  2462   2462     int rc;
  2463   2463   
  2464   2464     if( objc!=4 ){
  2465         -    Tcl_AppendResult(interp, "wrong # args: should be \"",
  2466         -        Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE", 0);
         2465  +    Tcl_WrongNumArgs(interp, 1, objv, "STMT IDX N");
  2467   2466       return TCL_ERROR;
  2468   2467     }
  2469   2468   
  2470   2469     if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  2471   2470     if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
  2472   2471     if( Tcl_GetIntFromObj(interp, objv[3], &n) ) return TCL_ERROR;
  2473   2472   

Changes to src/test_hexio.c.

    13     13   ** implements TCL commands for reading and writing the binary
    14     14   ** database files and displaying the content of those files as
    15     15   ** hexadecimal.  We could, in theory, use the built-in "binary"
    16     16   ** command of TCL to do a lot of this, but there are some issues
    17     17   ** with historical versions of the "binary" command.  So it seems
    18     18   ** easier and safer to build our own mechanism.
    19     19   **
    20         -** $Id: test_hexio.c,v 1.4 2007/08/16 04:30:40 drh Exp $
           20  +** $Id: test_hexio.c,v 1.5 2007/09/01 11:04:27 danielk1977 Exp $
    21     21   */
    22     22   #include "sqliteInt.h"
    23     23   #include "tcl.h"
    24     24   #include <stdlib.h>
    25     25   #include <string.h>
    26     26   #include <assert.h>
    27     27   
................................................................................
   287    287   */
   288    288   static int utf8_to_utf8(
   289    289     void * clientData,
   290    290     Tcl_Interp *interp,
   291    291     int objc,
   292    292     Tcl_Obj *CONST objv[]
   293    293   ){
          294  +#ifdef SQLITE_DEBUG
   294    295     int n;
   295    296     int nOut;
   296    297     const unsigned char *zOrig;
   297    298     unsigned char *z;
   298    299     if( objc!=2 ){
   299    300       Tcl_WrongNumArgs(interp, 1, objv, "HEX");
   300    301       return TCL_ERROR;
................................................................................
   303    304     z = sqlite3_malloc( n+3 );
   304    305     n = hexToBin(zOrig, n, z);
   305    306     z[n] = 0;
   306    307     nOut = sqlite3Utf8To8(z);
   307    308     binToHex(z,nOut);
   308    309     Tcl_AppendResult(interp, (char*)z, 0);
   309    310     sqlite3_free(z);
          311  +#endif
   310    312     return TCL_OK;
   311    313   }
   312    314   
   313    315   
   314    316   /*
   315    317   ** Register commands with the TCL interpreter.
   316    318   */

Changes to src/utf.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used to translate between UTF-8, 
    13     13   ** UTF-16, UTF-16BE, and UTF-16LE.
    14     14   **
    15         -** $Id: utf.c,v 1.56 2007/08/21 19:33:57 drh Exp $
           15  +** $Id: utf.c,v 1.57 2007/09/01 11:04:27 danielk1977 Exp $
    16     16   **
    17     17   ** Notes on UTF-8:
    18     18   **
    19     19   **   Byte-0    Byte-1    Byte-2    Byte-3    Value
    20     20   **  0xxxxxxx                                 00000000 00000000 0xxxxxxx
    21     21   **  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx
    22     22   **  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx
................................................................................
   452    452         READ_UTF16LE(z, c);
   453    453         n++;
   454    454       }
   455    455     }
   456    456     return (z-(char const *)zIn)-((c==0)?2:0);
   457    457   }
   458    458   
   459         -#if defined(SQLITE_TEST)
          459  +/* This test function is not currently used by the automated test-suite. 
          460  +** Hence it is only available in debug builds.
          461  +*/
          462  +#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
   460    463   /*
   461    464   ** Translate UTF-8 to UTF-8.
   462    465   **
   463    466   ** This has the effect of making sure that the string is well-formed
   464    467   ** UTF-8.  Miscoded characters are removed.
   465    468   **
   466    469   ** The translation is done in-place (since it is impossible for the

Changes to test/all.test.

     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file runs all tests.
    12     12   #
    13         -# $Id: all.test,v 1.47 2007/08/31 17:42:48 danielk1977 Exp $
           13  +# $Id: all.test,v 1.48 2007/09/01 11:04:28 danielk1977 Exp $
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   rename finish_test really_finish_test
    18     18   proc finish_test {} {
    19     19     # no-op
    20     20   }
................................................................................
    58     58   lappend EXCLUDE crash.test             ;# Run seperately later.
    59     59   lappend EXCLUDE crash2.test            ;# Run seperately later.
    60     60   lappend EXCLUDE autovacuum_crash.test  ;# Run seperately later.
    61     61   lappend EXCLUDE quick.test             ;# Alternate test driver script
    62     62   lappend EXCLUDE malloc.test            ;# Run seperately later.
    63     63   lappend EXCLUDE misuse.test            ;# Run seperately later.
    64     64   lappend EXCLUDE memleak.test           ;# Alternate test driver script
    65         -lappend EXCLUDE sqllimits1.test        ;# Default values use too much memory
    66     65   lappend EXCLUDE fuzz.test
    67     66   lappend EXCLUDE soak.test              ;# Takes a very long time (default 1 hr)
    68     67   
    69     68   # Files to include in the test.  If this list is empty then everything
    70     69   # that is not in the EXCLUDE list is run.
    71     70   #
    72     71   set INCLUDE {

Changes to test/sqllimits1.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # This file contains tests to verify that the limits defined in
    13     13   # sqlite source file limits.h are enforced.
    14     14   #
    15         -# $Id: sqllimits1.test,v 1.12 2007/09/01 05:57:50 danielk1977 Exp $
           15  +# $Id: sqllimits1.test,v 1.13 2007/09/01 11:04:28 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Test organization:
    21     21   #
    22     22   #     sqllimits-1.*:  SQLITE_MAX_LENGTH
    23     23   #     sqllimits-2.*:  SQLITE_MAX_SQL_LENGTH
    24         -#     sqllimits-3.*:  SQLITE_MAX_PAGE_COUNT
           24  +#     sqllimits-3.*:  SQLITE_MAX_PAGE_COUNT (and the max_page_count pragma)
    25     25   #     sqllimits-4.*:  SQLITE_MAX_COLUMN
    26     26   #
    27     27   #
    28     28   #     sqllimits-7.*:   SQLITE_MAX_FUNCTION_ARG  
    29     29   #     sqllimits-8.*:   SQLITE_MAX_ATTACHED
    30     30   #     sqllimits-9.*:   SQLITE_MAX_VARIABLE_NUMBER
    31     31   #     sqllimits-10.*:  SQLITE_MAX_PAGE_SIZE
................................................................................
    33     33   #
    34     34   # Todo:
    35     35   #
    36     36   #     sqllimits-5.*:   SQLITE_MAX_EXPR_DEPTH            (sqlite todo)
    37     37   #     sqllimits-6.*:   SQLITE_MAX_VDBE_OP               (sqlite todo)
    38     38   #     sqllimits-12.*:  SQLITE_MAX_PAGE_COUNT            (sqlite todo)
    39     39   #
           40  +
           41  +unset -nocomplain saved
           42  +foreach var [info vars SQLITE_MAX_*] {
           43  +  set saved($var) [set $var]
           44  +}
    40     45   
    41     46   set SQLITE_MAX_LENGTH                 100000
    42     47   set SQLITE_MAX_COLUMN
    43     48   set SQLITE_MAX_SQL_LENGTH             100000
    44     49   set SQLITE_MAX_EXPR_DEPTH               1000
    45     50   set SQLITE_MAX_COMPOUND_SELECT             5
    46     51   set SQLITE_MAX_VDBE_OP
................................................................................
   468    473   do_test sqllimits-1.12.2 {
   469    474     set ::format "[string repeat A 60][string repeat "%J" $::N]"
   470    475     catchsql {
   471    476       SELECT strftime($::format, 1);
   472    477     }
   473    478   } {1 {string or blob too big}}
   474    479   
          480  +
          481  +foreach {key value} [array get saved] {
          482  +  catch {set $key $value}
          483  +}
   475    484   finish_test

Changes to test/zeroblob.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing of the zero-filled blob functionality
    13     13   # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
    14     14   # and the built-in zeroblob() SQL function.
    15     15   #
    16         -# $Id: zeroblob.test,v 1.6 2007/06/07 19:08:34 drh Exp $
           16  +# $Id: zeroblob.test,v 1.7 2007/09/01 11:04:28 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   ifcapable !incrblob {
    22     22     finish_test
    23     23     return
................................................................................
   171    171   } {1} 
   172    172   do_test zeroblob-6.4 { 
   173    173     catchsql {select length(zeroblob(2147483648))} 
   174    174   } {1 {string or blob too big}} 
   175    175   do_test zeroblob-6.5 { 
   176    176     catchsql {select zeroblob(2147483648)} 
   177    177   } {1 {string or blob too big}} 
          178  +
          179  +# Test bind_zeroblob()
          180  +#
          181  +do_test zeroblob-7.1 {
          182  +  set ::STMT [sqlite3_prepare $::DB "SELECT length(?)" -1 DUMMY]
          183  +  sqlite3_bind_zeroblob $::STMT 1 450
          184  +  sqlite3_step $::STMT
          185  +} {SQLITE_ROW}
          186  +do_test zeroblob-7.2 {
          187  +  sqlite3_column_int $::STMT 0
          188  +} {450}
          189  +do_test zeroblob-7.3 {
          190  +  sqlite3_finalize $::STMT
          191  +} {SQLITE_OK}
   178    192   
   179    193   finish_test