From: Mark de Wever Date: Thu, 1 Dec 2022 17:56:40 +0000 (+0100) Subject: [NFC][libc++][chrono] Improves test coverage. X-Git-Tag: upstream/17.0.6~22946 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0df9a72f283a5c2b6f0435bd988e1fd70ed5b477;p=platform%2Fupstream%2Fllvm.git [NFC][libc++][chrono] Improves test coverage. 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 --- diff --git a/libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp b/libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp index 9bfa047..3ca32d9 100644 --- a/libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp +++ b/libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp @@ -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; }