1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
14 // constexpr month& operator+=(const month& d) noexcept;
15 // constexpr month& operator-=(const month& d) noexcept;
18 #include <type_traits>
21 #include "test_macros.h"
23 template <typename M, typename Ms>
24 constexpr bool testConstexpr()
27 if (static_cast<unsigned>(m1 += Ms{ 1}) != 2) return false;
28 if (static_cast<unsigned>(m1 += Ms{ 2}) != 4) return false;
29 if (static_cast<unsigned>(m1 += Ms{ 8}) != 12) return false;
30 if (static_cast<unsigned>(m1 -= Ms{ 1}) != 11) return false;
31 if (static_cast<unsigned>(m1 -= Ms{ 2}) != 9) return false;
32 if (static_cast<unsigned>(m1 -= Ms{ 8}) != 1) return false;
38 using month = std::chrono::month;
39 using months = std::chrono::months;
41 ASSERT_NOEXCEPT(std::declval<month&>() += std::declval<months&>());
42 ASSERT_NOEXCEPT(std::declval<month&>() -= std::declval<months&>());
43 ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() += std::declval<months&>()));
44 ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() -= std::declval<months&>()));
46 static_assert(testConstexpr<month, months>(), "");
48 for (unsigned i = 1; i <= 10; ++i)
54 assert(static_cast<unsigned>(month += months{10}) == static_cast<unsigned>(exp));
55 assert(static_cast<unsigned>(month) == static_cast<unsigned>(exp));
58 for (unsigned i = 1; i <= 10; ++i)
64 assert(static_cast<unsigned>(month -= months{ 9}) == static_cast<unsigned>(exp));
65 assert(static_cast<unsigned>(month) == static_cast<unsigned>(exp));