[libcxx-commits] [PATCH] D139126: [NFC][libc++][chrono] Improves test coverage.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 1 09:59:42 PST 2022
Mordante created this revision.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139126
Files:
libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp
Index: libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp
===================================================================
--- libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp
+++ libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp
@@ -70,5 +70,14 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139126.479341.patch
Type: text/x-patch
Size: 817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221201/b5a67ca7/attachment.bin>
More information about the libcxx-commits
mailing list