summaryrefslogtreecommitdiff
path: root/tests/misc/date
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-08-13 14:41:39 +0000
committerJim Meyering <jim@meyering.net>2005-08-13 14:41:39 +0000
commit9741a40764b2f0b114c7ad386eb818e429b8be59 (patch)
tree2c003463d4360ab8a96ad8e1b33f7f6143c9ffbc /tests/misc/date
parenta6f5fa497dd816243d18ff9512593fe2fe2b6581 (diff)
downloadcoreutils-9741a40764b2f0b114c7ad386eb818e429b8be59.tar.xz
add a bunch more tests
Diffstat (limited to 'tests/misc/date')
-rwxr-xr-xtests/misc/date57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/misc/date b/tests/misc/date
index a140f9685..bf9812147 100755
--- a/tests/misc/date
+++ b/tests/misc/date
@@ -21,8 +21,65 @@ use strict;
# Export TZ=UTC0 so that zone-dependent strings match.
$ENV{TZ} = 'UTC0';
+my $t0 = '08:17:48';
+my $d0 = '1997-01-19';
+my $d1 = "$d0 $t0 +0";
+
+my $ts = '08:17:49'; # next second
+my $tm = '08:18:48'; # next minute
+my $th = '09:17:48'; # next hour
+
+my $dd = '1997-01-20'; # next day
+my $dw = '1997-01-26'; # next week
+my $dm = '1997-02-19'; # next month
+my $dy = '1998-01-19'; # next month
+
+my $fmt = "'+%Y-%m-%d %T'";
+
my @Tests =
(
+ # test-name, [option, option, ...] {OUT=>'expected-output'}
+ #
+ ['1', "-d '$d1' +'%% %a %A %b %B'", {OUT=>'% Sun Sunday Jan January'}],
+
+ # [Actually, skip it on *all* systems. -- this Perl code is run at
+ # distribution-build-time, not at configure/test time. ]
+
+ # Skip the test of %c on SunOS4 systems. Such systems would fail this
+ # test because their underlying strftime doesn't handle the %c format
+ # properly. GNU strftime must rely on the underlying host library
+ # function to get locale-dependent behavior, as strftime is the only
+ # portable interface to that behavior.
+ # ['2', "-d '$d1' +'%c'", {OUT=>"Sun Jan 19 $t0 1997"}],
+
+ ['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {OUT=>'19_01/19/97_19_Jan_08'}],
+ ['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {OUT=>'08_019_ 8_ 8_01'}],
+ ['5', "-d '$d1' +'%M_%n_%p_%r'", {OUT=>"17_\n_AM_$t0 AM"}],
+ ['6', "-d '$d1' +'%s_%S_%t_%T'", {OUT=>"853661868_48_\t_$t0"}],
+ ['7', "-d '$d1' +'%U_%V_%w_%W'", {OUT=>'03_03_0_02'}],
+ ['8', "-d '$d1' +'%x_%X_%y_%Y'", {OUT=>"01/19/97_${t0}_97_1997"}],
+ ['9', "-d '$d1' +'%z'", {OUT=>'+0000'}],
+
+ ['leap-1', "--date '02/29/1996 1 year' +%Y-%m-%d", {OUT=>'1997-03-01'}],
+
+ ['U95-1', "--date '1995-1-1' +%U", {OUT=>'01'}],
+ ['U95-2', "--date '1995-1-7' +%U", {OUT=>'01'}],
+ ['U95-3', "--date '1995-1-8' +%U", {OUT=>'02'}],
+
+ ['U92-1', "--date '1992-1-1' +%U", {OUT=>'00'}],
+ ['U92-2', "--date '1992-1-4' +%U", {OUT=>'00'}],
+ ['U92-3', "--date '1992-1-5' +%U", {OUT=>'01'}],
+
+ ['V92-1', "--date '1992-1-1' +%V", {OUT=>'01'}],
+ ['V92-2', "--date '1992-1-5' +%V", {OUT=>'01'}],
+ ['V92-3', "--date '1992-1-6' +%V", {OUT=>'02'}],
+
+ ['W92-1', "--date '1992-1-1' +%W", {OUT=>'00'}],
+ ['W92-2', "--date '1992-1-5' +%W", {OUT=>'00'}],
+ ['W92-3', "--date '1992-1-6' +%W", {OUT=>'01'}],
+
+ ['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>'2001'}],
+
# This would infloop (or appear to) prior to coreutils-4.5.5,
# due to a bug in strftime.c.
['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . '1999'}],