Debian Codegraph @

libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/ctor.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9
10 // <chrono>
11 // class month;
12
13 // month() = default;
14 // explicit constexpr month(int m) noexcept;
15 // explicit constexpr operator int() const noexcept;
16
17 // Effects: Constructs an object of type month by initializing m_ with m.
18 // The value held is unspecified if d is not in the range [0, 255].
19
20 #include <chrono>
21 #include <type_traits>
22 #include <cassert>
23
24 #include "test_macros.h"
25
26 int main(int, char**)
27 {
28 using month = std::chrono::month;
29
30 ASSERT_NOEXCEPT(month{});
31 ASSERT_NOEXCEPT(month(1));
32 ASSERT_NOEXCEPT(static_cast<unsigned>(month(1)));
33
34 constexpr month m0{};
35 static_assert(static_cast<unsigned>(m0) == 0, "");
36
37 constexpr month m1{1};
38 static_assert(static_cast<unsigned>(m1) == 1, "");
39
40 for (unsigned i = 0; i <= 255; ++i)
41 {
42 month m(i);
43 assert(static_cast<unsigned>(m) == i);
44 }
45
46 return 0;
47 }