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 weekday;
12
13// weekday() = default;
14// explicit constexpr weekday(unsigned wd) noexcept;
15// constexpr weekday(const sys_days& dp) noexcept;
16// explicit constexpr weekday(const local_days& dp) noexcept;
17//
18// unsigned c_encoding() const noexcept;
19
20// Effects: Constructs an object of type weekday by initializing wd_ with wd == 7 ? 0 : wd
21// The value held is unspecified if wd is not in the range [0, 255].
22
23#include <chrono>
24#include <type_traits>
25#include <cassert>
26
27#include "test_macros.h"
28
29int main(int, char**)
30{
31 using weekday = std::chrono::weekday;
32
33 ASSERT_NOEXCEPT(weekday{});
34 ASSERT_NOEXCEPT(weekday(1));
35 ASSERT_NOEXCEPT(weekday(1).c_encoding());
36
37 constexpr weekday m0{};
38 static_assert(m0.c_encoding() == 0, "");
39
40 constexpr weekday m1{1};
41 static_assert(m1.c_encoding() == 1, "");
42
43 for (unsigned i = 0; i <= 255; ++i)
44 {
45 weekday m(i);
46 assert(m.c_encoding() == (i == 7 ? 0 : i));
47 }
48
49 // TODO - sys_days and local_days ctor tests
50
51 return 0;
52}
53

source code of libcxx/test/std/time/time.cal/time.cal.weekday/time.cal.weekday.members/ctor.pass.cpp