brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · a3a621b Raw
46 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <chrono>11// class weekday;12 13//  constexpr unsigned iso_encoding() const noexcept;14//  Returns the underlying weekday, _except_ that returns '7' for Sunday (zero)15//    See [time.cal.wd.members]16 17#include <chrono>18#include <cassert>19#include <type_traits>20#include <utility>21 22#include "test_macros.h"23 24using weekday = std::chrono::weekday;25 26constexpr bool test() {27  //  This is different than all the other tests, because the '7' gets converted to28  //  a zero in the constructor, but then back to '7' by iso_encoding().29  for (unsigned i = 0; i <= 10; ++i) {30    weekday wd(i);31    assert(wd.iso_encoding() == (i == 0 ? 7 : i));32  }33 34  return true;35}36 37int main(int, char**) {38  ASSERT_NOEXCEPT(std::declval<weekday&>().iso_encoding());39  ASSERT_SAME_TYPE(unsigned, decltype(std::declval<weekday&>().iso_encoding()));40 41  test();42  static_assert(test());43 44  return 0;45}46