[NFC][libc++][chrono] Improves test coverage.
authorMark de Wever <koraq@xs4all.nl>
Thu, 1 Dec 2022 17:56:40 +0000 (18:56 +0100)
committerMark de Wever <koraq@xs4all.nl>
Wed, 21 Dec 2022 16:53:23 +0000 (17:53 +0100)
The function year_month_weekday::sys_days should work properly with a
weekday index of 0 per [time.cal.ymwd.members]/20. This adds a test for
this case.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D139126

libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp

index 9bfa047..3ca32d9 100644 (file)
@@ -70,5 +70,14 @@ int main(int, char**)
     assert( year_month_weekday{sd} == ymwd); // and back
     }
 
+    {
+    // Index 0 returns 7 weekdays before index 1 and can't be round-tripped.
+    constexpr year_month_weekday ymwd{year{2000}, month{2}, weekday_indexed{std::chrono::Wednesday, 0}};
+    constexpr sys_days sd{ymwd};
+
+    static_assert(sd.time_since_epoch() == days{10957 + 25});
+    static_assert(year_month_weekday{sd} != ymwd); // and back fails
+    }
+
     return 0;
 }