Skip to content

Commit

Permalink
Add tests for boundary conditions when computing ISO week number
Browse files Browse the repository at this point in the history
These tests currently fail. These tests were pulled from the following PR in
chrono:

- chronotope/chrono#966

They were validated with MRI v3.1.2. The third test case differs between
chrono and MRI.
  • Loading branch information
lopopolo committed Apr 2, 2023
1 parent 40e64bc commit 9342567
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/tests/format.rs
Expand Up @@ -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(
&times,
"%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",
],
);
}

0 comments on commit 9342567

Please sign in to comment.