Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/sqlite/src/test/date.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/ctime.test ('k') | third_party/sqlite/src/test/dbstatus.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2003 October 31 1 # 2003 October 31
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing date and time functions. 12 # focus of this file is testing date and time functions.
13 # 13 #
14 # $Id: date.test,v 1.34 2009/04/16 12:58:03 drh Exp $ 14 # $Id: date.test,v 1.34 2009/04/16 12:58:03 drh Exp $
15 15
16 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 17 source $testdir/tester.tcl
18 18
19 # Do not use a codec for tests in this file, as the database file is
20 # manipulated directly using tcl scripts (using the [hexio_write] command).
21 #
22 do_not_use_codec
23
19 # Skip this whole file if date and time functions are omitted 24 # Skip this whole file if date and time functions are omitted
20 # at compile-time 25 # at compile-time
21 # 26 #
22 ifcapable {!datetime} { 27 ifcapable {!datetime} {
23 finish_test 28 finish_test
24 return 29 return
25 } 30 }
26 31
27 proc datetest {tnum expr result} { 32 proc datetest {tnum expr result} {
28 do_test date-$tnum [subst { 33 do_test date-$tnum [subst {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 datetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00} 77 datetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00}
73 datetest 2.2b datetime('946684800','unixepoch') {2000-01-01 00:00:00} 78 datetest 2.2b datetime('946684800','unixepoch') {2000-01-01 00:00:00}
74 for {set i 0} {$i<1000} {incr i} { 79 for {set i 0} {$i<1000} {incr i} {
75 set sql [format {strftime('%%H:%%M:%%f',1237962480.%03d,'unixepoch')} $i] 80 set sql [format {strftime('%%H:%%M:%%f',1237962480.%03d,'unixepoch')} $i]
76 set res [format {06:28:00.%03d} $i] 81 set res [format {06:28:00.%03d} $i]
77 datetest 2.2c-$i $sql $res 82 datetest 2.2c-$i $sql $res
78 } 83 }
79 datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26 84 datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26
80 datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27 85 datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27
81 datetest 2.4a {date('2003-10-22','weekday 1')} 2003-10-27 86 datetest 2.4a {date('2003-10-22','weekday 1')} 2003-10-27
82 datetest 2.4b {date('2003-10-22','weekday 1x')} 2003-10-27 87 datetest 2.4b {date('2003-10-22','weekday 1x')} NULL
83 datetest 2.4c {date('2003-10-22','weekday -1')} NULL 88 datetest 2.4c {date('2003-10-22','weekday -1')} NULL
84 datetest 2.4d {date('2003-10-22','weakday 1x')} NULL 89 datetest 2.4d {date('2003-10-22','weakday 1x')} NULL
85 datetest 2.4e {date('2003-10-22','weekday ')} NULL 90 datetest 2.4e {date('2003-10-22','weekday ')} NULL
86 datetest 2.5 {date('2003-10-22','weekday 2')} 2003-10-28 91 datetest 2.5 {date('2003-10-22','weekday 2')} 2003-10-28
87 datetest 2.6 {date('2003-10-22','weekday 3')} 2003-10-22 92 datetest 2.6 {date('2003-10-22','weekday 3')} 2003-10-22
88 datetest 2.7 {date('2003-10-22','weekday 4')} 2003-10-23 93 datetest 2.7 {date('2003-10-22','weekday 4')} 2003-10-23
89 datetest 2.8 {date('2003-10-22','weekday 5')} 2003-10-24 94 datetest 2.8 {date('2003-10-22','weekday 5')} 2003-10-24
90 datetest 2.9 {date('2003-10-22','weekday 6')} 2003-10-25 95 datetest 2.9 {date('2003-10-22','weekday 6')} 2003-10-25
91 datetest 2.10 {date('2003-10-22','weekday 7')} NULL 96 datetest 2.10 {date('2003-10-22','weekday 7')} NULL
92 datetest 2.11 {date('2003-10-22','weekday 5.5')} NULL 97 datetest 2.11 {date('2003-10-22','weekday 5.5')} NULL
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 datetest 13.32 {date('2002-01-01','+1.5 years')} {2003-07-02} 493 datetest 13.32 {date('2002-01-01','+1.5 years')} {2003-07-02}
489 datetest 13.33 {date('2002-01-01','-1.5 years')} {2000-07-02} 494 datetest 13.33 {date('2002-01-01','-1.5 years')} {2000-07-02}
490 datetest 13.34 {date('2001-01-01','-1.5 years')} {1999-07-02} 495 datetest 13.34 {date('2001-01-01','-1.5 years')} {1999-07-02}
491 496
492 # Test for issues reported by BareFeet (list.sql at tandb.com.au) 497 # Test for issues reported by BareFeet (list.sql at tandb.com.au)
493 # on mailing list on 2008-06-12. 498 # on mailing list on 2008-06-12.
494 # 499 #
495 # Put a floating point number in the database so that we can manipulate 500 # Put a floating point number in the database so that we can manipulate
496 # raw bits using the hexio interface. 501 # raw bits using the hexio interface.
497 # 502 #
498 do_test date-14.1 { 503 if {0==[sqlite3 -has-codec]} {
499 execsql { 504 do_test date-14.1 {
500 PRAGMA auto_vacuum=OFF; 505 execsql {
501 PRAGMA page_size = 1024; 506 PRAGMA auto_vacuum=OFF;
502 CREATE TABLE t1(x); 507 PRAGMA page_size = 1024;
503 INSERT INTO t1 VALUES(1.1); 508 CREATE TABLE t1(x);
509 INSERT INTO t1 VALUES(1.1);
510 }
511 db close
512 hexio_write test.db 2040 4142ba32bffffff9
513 sqlite3 db test.db
514 db eval {SELECT * FROM t1}
515 } {2454629.5}
516
517 # Changing the least significant byte of the floating point value between
518 # 00 and FF should always generate a time of either 23:59:59 or 00:00:00,
519 # never 24:00:00
520 #
521 for {set i 0} {$i<=255} {incr i} {
522 db close
523 hexio_write test.db 2047 [format %02x $i]
524 sqlite3 db test.db
525 do_test date-14.2.$i {
526 set date [db one {SELECT datetime(x) FROM t1}]
527 expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"}
528 } {1}
504 } 529 }
505 db close
506 hexio_write test.db 2040 4142ba32bffffff9
507 sqlite3 db test.db
508 db eval {SELECT * FROM t1}
509 } {2454629.5}
510
511 # Changing the least significant byte of the floating point value between
512 # 00 and FF should always generate a time of either 23:59:59 or 00:00:00,
513 # never 24:00:00
514 #
515 for {set i 0} {$i<=255} {incr i} {
516 db close
517 hexio_write test.db 2047 [format %02x $i]
518 sqlite3 db test.db
519 do_test date-14.2.$i {
520 set date [db one {SELECT datetime(x) FROM t1}]
521 expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"}
522 } {1}
523 } 530 }
524 finish_test 531 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/ctime.test ('k') | third_party/sqlite/src/test/dbstatus.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698