From 93425676efc3653c69ddc5dfc7ed81f3966a1b89 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sat, 1 Apr 2023 17:54:11 -0700 Subject: [PATCH] Add tests for boundary conditions when computing ISO week number These tests currently fail. These tests were pulled from the following PR in chrono: - https://github.com/chronotope/chrono/pull/966 They were validated with MRI v3.1.2. The third test case differs between chrono and MRI. --- src/tests/format.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/tests/format.rs b/src/tests/format.rs index 27cbce3..9bad29a 100644 --- a/src/tests/format.rs +++ b/src/tests/format.rs @@ -922,3 +922,34 @@ fn test_format_copies_non_specifier_bytes() { ], ); } + +#[test] +fn test_chrono_pr_966_week_numbers() { + let times = [ + MockTime::new(2020, 1, 12, 0, 0, 0, 0, 4, 1, 0, false, 0, ""), + MockTime::new(2019, 1, 13, 0, 0, 0, 0, 4, 1, 0, false, 0, ""), + MockTime::new(2007, 12, 31, 0, 0, 0, 0, 4, 1, 0, false, 0, ""), + ]; + + check_all( + ×, + "%Y-%W-%w", + &[ + // ``` + // [3.1.2] > Time.utc(2020, 1, 12).strftime("%Y-%W-%w") + // => "2020-01-0" + // ``` + "2020-01-0", + // ``` + // [3.1.2] > Time.utc(2019, 1, 13).strftime("%Y-%W-%w") + // => "2019-01-0" + // ``` + "2019-01-0", + // ``` + // [3.1.2] > Time.utc(2007, 12, 31).strftime("%Y-%W-%w") + // => "2007-53-1" + // ``` + "2007-12-52", + ], + ); +}