]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improve test coverage of util.c (CVS 1773)
authordrh <drh@noemail.net>
Wed, 30 Jun 2004 04:02:11 +0000 (04:02 +0000)
committerdrh <drh@noemail.net>
Wed, 30 Jun 2004 04:02:11 +0000 (04:02 +0000)
FossilOrigin-Name: 68ac32213766c5e83de54373b90030a458538017

manifest
manifest.uuid
src/sqliteInt.h
src/test1.c
src/test3.c
src/util.c
test/intpkey.test

index 9f7f35c94113af7deb4afdcdb614b56544506720..4bbd27432cb7d43fabfc9481c758863a51f69ed9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improved\stest\scoverage\sof\sfunc.c\sand\shash.c.\s(CVS\s1772)
-D 2004-06-30T03:08:25
+C Improve\stest\scoverage\sof\sutil.c\s(CVS\s1773)
+D 2004-06-30T04:02:12
 F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -59,19 +59,19 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
 F src/select.c f02a65af34231031896e8442161cb5251e191e75
 F src/shell.c 24b641700c9d90f361fcfa4f432c5b4aff704e6d
 F src/sqlite.h.in b70fded2bdfeaddfb06adea3888118b722975136
-F src/sqliteInt.h 4f8d44f04cc51cb421bf3c195247353a5be2e98f
+F src/sqliteInt.h 9dcfcc67fc995b9079074d6b9619a1d4335583d0
 F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49
 F src/tclsqlite.c f72288553ca3cdaf686baab4b1797dd98140c501
-F src/test1.c 151df224f7202c2a0d907638f22ed4b0e2378ba9
+F src/test1.c ad2ae36959d6ac480f54b7e07d4baad8ee3b2e88
 F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40
-F src/test3.c 7163c577f1dd73ad4a1d3730ea6541af3274c964
+F src/test3.c d0c56667e89f79ad0f060fdf010d1c34a4bc2988
 F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
 F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1
 F src/tokenize.c 900374b6b37f04748bcd48c2d29a41c251542935
 F src/trigger.c 6aaf6d79cc2157c70a06031dd1531707d644cfb4
 F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a
 F src/utf.c f03535db72bfa09e24202ccdd245f21d2fc65f0a
-F src/util.c 94796d2b31600beee7de426c3946022ef3508d46
+F src/util.c b267d0fe10cffa3301fe9fab6592a6808a38bce6
 F src/vacuum.c 353c7f69dbeb6738434d81798465cc0698844640
 F src/vdbe.c 32039b08701f1c19fcd9b684366cefaa8fabaa72
 F src/vdbe.h 75b241c02431b9c0f16eaa9cdbb34146c6287f52
@@ -120,7 +120,7 @@ F test/index.test b6941dd532815f278042b85f79b1a6dc16c4d729
 F test/insert.test ebbab63db4ad69395a058514bccb3cdb0a029d48
 F test/insert2.test ea5d4f8dcbc68d8ad85eaa5f03d9812757610f90
 F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91
-F test/intpkey.test 8b9590b2db07696e73381da4df6c40ef10436d73
+F test/intpkey.test c8efd06db62b8b27216558ef439cc867d113cfec
 F test/ioerr.test 7d087bfd1a1a53442940e000df936e0df0c5b886
 F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd
 F test/join2.test c97e4c5aa65dea462145529e58212a709b4722b8
@@ -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 e5e39764038311cbb3555b5bd41de2563a89113e
-R 6128bf7e6957bc36be00e553f4313e2a
+P 0c999f28137bd82ba24dd263bab30d22329eed73
+R aac9bef2959b49a3b21126dff36eb51a
 U drh
-Z 6dcdf7a54d5c2b70e5fcf38318bf29ad
+Z d9d34e7eed57c4c6a384e0a609787172
index d7052eb6421ec98a7c6980f6a1f96706214e2fec..c10c079327776476bea5cdf69b591b2fb4221341 100644 (file)
@@ -1 +1 @@
-0c999f28137bd82ba24dd263bab30d22329eed73
\ No newline at end of file
+68ac32213766c5e83de54373b90030a458538017
\ No newline at end of file
index c70871024ca7bcc3957c7669002aab250f0eac37..3ccf38b3503d26ae1310477de835390f7bb67156 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.303 2004/06/29 08:59:35 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.304 2004/06/30 04:02:12 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -1338,7 +1338,6 @@ int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
 double sqlite3AtoF(const char *z, const char **);
 char *sqlite3_snprintf(int,char*,const char*,...);
 int sqlite3GetInt32(const char *, int*);
-int sqlite3GetInt64(const char *, i64*);
 int sqlite3FitsIn64Bits(const char *);
 int sqlite3utf16ByteLen(const void *pData, int nChar);
 int sqlite3utf8CharLen(const char *pData, int nByte);
index 92a1a2056afcbc21ae51118af0d9959afdd9c717..4310f42d534064167273dfd844f01cff71bbbd38 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.90 2004/06/29 13:18:24 danielk1977 Exp $
+** $Id: test1.c,v 1.91 2004/06/30 04:02:12 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -540,6 +540,18 @@ static int sqlite3_mprintf_int(
   return TCL_OK;
 }
 
+/*
+** If zNum represents an integer that will fit in 64-bits, then set
+** *pValue to that integer and return true.  Otherwise return false.
+*/
+static int sqlite3GetInt64(const char *zNum, i64 *pValue){
+  if( sqlite3FitsIn64Bits(zNum) ){
+    sqlite3atoi64(zNum, pValue);
+    return 1;
+  }
+  return 0;
+}
+
 /*
 ** Usage:  sqlite3_mprintf_int64 FORMAT INTEGER INTEGER INTEGER
 **
index 4a102e0cc4f897139c37cdcbe39f4377b9470385..70a4617f235b83e6ad08ab6bf183889e51071280 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.47 2004/06/30 02:35:51 danielk1977 Exp $
+** $Id: test3.c,v 1.48 2004/06/30 04:02:12 drh Exp $
 */
 #include "sqliteInt.h"
 #include "pager.h"
@@ -1279,6 +1279,23 @@ static int btree_varint_test(
       Tcl_AppendResult(interp, zErr, 0);
       return TCL_ERROR;
     }
+    if( (in & 0xffffffff)==in ){
+      u32 out32;
+      n2 = sqlite3GetVarint32(zBuf, &out32);
+      out = out32;
+      if( n1!=n2 ){
+        sprintf(zErr, "PutVarint returned %d and GetVarint32 returned %d", 
+                  n1, n2);
+        Tcl_AppendResult(interp, zErr, 0);
+        return TCL_ERROR;
+      }
+      if( in!=out ){
+        sprintf(zErr, "Wrote 0x%016llx and got back 0x%016llx from GetVarint32",
+            in, out);
+        Tcl_AppendResult(interp, zErr, 0);
+        return TCL_ERROR;
+      }
+    }
 
     /* In order to get realistic timings, run getVarint 19 more times.
     ** This is because getVarint is called about 20 times more often
index ea0946dcb0bb08b20c3fa87709542b62d80a107d..f4c2d136e8b5c540d40762ba4e329c2527233d1d 100644 (file)
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.108 2004/06/30 02:35:51 danielk1977 Exp $
+** $Id: util.c,v 1.109 2004/06/30 04:02:12 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -762,18 +762,6 @@ int sqlite3FitsIn64Bits(const char *zNum){
   return i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0);
 }
 
-/*
-** If zNum represents an integer that will fit in 64-bits, then set
-** *pValue to that integer and return true.  Otherwise return false.
-*/
-int sqlite3GetInt64(const char *zNum, i64 *pValue){
-  if( sqlite3FitsIn64Bits(zNum) ){
-    sqlite3atoi64(zNum, pValue);
-    return 1;
-  }
-  return 0;
-}
-
 #if 1  /* We are now always UTF-8 */
 /*
 ** X is a pointer to the first byte of a UTF-8 character.  Increment
@@ -1112,17 +1100,8 @@ int sqlite3GetVarint32(const unsigned char *p, u32 *v){
     *v = (x<<7) | c;
     return 2;
   }
-  x = (x<<7) | (c&0x7f);
-  if( ((c = p[2]) & 0x80)==0 ){
-    *v = (x<<7) | c;
-    return 3;
-  }
-  x = (x<<7) | (c&0x7f);
-  if( ((c = p[3]) & 0x80)==0 ){
-    *v = (x<<7) | c;
-    return 4;
-  }
-  n = 4;
+  x = (x<<7) | (c & 0x7f);
+  n = 2;
   do{
     x = (x<<7) | ((c = p[n++])&0x7f);
   }while( (c & 0x80)!=0 && n<9 );
@@ -1143,6 +1122,27 @@ int sqlite3VarintLen(u64 v){
   return i;
 }
 
+/*
+** Translate a single byte of Hex into an integer.
+*/
+static int hexToInt(int h){
+  if( h>='0' && h<='9' ){
+    return h - '0';
+  }else if( h>='a' && h<='f' ){
+    return h - 'a' + 10;
+  }else if( h>='A' && h<='F' ){
+    return h - 'A' + 10;
+  }else{
+    return 0;
+  }
+}
+
+/*
+** Convert a BLOB literal of the form "x'hhhhhh'" into its binary
+** value.  Return a pointer to its binary value.  Space to hold the
+** binary value has been obtained from malloc and must be freed by
+** the calling routine.
+*/
 void *sqlite3HexToBlob(const char *z){
   char *zBlob;
   int i;
@@ -1150,27 +1150,8 @@ void *sqlite3HexToBlob(const char *z){
   if( n%2 ) return 0;
 
   zBlob = (char *)sqliteMalloc(n/2);
-
-  for(i=0; i<n; i++){
-    u8 c;
-
-    if     ( z[i]>47 && z[i]<58 ) c = (z[i]-48)<<4;
-    else if( z[i]>64 && z[i]<71 ) c = (z[i]-55)<<4;
-    else if( z[i]>96 && z[i]<103 ) c = (z[i]-87)<<4;
-    else {
-      sqliteFree(zBlob);
-      return 0;
-    }
-    i++;
-    if     ( z[i]>47 && z[i]<58 ) c += (z[i]-48);
-    else if( z[i]>64 && z[i]<71 ) c += (z[i]-55);
-    else if( z[i]>96 && z[i]<103 ) c += (z[i]-87);
-    else {
-      sqliteFree(zBlob);
-      return 0;
-    }
-
-    zBlob[i/2] = c;
+  for(i=0; i<n; i+=2){
+    zBlob[i/2] = (hexToInt(z[i])<<4) | hexToInt(z[i+1]);
   }
   return zBlob;
 }
index 05ca8b53ab989633f72a5f8a032413e6e41ea570..74ce65b9739a46a5c11534b98fd85a74db46f419 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for the special processing associated
 # with INTEGER PRIMARY KEY columns.
 #
-# $Id: intpkey.test,v 1.17 2004/06/30 02:29:03 drh Exp $
+# $Id: intpkey.test,v 1.18 2004/06/30 04:02:12 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -511,6 +511,11 @@ do_test intpkey-13.4 {
     INSERT INTO t1 VALUES(x'123456',3,4);
   }
 } {1 {datatype mismatch}}
+do_test intpkey-13.5 {
+  catchsql {
+    INSERT INTO t1 VALUES('+1234567890',3,4);
+  }
+} {0 {}}
 
 
 finish_test