]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Test coverage for date.c. (CVS 4722)
authordrh <drh@noemail.net>
Thu, 17 Jan 2008 22:27:53 +0000 (22:27 +0000)
committerdrh <drh@noemail.net>
Thu, 17 Jan 2008 22:27:53 +0000 (22:27 +0000)
FossilOrigin-Name: a676f949b68c968d7e71aceb060c1639b42ba680

manifest
manifest.uuid
src/date.c
test/date.test

index 0398dab6bfde2de61902d00378f235f2b7654fa4..21254e49487d306cb72e50f5d0cf5f230144dd3d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improved\stest\scoverage\sin\sdate.c.\s\sReport\san\serror\sif\sa\smalloc\nfails\swithin\sstrftime().\s(CVS\s4721)
-D 2008-01-17T20:26:47
+C Test\scoverage\sfor\sdate.c.\s(CVS\s4722)
+D 2008-01-17T22:27:54
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -89,7 +89,7 @@ F src/btreeInt.h 1c5a9da165718ef7de81e35ce9ab5d9ba9283f76
 F src/build.c 27a3be10a7186515915ac73c40667dc55beacbac
 F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
 F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
-F src/date.c a5bf94263a39dd564de8262a60bc4f6dd4b3d26c
+F src/date.c 8ce763c68143b1e8fb6f79dcfc8b801853c97017
 F src/delete.c 739ccbab8fa7478762bded5c9cc67f16a4d09dbe
 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
 F src/expr.c f13ad688f64d93efe6c4f86c46e9d172d9166217
@@ -245,7 +245,7 @@ F test/crash3.test 0b09687ae1a3ccbcefdfaeb4b963e26e36255d76
 F test/crash4.test 02ff4f15c149ca1e88a5c299b4896c84d9450c3b
 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
 F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272
-F test/date.test b2bd57ff2ab6185b9322306f7b68fa647d63c857
+F test/date.test 51734f3798f338e3f75107aff5a057ae0ff7006c
 F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
 F test/delete.test 57533e88e886608bf5ae0f394e14c2eb1b1f7754
 F test/delete2.test c06be3806ba804bc8c6f134476816080280b40e3
@@ -606,7 +606,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 1c37d7b69b672987a6974f4193f933666f4f0c3a
-R d9967355fe21baab9dd2f21a45527aae
+P 495fb41626dfbfbeeb748675b9476a4f7cec6c7a
+R 44b7cf7c7631ced0327987df0e419a17
 U drh
-Z 81650e99db9d29986d19577b6d69f753
+Z 08c8b2a3ecf57a5c9fe6eb42188de03e
index 892b99964ddff70e2d25cadc5ab2ac701267e913..8bbdfd568f47b71d861a5fd5acc0c592a147a226 100644 (file)
@@ -1 +1 @@
-495fb41626dfbfbeeb748675b9476a4f7cec6c7a
\ No newline at end of file
+a676f949b68c968d7e71aceb060c1639b42ba680
\ No newline at end of file
index 5995da73f1dc2ffd3e115f90cd266618803070e4..07ba2f254f117006398a53f623b11fe77a249a87 100644 (file)
@@ -16,7 +16,7 @@
 ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: date.c,v 1.74 2008/01/17 20:26:47 drh Exp $
+** $Id: date.c,v 1.75 2008/01/17 22:27:54 drh Exp $
 **
 ** SQLite processes all times and dates as Julian Day numbers.  The
 ** dates and times are stored as the number of days since noon
@@ -653,6 +653,9 @@ static int parseModifier(const char *zMod, DateTime *p){
 ** argv[1] and following are modifiers.  Parse them all and write
 ** the resulting time into the DateTime structure p.  Return 0
 ** on success and 1 if there are any errors.
+**
+** If there are zero parameters (if even argv[0] is undefined)
+** then assume a default value of "now" for argv[0].
 */
 static int isDate(
   sqlite3_context *context, 
@@ -662,8 +665,12 @@ static int isDate(
 ){
   int i;
   const unsigned char *z;
-  if( argc==0 ) return 1;
-  z = sqlite3_value_text(argv[0]);
+  static const unsigned char zDflt[] = "now";
+  if( argc==0 ){
+    z = zDflt;
+  }else{
+    z = sqlite3_value_text(argv[0]);
+  }
   if( !z || parseDateOrTime(context, (char*)z, p) ){
     return 1;
   }
@@ -885,7 +892,7 @@ static void strftimeFunc(
         case 'S':  sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
         case 'w':  z[j++] = (((int)(x.rJD+1.5)) % 7) + '0'; break;
         case 'Y':  sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=strlen(&z[j]);break;
-        case '%':  z[j++] = '%'; break;
+        default:   z[j++] = '%'; break;
       }
     }
   }
@@ -904,12 +911,7 @@ static void ctimeFunc(
   int argc,
   sqlite3_value **argv
 ){
-  sqlite3_value *pVal = sqlite3ValueNew(0);
-  if( pVal ){
-    sqlite3ValueSetStr(pVal, -1, "now", SQLITE_UTF8, SQLITE_STATIC);
-    timeFunc(context, 1, &pVal);
-    sqlite3ValueFree(pVal);
-  }
+  timeFunc(context, 0, 0);
 }
 
 /*
@@ -922,12 +924,7 @@ static void cdateFunc(
   int argc,
   sqlite3_value **argv
 ){
-  sqlite3_value *pVal = sqlite3ValueNew(0);
-  if( pVal ){
-    sqlite3ValueSetStr(pVal, -1, "now", SQLITE_UTF8, SQLITE_STATIC);
-    dateFunc(context, 1, &pVal);
-    sqlite3ValueFree(pVal);
-  }
+  dateFunc(context, 0, 0);
 }
 
 /*
@@ -940,12 +937,7 @@ static void ctimestampFunc(
   int argc,
   sqlite3_value **argv
 ){
-  sqlite3_value *pVal = sqlite3ValueNew(0);
-  if( pVal ){
-    sqlite3ValueSetStr(pVal, -1, "now", SQLITE_UTF8, SQLITE_STATIC);
-    datetimeFunc(context, 1, &pVal);
-    sqlite3ValueFree(pVal);
-  }
+  datetimeFunc(context, 0, 0);
 }
 #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
 
index b26db27b440e254f54d3c5495d370cb0b47809a2..bead4564d76ad464395401325ba3ed552d6720ce 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing date and time functions.
 #
-# $Id: date.test,v 1.23 2007/08/31 17:42:48 danielk1977 Exp $
+# $Id: date.test,v 1.24 2008/01/17 22:27:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -119,11 +119,14 @@ datetest 2.36 {datetime('2003-10-22 12:24','+1 abcdef')} NULL
 datetest 2.37 {datetime('2003-10-22 12:24','+1 abcdefg')} NULL
 datetest 2.38 {datetime('2003-10-22 12:24','+1 abcdefgh')} NULL
 datetest 2.39 {datetime('2003-10-22 12:24','+1 abcdefghi')} NULL
-datetest 2.40 {datetime()} NULL
+set sqlite_current_time 1199243045
+datetest 2.40 {datetime()} {2008-01-02 03:04:05}
+set sqlite_current_time 0
 
 
 datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31
-datetest 3.2 {strftime('%f','2003-10-31 12:34:56.432')} 56.432
+datetest 3.2.1 {strftime('%f','2003-10-31 12:34:56.432')} 56.432
+datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999
 datetest 3.3 {strftime('%H','2003-10-31 12:34:56.432')} 12
 datetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304
 datetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.02426426