[libcxx-commits] [libcxx] 0df9a72 - [NFC][libc++][chrono] Improves test coverage.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 21 08:53:30 PST 2022
Author: Mark de Wever
Date: 2022-12-21T17:53:23+01:00
New Revision: 0df9a72f283a5c2b6f0435bd988e1fd70ed5b477
URL: https://github.com/llvm/llvm-project/commit/0df9a72f283a5c2b6f0435bd988e1fd70ed5b477
DIFF: https://github.com/llvm/llvm-project/commit/0df9a72f283a5c2b6f0435bd988e1fd70ed5b477.diff
LOG: [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
Added:
Modified:
libcxx/test/std/time/time.cal/time.cal.ymwd/time.cal.ymwd.members/op.sys_days.pass.cpp
Removed:
################################################################################
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 9bfa0472f7bce..3ca32d926cbab 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;
}
More information about the libcxx-commits
mailing list