]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: date: add large year test
authorSylvestre Ledru <sylvestre@debian.org>
Thu, 2 Apr 2026 11:10:13 +0000 (13:10 +0200)
committerPádraig Brady <P@draigBrady.com>
Mon, 6 Apr 2026 18:22:24 +0000 (19:22 +0100)
* tests/date/date.pl: Add the test case.
Add test case for https://github.com/uutils/coreutils/issues/9774
to verify with large dates.
https://github.com/coreutils/coreutils/pull/237

tests/date/date.pl

index 99b3adb415db1804aec8863c67715f64142ce407..d5a93ff9b36f57d9d1379afb59150f0b9a3de48e 100755 (executable)
 
 use strict;
 
+my $limits = getlimits ();
+my $large_year = $limits->{INT_MAX} + 1900;
+my $large_year_out_of_range = $large_year + 1;
+
 (my $ME = $0) =~ s|.*/||;
 
 # Turn off localization of executable's output.
@@ -372,8 +376,21 @@ my @Tests =
      # Test timezone conversion with -u -d flag
      # "10:30 UTC-05" should convert to "15:30 UTC", not "10:30 UTC"
      ['tz-conversion-est', "-u -d '10:30 UTC-05' +'%H:%M'", {OUT=>"15:30"}],
+
     );
 
+$limits->{TIME_T_MAX} == $limits->{INTMAX_MAX}
+  and push @Tests,
+    ['large-year', "-d '$large_year-01-01' +'%Y-%m-%d'",
+     {OUT=>"$large_year-01-01"}];
+
+push @Tests,
+  ['large-year-out-of-range',
+   "-d '$large_year_out_of_range-01-01' +'%Y-%m-%d'",
+   {ERR => "date: invalid date '$large_year_out_of_range-01-01'\n"},
+   {EXIT => 1},
+  ];
+
 # Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.
 foreach my $i (1..364)
   {