[libc++][chrono] Fixes month inc and dec operations.
authorMark de Wever <koraq@xs4all.nl>
Mon, 17 Jul 2023 18:25:01 +0000 (20:25 +0200)
committerMark de Wever <koraq@xs4all.nl>
Tue, 18 Jul 2023 15:32:11 +0000 (17:32 +0200)
commitab0d757bcfc486ac6ed8ba69d4e630feda2b6ab7
tree2cc00e8d76a7ff60e5f35d255faf773554b853f4
parentf4f6c229bde8f42721482469bd5a3d050d254d82
[libc++][chrono] Fixes month inc and dec operations.

The operator++, operator++(int), operator--, and operator--(int) need to
change the month to a valid value. The wording is specified in terms of
  operator+(const month& x, const months& y) noexcept;
which has the correct behavior. The aforementioned operators instead
used ++/-- on the internal value direction, resulting in incorrect
behaviour.

As a drive-by improve the unit tests:
- use the typical constexpr test method
- test whether the month is valid after the operations
- format the tests

Fixes: https://llvm.org/PR63912

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D155504
libcxx/include/__chrono/month.h
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/decrement.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/increment.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/plus_minus_equal.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.nonmembers/minus.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.nonmembers/plus.pass.cpp