]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Test cases intended to improve coverage of main.c. (CVS 1763)
authordanielk1977 <danielk1977@noemail.net>
Tue, 29 Jun 2004 13:18:23 +0000 (13:18 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 29 Jun 2004 13:18:23 +0000 (13:18 +0000)
FossilOrigin-Name: 15a084e9ea14d093f75c54a321f146c18f4453d7

manifest
manifest.uuid
src/main.c
src/test1.c
src/test3.c
test/capi3.test
test/enc2.test
test/func.test

index 315190a6a52623aae17f828f494505798df9b34d..00fa484bf9a49de9b7f439dc949b79171483bbe5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improved\stest\scoverage\sof\stable.c\sand\sprintf.c.\s(CVS\s1762)
-D 2004-06-29T13:04:33
+C Test\scases\sintended\sto\simprove\scoverage\sof\smain.c.\s(CVS\s1763)
+D 2004-06-29T13:18:24
 F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -38,7 +38,7 @@ F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
 F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
 F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18
 F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
-F src/main.c 9c01890c4e928d31b8c754d67820c645b7b99f4f
+F src/main.c 95a915b2fe9bd879aa47f80472654f11e033b7a6
 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
 F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
 F src/os_common.h 1e745e582138c01d995f190d7544da3e826f6b2f
@@ -62,9 +62,9 @@ F src/sqlite.h.in b70fded2bdfeaddfb06adea3888118b722975136
 F src/sqliteInt.h 4f8d44f04cc51cb421bf3c195247353a5be2e98f
 F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49
 F src/tclsqlite.c 7648310ff0034213f3e58e7272328ed306507e9f
-F src/test1.c 0eca68f6e70069aad7ad0fd91fda886926646786
+F src/test1.c 151df224f7202c2a0d907638f22ed4b0e2378ba9
 F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40
-F src/test3.c bacc42bf41fa04d6faf7dd104b595b8bafb9aec9
+F src/test3.c 7bf0d3fb811a68e009f4c0b228d6daad49176efb
 F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
 F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1
 F src/tokenize.c 900374b6b37f04748bcd48c2d29a41c251542935
@@ -96,7 +96,7 @@ F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
 F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293
 F test/capi2.test fe61f341e953f73c29bacfcbdaf688cd7b0e0d38
-F test/capi3.test c6af4822903c947da586c87811caec95e7a9da13
+F test/capi3.test e878f7fb13a80bf4c88e4dca7d4a45b43c526e5c
 F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef
 F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b
 F test/collate3.test e60b428e07ec945492ba90ff1c895902ee3a8a50
@@ -109,11 +109,11 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
 F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d
 F test/delete.test 4f0c86e2bebdc822d179c80697b1ceabe6bbcd07
 F test/enc.test 2f5463af488d50aef60c6110bec6b21b5efba961
-F test/enc2.test d4427cf5d866addb3ecb46412ad45b7e04bbdfd4
+F test/enc2.test d0d9b8591d6c7779c5c6707ac6cb3a4aad3fa13b
 F test/enc3.test 315f302ed9a6042be76710eb6aa70e4551e9aa73
 F test/expr.test b4e945265c4c697bf5213b72558914ba10a989cc
 F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
-F test/func.test db369afc9e77c4b40863e55497c8f0e449a43e79
+F test/func.test 7653394d854a8e3eb97c7f03c39610f8dc23922b
 F test/hook.test f8605cde4c77b2c6a4a73723bf6c507796a64dda
 F test/in.test b92a2df9162e1cbd33c6449a29a05e6955b1741a
 F test/index.test b6941dd532815f278042b85f79b1a6dc16c4d729
@@ -232,7 +232,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 008e57dcd5e16886ed732fe1e9797a3c00e8c579
-R 094ef9d75f74182971b9bfef31c30613
-U drh
-Z f73ff388c64168a07cb5da4a2e119b6b
+P ba87834d863cb50f3016ccb04f790be5fa4070c6
+R 9de0270fa482c682b722ff7b8c52db20
+U danielk1977
+Z 981a43dc55972048b9a32ccb906e6f2d
index 47ebd13437ce589531fa2b00a334ec5ded966cec..f911e09c967cb4022f5407eefa4d9235dda19f9c 100644 (file)
@@ -1 +1 @@
-ba87834d863cb50f3016ccb04f790be5fa4070c6
\ No newline at end of file
+15a084e9ea14d093f75c54a321f146c18f4453d7
\ No newline at end of file
index 0bb3496d7ce2f32baf6be92607bbcf270e7e6205..c2cb938f7b3870913995e7d15a1b636687287f2c 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.241 2004/06/29 11:26:59 drh Exp $
+** $Id: main.c,v 1.242 2004/06/29 13:18:24 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -894,7 +894,10 @@ const void *sqlite3_errmsg16(sqlite3 *db){
   };
 
   if( db && db->pErr ){
-    if( db->magic==SQLITE_MAGIC_ERROR ){
+    if( db->magic!=SQLITE_MAGIC_OPEN && 
+        db->magic!=SQLITE_MAGIC_BUSY &&
+        db->magic!=SQLITE_MAGIC_CLOSED 
+    ){
       return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
     }
     if( !sqlite3_value_text16(db->pErr) ){
@@ -1277,6 +1280,7 @@ int sqlite3_create_collation(
   }else{
     pColl->xCmp = xCompare;
     pColl->pUser = pCtx;
+    pColl->enc = enc;
   }
   sqlite3Error(db, rc, 0);
   return rc;
index d5dcfa2a20d66f8a61010ee4bf72061398082230..92a1a2056afcbc21ae51118af0d9959afdd9c717 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.89 2004/06/26 09:50:12 danielk1977 Exp $
+** $Id: test1.c,v 1.90 2004/06/29 13:18:24 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -76,6 +76,7 @@ static const char * errorName(int rc){
     case SQLITE_RANGE:      zName = "SQLITE_RANGE";       break;
     case SQLITE_ROW:        zName = "SQLITE_ROW";         break;
     case SQLITE_DONE:       zName = "SQLITE_DONE";        break;
+    case SQLITE_NOTADB:     zName = "SQLITE_NOTADB";        break;
     default:                zName = "SQLITE_Unknown";     break;
   }
   return zName;
@@ -437,17 +438,25 @@ static int test_create_function(
   char **argv            /* Text of each argument */
 ){
   sqlite *db;
+  sqlite3_value *pVal;
   extern void Md5_Register(sqlite*);
+
   if( argc!=2 ){
     Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
        " FILENAME\"", 0);
     return TCL_ERROR;
   }
   if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
-  sqlite3_create_function(db, "x_coalesce", -1, SQLITE_UTF8, 0, 
+  sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0, 
       ifnullFunc, 0, 0);
-  sqlite3_create_function(db, "x_sqlite_exec", 1, SQLITE_UTF8, db,
-      sqlite3ExecFunc, 0, 0);
+
+  /* Use the sqlite3_create_function16() API here. Mainly for fun, but also 
+  ** because it is not tested anywhere else. */
+  pVal = sqlite3ValueNew();
+  sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC);
+  sqlite3_create_function16(db, sqlite3ValueText(pVal, SQLITE_UTF16NATIVE),
+      1, SQLITE_UTF16, db, sqlite3ExecFunc, 0, 0);
+  sqlite3ValueFree(pVal);
   return TCL_OK;
 }
 
@@ -984,6 +993,7 @@ static int test_collate(
 ){
   sqlite3 *db;
   int val;
+  sqlite3_value *pVal;
 
   if( objc!=5 ) goto bad_args;
   pTestCollateInterp = interp;
@@ -996,8 +1006,12 @@ static int test_collate(
   sqlite3_create_collation(db, "test_collate", SQLITE_UTF16LE, 
         (void *)SQLITE_UTF16LE, val?test_collate_func:0);
   if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[4], &val) ) return TCL_ERROR;
-  sqlite3_create_collation(db, "test_collate", SQLITE_UTF16BE, 
-        (void *)SQLITE_UTF16BE, val?test_collate_func:0);
+
+  pVal = sqlite3ValueNew();
+  sqlite3ValueSetStr(pVal, -1, "test_collate", SQLITE_UTF8, SQLITE_STATIC);
+  sqlite3_create_collation16(db, sqlite3ValueText(pVal, SQLITE_UTF16NATIVE), 
+        SQLITE_UTF16BE, (void *)SQLITE_UTF16BE, val?test_collate_func:0);
+  sqlite3ValueFree(pVal);
   
   return TCL_OK;
 
@@ -1007,6 +1021,38 @@ bad_args:
   return TCL_ERROR;
 }
 
+static void test_collate_needed_cb(
+  void *pCtx, 
+  sqlite3 *db,
+  int eTextRep,
+  const void *notUsed
+){
+  int enc = db->enc;
+  sqlite3_create_collation(
+      db, "test_collate", db->enc, (void *)enc, test_collate_func);
+}
+
+/*
+** Usage: add_test_collate_needed DB
+*/
+static int test_collate_needed(
+  void * clientData,
+  Tcl_Interp *interp,
+  int objc,
+  Tcl_Obj *CONST objv[]
+){
+  sqlite3 *db;
+
+  if( objc!=2 ) goto bad_args;
+  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+  sqlite3_collation_needed16(db, 0, test_collate_needed_cb);
+  return TCL_OK;
+
+bad_args:
+  Tcl_WrongNumArgs(interp, 1, objv, "DB");
+  return TCL_ERROR;
+}
+
 /*
 ** Usage: add_test_function <db ptr> <utf8> <utf16le> <utf16be>
 **
@@ -1136,6 +1182,34 @@ bad_args:
   return TCL_ERROR;
 }
 
+/*
+** Usage:         test_errstr <err code>
+**
+** Test that the english language string equivalents for sqlite error codes
+** are sane. The parameter is an integer representing an sqlite error code.
+** The result is a list of two elements, the string representation of the
+** error code and the english language explanation.
+*/
+static int test_errstr(
+  void * clientData,
+  Tcl_Interp *interp,
+  int objc,
+  Tcl_Obj *CONST objv[]
+){
+  char *zCode;
+  int i;
+  if( objc!=1 ){
+    Tcl_WrongNumArgs(interp, 1, objv, "<error code>");
+  }
+
+  zCode = Tcl_GetString(objv[1]);
+  for(i=0; i<200; i++){
+    if( 0==strcmp(errorName(i), zCode) ) break;
+  }
+  Tcl_SetResult(interp, (char *)sqlite3ErrStr(i), 0);
+  return TCL_OK;
+}
+
 static int sqlite3_crashparams(
   void * clientData,
   Tcl_Interp *interp,
@@ -2219,10 +2293,14 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
      { "sqlite3OsOpenReadWrite",test_sqlite3OsOpenReadWrite, 0 },
      { "sqlite3OsClose",        test_sqlite3OsClose, 0 },
      { "sqlite3OsLock",         test_sqlite3OsLock, 0 },
-     { "sqlite3OsUnlock",       test_sqlite3OsUnlock, 0 },
-     { "add_test_collate",      test_collate, 0         },
-     { "add_test_function",     test_function, 0         },
-     { "sqlite3_crashparams",     sqlite3_crashparams, 0         },
+   
+     /* Custom test interfaces */
+     { "sqlite3OsUnlock",         test_sqlite3OsUnlock, 0    },
+     { "add_test_collate",        test_collate, 0            },
+     { "add_test_collate_needed", test_collate_needed, 0     },
+     { "add_test_function",       test_function, 0           },
+     { "sqlite3_crashparams",     sqlite3_crashparams, 0     },
+     { "sqlite3_test_errstr",     test_errstr, 0             },
 
   };
   int i;
index f841ff35702255557738c082d7587eb84a15ee39..0e2020ba97d220d32bd1226f3e7a151fee8872df 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test3.c,v 1.45 2004/06/26 08:38:25 danielk1977 Exp $
+** $Id: test3.c,v 1.46 2004/06/29 13:18:24 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "pager.h"
@@ -750,35 +750,35 @@ static int btree_delete(
 ** exists with the same key the old entry is overwritten.
 */
 static int btree_insert(
-  void *NotUsed,
-  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
-  int argc,              /* Number of arguments */
-  const char **argv      /* Text of each argument */
+  void * clientData,
+  Tcl_Interp *interp,
+  int objc,
+  Tcl_Obj *CONST objv[]
 ){
   BtCursor *pCur;
   int rc;
 
-  if( argc!=4 ){
-    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
-       " ID KEY DATA\"", 0);
+  if( objc!=4 ){
+    Tcl_WrongNumArgs(interp, 1, objv, "ID KEY DATA");
     return TCL_ERROR;
   }
-  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
+
+  if( Tcl_GetIntFromObj(interp, objv[1], (int*)&pCur) ) return TCL_ERROR;
   if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
-/*
-    int iKey;
-    if( Tcl_GetInt(interp, argv[2], &iKey) ) return TCL_ERROR;
-*/
     i64 iKey;
-    Tcl_Obj *obj = Tcl_NewStringObj(argv[2], -1);
-    Tcl_IncrRefCount(obj);
-    if( Tcl_GetWideIntFromObj(interp, obj, &iKey) ) return TCL_ERROR;
-    Tcl_DecrRefCount(obj);
-
-    rc = sqlite3BtreeInsert(pCur, 0, iKey, argv[3], strlen(argv[3]));
+    int len;
+    unsigned char *pBuf;
+    if( Tcl_GetWideIntFromObj(interp, objv[2], &iKey) ) return TCL_ERROR;
+    pBuf = Tcl_GetByteArrayFromObj(objv[3], &len);
+    rc = sqlite3BtreeInsert(pCur, 0, iKey, pBuf, len);
   }else{
-    rc = sqlite3BtreeInsert(pCur, argv[2], strlen(argv[2]),
-                         argv[3], strlen(argv[3]));
+    int keylen;
+    int dlen;
+    unsigned char *pKBuf;
+    unsigned char *pDBuf;
+    pKBuf = Tcl_GetByteArrayFromObj(objv[2], &keylen);
+    pDBuf = Tcl_GetByteArrayFromObj(objv[3], &dlen);
+    rc = sqlite3BtreeInsert(pCur, pKBuf, keylen, pDBuf, dlen);
   }
   if( rc ){
     Tcl_AppendResult(interp, errorName(rc), 0);
@@ -1319,7 +1319,6 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
      { "btree_close_cursor",       (Tcl_CmdProc*)btree_close_cursor       },
      { "btree_move_to",            (Tcl_CmdProc*)btree_move_to            },
      { "btree_delete",             (Tcl_CmdProc*)btree_delete             },
-     { "btree_insert",             (Tcl_CmdProc*)btree_insert             },
      { "btree_next",               (Tcl_CmdProc*)btree_next               },
      { "btree_prev",               (Tcl_CmdProc*)btree_prev               },
      { "btree_eof",                (Tcl_CmdProc*)btree_eof                },
@@ -1349,5 +1348,11 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
      TCL_LINK_INT);
   Tcl_LinkVar(interp, "btree_trace", (char*)&sqlite3_btree_trace,
      TCL_LINK_INT);
+
+  /* The btree_insert command is implemented using the tcl 'object'
+  ** interface, not the string interface like the other commands in this
+  ** file. This is so binary data can be inserted into btree tables.
+  */
+  Tcl_CreateObjCommand(interp, "btree_insert", btree_insert, 0, 0);
   return TCL_OK;
 }
index ecccbc0f487407ab79e50fa5258e7aef27a479d2..e7457269d7910c485188ba471a0721d291dde07b 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script testing the callback-free C/C++ API.
 #
-# $Id: capi3.test,v 1.15 2004/06/29 08:59:35 danielk1977 Exp $
+# $Id: capi3.test,v 1.16 2004/06/29 13:18:24 danielk1977 Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -135,6 +135,12 @@ do_test capi3-3.5 {
 do_test capi3-3.6 {
   sqlite3_close $db2
 } {SQLITE_MISUSE}
+do_test capi3-3.6 {
+  sqlite3_errmsg $db2
+} {library routine called out of sequence}
+do_test capi3-3.6 {
+  utf8 [sqlite3_errmsg16 $db2]
+} {library routine called out of sequence}
 
 # rename sqlite3_open ""
 # rename sqlite3_open_old sqlite3_open
@@ -474,4 +480,119 @@ do_test capi3-7.2 {
   }
 } {1 {unsupported file format}}
 
+# Now test that the library correctly handles bogus entries in the
+# sqlite_master table (schema corruption).
+do_test capi3-8.1 {
+  db close
+  file delete -force test.db
+  sqlite3 db test.db
+  execsql {
+    CREATE TABLE t1(a);
+  }
+  db close
+} {}
+do_test capi3-8.2 {
+  set ::bt [btree_open test.db 10 0]
+  btree_begin_transaction $::bt
+  set ::bc [btree_cursor $::bt 1 1]
+
+  # Build a 5-field row record consisting of 5 null records. This is
+  # officially black magic.
+  set data [binary format c6 {6 0 0 0 0 0}]
+  btree_insert $::bc 5 $data
+
+  btree_close_cursor $::bc
+  btree_commit $::bt
+  btree_close $::bt
+} {}
+do_test capi3-8.3 {
+  sqlite3 db test.db
+  catchsql {
+    SELECT * FROM sqlite_master;
+  }
+} {1 {malformed database schema}}
+do_test capi3-8.4 {
+  set ::bt [btree_open test.db 10 0]
+  btree_begin_transaction $::bt
+  set ::bc [btree_cursor $::bt 1 1]
+
+  # Build a 5-field row record. The first field is a string 'table', and
+  # subsequent fields are all NULL. Replace the other broken record with
+  # this one and try to read the schema again.
+  set data [binary format c6a5 {6 23 0 0 0 0} table]
+  btree_insert $::bc 5 $data
+
+  btree_close_cursor $::bc
+  btree_commit $::bt
+  btree_close $::bt
+} {}
+do_test capi3-8.5 {
+  db close 
+  sqlite3 db test.db
+  catchsql {
+    SELECT * FROM sqlite_master;
+  }
+} {1 {malformed database schema}}
+db close
+file delete -force test.db
+
+# Test the english language string equivalents for sqlite error codes
+set code2english [list \
+SQLITE_OK         {not an error} \
+SQLITE_ERROR      {SQL logic error or missing database} \
+SQLITE_INTERNAL   {internal SQLite implementation flaw} \
+SQLITE_PERM       {access permission denied} \
+SQLITE_ABORT      {callback requested query abort} \
+SQLITE_BUSY       {database is locked} \
+SQLITE_LOCKED     {database table is locked} \
+SQLITE_NOMEM      {out of memory} \
+SQLITE_READONLY   {attempt to write a readonly database} \
+SQLITE_INTERRUPT  {interrupted} \
+SQLITE_IOERR      {disk I/O error} \
+SQLITE_CORRUPT    {database disk image is malformed} \
+SQLITE_NOTFOUND   {table or record not found} \
+SQLITE_FULL       {database is full} \
+SQLITE_CANTOPEN   {unable to open database file} \
+SQLITE_PROTOCOL   {database locking protocol failure} \
+SQLITE_EMPTY      {table contains no data} \
+SQLITE_SCHEMA     {database schema has changed} \
+SQLITE_TOOBIG     {too much data for one table row} \
+SQLITE_CONSTRAINT {constraint failed} \
+SQLITE_MISMATCH   {datatype mismatch} \
+SQLITE_MISUSE     {library routine called out of sequence} \
+SQLITE_NOLFS      {kernel lacks large file support} \
+SQLITE_AUTH       {authorization denied} \
+SQLITE_FORMAT     {auxiliary database format error} \
+SQLITE_RANGE      {bind index out of range} \
+SQLITE_NOTADB     {file is encrypted or is not a database} \
+unknownerror      {unknown error} \
+]
+
+set test_number 1
+foreach {code english} $code2english {
+  do_test capi3-9.$test_number "sqlite3_test_errstr $code" $english
+  incr test_number
+}
+
+# Test the error message when a "real" out of memory occurs.
+set sqlite_malloc_fail 1
+do_test capi3-10-1 {
+  set ::DB [sqlite3 db test.db]
+  sqlite_malloc_fail 1
+  catchsql {
+    select * from sqlite_master;
+  }
+} {1 {out of memory}}
+do_test capi3-10-2 {
+  sqlite3_errmsg $::DB
+} {out of memory}
+do_test capi3-10-3 {
+  utf8 [sqlite3_errmsg16 $::DB]
+} {out of memory}
+db close
+sqlite_malloc_fail 0
+
 finish_test
+
+
+
index 265ca38ac096763b83f66850013a5a055ff4f443..4af75cf46b15379c13e0b17467425dda8b34f5b2 100644 (file)
@@ -13,7 +13,7 @@
 # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
 # UTF-16be).
 #
-# $Id: enc2.test,v 1.15 2004/06/28 11:52:46 drh Exp $
+# $Id: enc2.test,v 1.16 2004/06/29 13:18:24 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -260,6 +260,19 @@ do_test enc2-5.11 {
   lappend res $::test_collate_enc
 } {one two three four five UTF-8}
 
+# Also test that a UTF-16 collation factory works.
+do_test enc2-6-12 {
+  add_test_collate $DB 0 0 0
+  catchsql {
+    SELECT * FROM t5 ORDER BY 1 COLLATE test_collate
+  }
+} {1 {no such collation sequence: test_collate}}
+do_test enc2-5.13 {
+  add_test_collate_needed $DB 
+  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+  lappend res $::test_collate_enc
+} {one two three four five UTF-16BE}
+
 db close
 file delete -force test.db
 
@@ -368,6 +381,7 @@ do_test enc2-6.10 {
   }
 } {{UTF-16BE sqlite}}
 
+
 db close
 file delete -force test.db
 
index b80cc59a7927531c8aa503423a8b27c72fd776b6..5dfee54054b125dac2b223ccd52b9e89dcaa8635 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing built-in functions.
 #
-# $Id: func.test,v 1.26 2004/06/24 00:20:05 danielk1977 Exp $
+# $Id: func.test,v 1.27 2004/06/29 13:18:24 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -440,4 +440,16 @@ do_test func-13.7 {
   lappend res [sqlite3_finalize $STMT]
 } {{0 0} {1 0} SQLITE_OK}
 
+# Make sure that a function with a very long name is rejected
+do_test func-14.1 {
+  catch {
+    db function [string repeat X 254] {return "hello"}
+  } 
+} {0}
+do_test func-14.2 {
+  catch {
+    db function [string repeat X 256] {return "hello"}
+  }
+} {1}
+
 finish_test