Revert r344529 "Implement the first part of the calendar support for C++20"

Revert r344535 "Wrap up the new chrono literals in an #ifdef..."
Revert r344546 "Mark a couple of test cases as 'C++17-only'..."

Some of the buildbot failures were masked by another error,
and this one was probably missed.

llvm-svn: 344580
This commit is contained in:
Artem Dergachev 2018-10-16 02:40:42 +00:00
parent 4886652773
commit a9bc0face5
183 changed files with 3 additions and 10964 deletions

View File

@ -492,11 +492,6 @@ namespace std {
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
// No apple compilers support ""d and ""y at this time.
#if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__)
#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
#endif
#elif defined(_LIBCPP_COMPILER_GCC)
#define _ALIGNAS(x) __attribute__((__aligned__(x)))

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// using days = duration<signed integer type of at least 25 bits, ratio_multiply<ratio<24>, hours::period>>;
#include <chrono>
#include <type_traits>
#include <limits>
int main()
{
typedef std::chrono::days D;
typedef D::rep Rep;
typedef D::period Period;
static_assert(std::is_signed<Rep>::value, "");
static_assert(std::is_integral<Rep>::value, "");
static_assert(std::numeric_limits<Rep>::digits >= 25, "");
static_assert(std::is_same_v<Period, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>, "");
}

View File

@ -1,29 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// using months = duration<signed integer type of at least 20 bits, ratio_divide<years::period, ratio<12>>>;
#include <chrono>
#include <type_traits>
#include <limits>
int main()
{
typedef std::chrono::months D;
typedef D::rep Rep;
typedef D::period Period;
static_assert(std::is_signed<Rep>::value, "");
static_assert(std::is_integral<Rep>::value, "");
static_assert(std::numeric_limits<Rep>::digits >= 20, "");
static_assert(std::is_same_v<Period, std::ratio_divide<std::chrono::years::period, std::ratio<12>>>, "");
}

View File

@ -1,40 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Assumption: minValue < maxValue
// Assumption: minValue <= rhs <= maxValue
// Assumption: minValue <= lhs <= maxValue
// Assumption: minValue >= 0
template <typename T, T minValue, T maxValue>
T euclidian_addition(T rhs, T lhs)
{
const T modulus = maxValue - minValue + 1;
T ret = rhs + lhs;
if (ret > maxValue)
ret -= modulus;
return ret;
}
// Assumption: minValue < maxValue
// Assumption: minValue <= rhs <= maxValue
// Assumption: minValue <= lhs <= maxValue
// Assumption: minValue >= 0
template <typename T, T minValue, T maxValue>
T euclidian_subtraction(T lhs, T rhs)
{
const T modulus = maxValue - minValue + 1;
T ret = lhs - rhs;
if (ret < minValue)
ret += modulus;
if (ret > maxValue) // this can happen if T is unsigned
ret += modulus;
return ret;
}

View File

@ -1,12 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@ -1,46 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// day() = default;
// explicit constexpr day(unsigned d) noexcept;
// explicit constexpr operator unsigned() const noexcept;
// Effects: Constructs an object of type day by initializing d_ with d.
// The value held is unspecified if d is not in the range [0, 255].
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
ASSERT_NOEXCEPT(day{});
ASSERT_NOEXCEPT(day(0U));
ASSERT_NOEXCEPT(static_cast<unsigned>(day(0U)));
constexpr day d0{};
static_assert(static_cast<unsigned>(d0) == 0, "");
constexpr day d1{1};
static_assert(static_cast<unsigned>(d1) == 1, "");
for (unsigned i = 0; i <= 255; ++i)
{
day day(i);
assert(static_cast<unsigned>(day) == i);
}
}

View File

@ -1,52 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr day& operator--() noexcept;
// constexpr day operator--(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename D>
constexpr bool testConstexpr()
{
D d1{10};
if (static_cast<unsigned>(--d1) != 9) return false;
if (static_cast<unsigned>(d1--) != 9) return false;
if (static_cast<unsigned>(d1) != 8) return false;
return true;
}
int main()
{
using day = std::chrono::day;
ASSERT_NOEXCEPT(--(std::declval<day&>()) );
ASSERT_NOEXCEPT( (std::declval<day&>())--);
ASSERT_SAME_TYPE(day , decltype( std::declval<day&>()--));
ASSERT_SAME_TYPE(day&, decltype(--std::declval<day&>() ));
static_assert(testConstexpr<day>(), "");
for (unsigned i = 10; i <= 20; ++i)
{
day day(i);
assert(static_cast<unsigned>(--day) == i - 1);
assert(static_cast<unsigned>(day--) == i - 1);
assert(static_cast<unsigned>(day) == i - 2);
}
}

View File

@ -1,52 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr day& operator++() noexcept;
// constexpr day operator++(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename D>
constexpr bool testConstexpr()
{
D d1{1};
if (static_cast<unsigned>(++d1) != 2) return false;
if (static_cast<unsigned>(d1++) != 2) return false;
if (static_cast<unsigned>(d1) != 3) return false;
return true;
}
int main()
{
using day = std::chrono::day;
ASSERT_NOEXCEPT(++(std::declval<day&>()) );
ASSERT_NOEXCEPT( (std::declval<day&>())++);
ASSERT_SAME_TYPE(day , decltype( std::declval<day&>()++));
ASSERT_SAME_TYPE(day&, decltype(++std::declval<day&>() ));
static_assert(testConstexpr<day>(), "");
for (unsigned i = 10; i <= 20; ++i)
{
day day(i);
assert(static_cast<unsigned>(++day) == i + 1);
assert(static_cast<unsigned>(day++) == i + 1);
assert(static_cast<unsigned>(day) == i + 2);
}
}

View File

@ -1,37 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr bool ok() const noexcept;
// Returns: 1 <= d_ && d_ <= 31
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
ASSERT_NOEXCEPT( std::declval<const day>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const day>().ok()));
static_assert(!day{0}.ok(), "");
static_assert( day{1}.ok(), "");
assert(!day{0}.ok());
for (unsigned i = 1; i <= 31; ++i)
assert(day{i}.ok());
for (unsigned i = 32; i <= 255; ++i)
assert(!day{i}.ok());
}

View File

@ -1,57 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr day& operator+=(const days& d) noexcept;
// constexpr day& operator-=(const days& d) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename D, typename Ds>
constexpr bool testConstexpr()
{
D d1{1};
if (static_cast<unsigned>(d1 += Ds{ 1}) != 2) return false;
if (static_cast<unsigned>(d1 += Ds{ 2}) != 4) return false;
if (static_cast<unsigned>(d1 += Ds{22}) != 26) return false;
if (static_cast<unsigned>(d1 -= Ds{ 1}) != 25) return false;
if (static_cast<unsigned>(d1 -= Ds{ 2}) != 23) return false;
if (static_cast<unsigned>(d1 -= Ds{22}) != 1) return false;
return true;
}
int main()
{
using day = std::chrono::day;
using days = std::chrono::days;
ASSERT_NOEXCEPT(std::declval<day&>() += std::declval<days>());
ASSERT_NOEXCEPT(std::declval<day&>() -= std::declval<days>());
ASSERT_SAME_TYPE(day&, decltype(std::declval<day&>() += std::declval<days>()));
ASSERT_SAME_TYPE(day&, decltype(std::declval<day&>() -= std::declval<days>()));
static_assert(testConstexpr<day, days>(), "");
for (unsigned i = 0; i <= 10; ++i)
{
day day(i);
assert(static_cast<unsigned>(day += days{22}) == i + 22);
assert(static_cast<unsigned>(day) == i + 22);
assert(static_cast<unsigned>(day -= days{12}) == i + 10);
assert(static_cast<unsigned>(day) == i + 10);
}
}

View File

@ -1,44 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr bool operator==(const day& x, const day& y) noexcept;
// Returns: unsigned{x} == unsigned{y}.
// constexpr bool operator<(const day& x, const day& y) noexcept;
// Returns: unsigned{x} < unsigned{y}.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using day = std::chrono::day;
AssertComparisons6AreNoexcept<day>();
AssertComparisons6ReturnBool<day>();
static_assert(testComparisons6Values<day>(0U, 0U), "");
static_assert(testComparisons6Values<day>(0U, 1U), "");
// Some 'ok' values as well
static_assert(testComparisons6Values<day>( 5U, 5U), "");
static_assert(testComparisons6Values<day>( 5U, 10U), "");
for (unsigned i = 1; i < 10; ++i)
for (unsigned j = 1; j < 10; ++j)
assert(testComparisons6Values<day>(i, j));
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr day operator""d(unsigned long long d) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
day d1 = 4d; // expected-error-re {{no matching literal operator for call to 'operator""d' {{.*}}}}
}

View File

@ -1,47 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: clang-5, clang-6
// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
// <chrono>
// class day;
// constexpr day operator""d(unsigned long long d) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
{
using namespace std::chrono;
ASSERT_NOEXCEPT( 4d);
ASSERT_SAME_TYPE(day, decltype(4d));
static_assert( 7d == day(7), "");
day d1 = 4d;
assert (d1 == day(4));
}
{
using namespace std::literals;
ASSERT_NOEXCEPT( 4d);
ASSERT_SAME_TYPE(std::chrono::day, decltype(4d));
static_assert( 7d == std::chrono::day(7), "");
std::chrono::day d1 = 4d;
assert (d1 == std::chrono::day(4));
}
}

View File

@ -1,58 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr day operator-(const day& x, const days& y) noexcept;
// Returns: x + -y.
//
// constexpr days operator-(const day& x, const day& y) noexcept;
// Returns: days{int(unsigned{x}) - int(unsigned{y}).
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename D, typename Ds>
constexpr bool testConstexpr()
{
D d{23};
Ds offset{6};
if (d - offset != D{17}) return false;
if (d - D{17} != offset) return false;
return true;
}
int main()
{
using day = std::chrono::day;
using days = std::chrono::days;
ASSERT_NOEXCEPT(std::declval<day>() - std::declval<days>());
ASSERT_NOEXCEPT(std::declval<day>() - std::declval<day>());
ASSERT_SAME_TYPE(day, decltype(std::declval<day>() - std::declval<days>()));
ASSERT_SAME_TYPE(days, decltype(std::declval<day>() - std::declval<day>()));
static_assert(testConstexpr<day, days>(), "");
day dy{12};
for (unsigned i = 0; i <= 10; ++i)
{
day d1 = dy - days{i};
days off = dy - day {i};
assert(static_cast<unsigned>(d1) == 12 - i);
assert(off.count() == static_cast<int>(12 - i)); // days is signed
}
}

View File

@ -1,59 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
// constexpr day operator+(const day& x, const days& y) noexcept;
// Returns: day(unsigned{x} + y.count()).
//
// constexpr day operator+(const days& x, const day& y) noexcept;
// Returns: y + x.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename D, typename Ds>
constexpr bool testConstexpr()
{
D d{1};
Ds offset{23};
if (d + offset != D{24}) return false;
if (offset + d != D{24}) return false;
return true;
}
int main()
{
using day = std::chrono::day;
using days = std::chrono::days;
ASSERT_NOEXCEPT(std::declval<day>() + std::declval<days>());
ASSERT_NOEXCEPT(std::declval<days>() + std::declval<day>());
ASSERT_SAME_TYPE(day, decltype(std::declval<day>() + std::declval<days>()));
ASSERT_SAME_TYPE(day, decltype(std::declval<days>() + std::declval<day>()));
static_assert(testConstexpr<day, days>(), "");
day dy{12};
for (unsigned i = 0; i <= 10; ++i)
{
day d1 = dy + days{i};
day d2 = days{i} + dy;
assert(d1 == d2);
assert(static_cast<unsigned>(d1) == i + 12);
assert(static_cast<unsigned>(d2) == i + 12);
}
}

View File

@ -1,56 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class day;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const day& d);
//
// Effects: Inserts format(fmt, d) where fmt is "%d" widened to charT.
// If !d.ok(), appends with " is not a valid day".
//
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const day& d);
//
// Effects: Streams d into os using the format specified by the NTCTS fmt.
// fmt encoding follows the rules specified in 25.11.
//
// template<class charT, class traits, class Alloc = allocator<charT>>
// basic_istream<charT, traits>&
// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
// day& d, basic_string<charT, traits, Alloc>* abbrev = nullptr,
// minutes* offset = nullptr);
//
// Effects: Attempts to parse the input stream is into the day d using the format flags
// given in the NTCTS fmt as specified in 25.12.
// If the parse fails to decode a valid day, is.setstate(ios_base::failbit)
// shall be called and d shall not be modified.
// If %Z is used and successfully parsed, that value will be assigned to *abbrev
// if abbrev is non-null. If %z (or a modified variant) is used and
// successfully parsed, that value will be assigned to *offset if offset is non-null.
//
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
std::cout << day{1};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class day;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
static_assert(std::is_trivially_copyable_v<day>, "");
static_assert(std::is_standard_layout_v<day>, "");
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// struct last_spec {
// explicit last_spec() = default;
// };
//
// inline constexpr last_spec last{};
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using last_spec = std::chrono::last_spec;
ASSERT_SAME_TYPE(const last_spec, decltype(std::chrono::last));
static_assert(std::is_trivially_copyable_v<last_spec>, "");
static_assert(std::is_standard_layout_v<last_spec>, "");
}

View File

@ -1,47 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
// month_day() = default;
// constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
//
// Effects: Constructs an object of type month_day by initializing m_ with m, and d_ with d.
//
// constexpr chrono::month month() const noexcept;
// constexpr chrono::day day() const noexcept;
// constexpr bool ok() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
using month = std::chrono::month;
using month_day = std::chrono::month_day;
ASSERT_NOEXCEPT(month_day{});
ASSERT_NOEXCEPT(month_day{month{1}, day{1}});
constexpr month_day md0{};
static_assert( md0.month() == month{}, "");
static_assert( md0.day() == day{}, "");
static_assert(!md0.ok(), "");
constexpr month_day md1{std::chrono::January, day{4}};
static_assert( md1.month() == std::chrono::January, "");
static_assert( md1.day() == day{4}, "");
static_assert( md1.ok(), "");
}

View File

@ -1,39 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
// constexpr chrono::day day() const noexcept;
// Returns: d_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
using month = std::chrono::month;
using month_day = std::chrono::month_day;
ASSERT_NOEXCEPT( std::declval<const month_day>().day());
ASSERT_SAME_TYPE(day, decltype(std::declval<const month_day>().day()));
static_assert( month_day{}.day() == day{}, "");
for (unsigned i = 1; i <= 50; ++i)
{
month_day md(std::chrono::March, day{i});
assert( static_cast<unsigned>(md.day()) == i);
}
}

View File

@ -1,39 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
// constexpr chrono::month month() const noexcept;
// Returns: wd_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
using month = std::chrono::month;
using month_day = std::chrono::month_day;
ASSERT_NOEXCEPT( std::declval<const month_day>().month());
ASSERT_SAME_TYPE(month, decltype(std::declval<const month_day>().month()));
static_assert( month_day{}.month() == month{}, "");
for (unsigned i = 1; i <= 50; ++i)
{
month_day md(month{i}, day{1});
assert( static_cast<unsigned>(md.month()) == i);
}
}

View File

@ -1,55 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
// constexpr bool ok() const noexcept;
// Returns: true if m_.ok() is true, 1d <= d_, and d_ is less than or equal to the
// number of days in month m_; otherwise returns false.
// When m_ == February, the number of days is considered to be 29.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using day = std::chrono::day;
using month = std::chrono::month;
using month_day = std::chrono::month_day;
ASSERT_NOEXCEPT( std::declval<const month_day>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_day>().ok()));
static_assert(!month_day{}.ok(), "");
static_assert( month_day{std::chrono::May, day{2}}.ok(), "");
assert(!(month_day(std::chrono::April, day{0}).ok()));
assert( (month_day{std::chrono::March, day{1}}.ok()));
for (unsigned i = 1; i <= 12; ++i)
{
const bool is31 = i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12;
assert(!(month_day{month{i}, day{ 0}}.ok()));
assert( (month_day{month{i}, day{ 1}}.ok()));
assert( (month_day{month{i}, day{10}}.ok()));
assert( (month_day{month{i}, day{29}}.ok()));
assert( (month_day{month{i}, day{30}}.ok()) == (i != 2));
assert( (month_day{month{i}, day{31}}.ok()) == is31);
assert(!(month_day{month{i}, day{32}}.ok()));
}
// If the month is not ok, all the days are bad
for (unsigned i = 1; i <= 35; ++i)
assert(!(month_day{month{13}, day{i}}.ok()));
}

View File

@ -1,70 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
// Returns: x.month() == y.month() && x.day() == y.day().
//
// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
// Returns:
// If x.month() < y.month() returns true.
// Otherwise, if x.month() > y.month() returns false.
// Otherwise, returns x.day() < y.day().
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using day = std::chrono::day;
using month = std::chrono::month;
using month_day = std::chrono::month_day;
AssertComparisons6AreNoexcept<month_day>();
AssertComparisons6ReturnBool<month_day>();
static_assert( testComparisons6(
month_day{std::chrono::January, day{1}},
month_day{std::chrono::January, day{1}},
true, false), "");
static_assert( testComparisons6(
month_day{std::chrono::January, day{1}},
month_day{std::chrono::January, day{2}},
false, true), "");
static_assert( testComparisons6(
month_day{std::chrono::January, day{1}},
month_day{std::chrono::February, day{1}},
false, true), "");
// same day, different months
for (unsigned i = 1; i < 12; ++i)
for (unsigned j = 1; j < 12; ++j)
assert((testComparisons6(
month_day{month{i}, day{1}},
month_day{month{j}, day{1}},
i == j, i < j )));
// same month, different days
for (unsigned i = 1; i < 31; ++i)
for (unsigned j = 1; j < 31; ++j)
assert((testComparisons6(
month_day{month{2}, day{i}},
month_day{month{2}, day{j}},
i == j, i < j )));
}

View File

@ -1,41 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class month_day;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const month_day& md);
//
// Returns: os << md.month() << '/' << md.day().
//
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month_day& md);
//
// Effects: Streams md into os using the format specified by the NTCTS fmt.
// fmt encoding follows the rules specified in 25.11.
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using month_day = std::chrono::month_day;
using month = std::chrono::month;
using day = std::chrono::day;
std::cout << month_day{month{1}, day{1}};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_day = std::chrono::month_day;
static_assert(std::is_trivially_copyable_v<month_day>, "");
static_assert(std::is_standard_layout_v<month_day>, "");
}

View File

@ -1,43 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day_last;
// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
// Returns: x.month() == y.month()
//
// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
// Returns: x.month() < y.month()
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month = std::chrono::month;
using month_day_last = std::chrono::month_day_last;
AssertComparisons6AreNoexcept<month_day_last>();
AssertComparisons6ReturnBool<month_day_last>();
static_assert( testComparisons6Values<month_day_last>(month{1}, month{1}), "");
static_assert( testComparisons6Values<month_day_last>(month{1}, month{2}), "");
// same day, different months
for (unsigned i = 1; i < 12; ++i)
for (unsigned j = 1; j < 12; ++j)
assert((testComparisons6Values<month_day_last>(month{i}, month{j})));
}

View File

@ -1,41 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day_last;
// constexpr month_day_last(const chrono::month& m) noexcept;
//
// Effects: Constructs an object of type month_day_last by initializing m_ with m
//
// constexpr chrono::month month() const noexcept;
// constexpr bool ok() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using month_day_last = std::chrono::month_day_last;
ASSERT_NOEXCEPT(month_day_last{month{1}});
constexpr month_day_last md0{month{}};
static_assert( md0.month() == month{}, "");
static_assert(!md0.ok(), "");
constexpr month_day_last md1{std::chrono::January};
static_assert( md1.month() == std::chrono::January, "");
static_assert( md1.ok(), "");
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day_last;
// constexpr chrono::month month() const noexcept;
// Returns: m_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using month_day_last = std::chrono::month_day_last;
ASSERT_NOEXCEPT( std::declval<const month_day_last>().month());
ASSERT_SAME_TYPE(month, decltype(std::declval<const month_day_last>().month()));
static_assert( month_day_last{month{}}.month() == month{}, "");
for (unsigned i = 1; i <= 50; ++i)
{
month_day_last mdl(month{i});
assert( static_cast<unsigned>(mdl.month()) == i);
}
}

View File

@ -1,46 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day_last;
// constexpr bool ok() const noexcept;
// Returns: m_.ok()
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using month_day_last = std::chrono::month_day_last;
ASSERT_NOEXCEPT( std::declval<const month_day_last>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_day_last>().ok()));
static_assert(!month_day_last{month{}}.ok(), "");
static_assert( month_day_last{std::chrono::May}.ok(), "");
for (unsigned i = 1; i <= 12; ++i)
{
month_day_last mdl{month{i}};
assert( mdl.ok());
}
// If the month is not ok, all the days are bad
for (unsigned i = 13; i <= 50; ++i)
{
month_day_last mdl{month{i}};
assert(!mdl.ok());
}
}

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class month_day_last;
//
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
//
// Returns: os << mdl.month() << "/last".
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using month_day_last = std::chrono::month_day_last;
using month = std::chrono::month;
std::cout << month_day_last{month{1}};
}

View File

@ -1,27 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day_last;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_day_last = std::chrono::month_day_last;
static_assert(std::is_trivially_copyable_v<month_day_last>, "");
static_assert(std::is_standard_layout_v<month_day_last>, "");
}

View File

@ -1,46 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// month() = default;
// explicit constexpr month(int m) noexcept;
// explicit constexpr operator int() const noexcept;
// Effects: Constructs an object of type month by initializing m_ with m.
// The value held is unspecified if d is not in the range [0, 255].
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
ASSERT_NOEXCEPT(month{});
ASSERT_NOEXCEPT(month(1));
ASSERT_NOEXCEPT(static_cast<unsigned>(month(1)));
constexpr month m0{};
static_assert(static_cast<unsigned>(m0) == 0, "");
constexpr month m1{1};
static_assert(static_cast<unsigned>(m1) == 1, "");
for (unsigned i = 0; i <= 255; ++i)
{
month m(i);
assert(static_cast<unsigned>(m) == i);
}
}

View File

@ -1,53 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr month& operator--() noexcept;
// constexpr month operator--(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename M>
constexpr bool testConstexpr()
{
M m1{10};
if (static_cast<unsigned>(--m1) != 9) return false;
if (static_cast<unsigned>(m1--) != 9) return false;
if (static_cast<unsigned>(m1) != 8) return false;
return true;
}
int main()
{
using month = std::chrono::month;
ASSERT_NOEXCEPT(--(std::declval<month&>()) );
ASSERT_NOEXCEPT( (std::declval<month&>())--);
ASSERT_SAME_TYPE(month , decltype( std::declval<month&>()--));
ASSERT_SAME_TYPE(month&, decltype(--std::declval<month&>() ));
static_assert(testConstexpr<month>(), "");
for (unsigned i = 10; i <= 20; ++i)
{
month month(i);
assert(static_cast<unsigned>(--month) == i - 1);
assert(static_cast<unsigned>(month--) == i - 1);
assert(static_cast<unsigned>(month) == i - 2);
}
}

View File

@ -1,52 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr month& operator++() noexcept;
// constexpr month operator++(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename M>
constexpr bool testConstexpr()
{
M m1{1};
if (static_cast<unsigned>(++m1) != 2) return false;
if (static_cast<unsigned>(m1++) != 2) return false;
if (static_cast<unsigned>(m1) != 3) return false;
return true;
}
int main()
{
using month = std::chrono::month;
ASSERT_NOEXCEPT(++(std::declval<month&>()) );
ASSERT_NOEXCEPT( (std::declval<month&>())++);
ASSERT_SAME_TYPE(month , decltype( std::declval<month&>()++));
ASSERT_SAME_TYPE(month&, decltype(++std::declval<month&>() ));
static_assert(testConstexpr<month>(), "");
for (unsigned i = 0; i <= 10; ++i)
{
month month(i);
assert(static_cast<unsigned>(++month) == i + 1);
assert(static_cast<unsigned>(month++) == i + 1);
assert(static_cast<unsigned>(month) == i + 2);
}
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr bool ok() const noexcept;
// Returns: 1 <= d_ && d_ <= 12
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
ASSERT_NOEXCEPT( std::declval<const month>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const month>().ok()));
static_assert(!month{0}.ok(), "");
static_assert( month{1}.ok(), "");
assert(!month{0}.ok());
for (unsigned i = 1; i <= 12; ++i)
assert(month{i}.ok());
for (unsigned i = 13; i <= 255; ++i)
assert(!month{i}.ok());
}

View File

@ -1,67 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr month& operator+=(const month& d) noexcept;
// constexpr month& operator-=(const month& d) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename M, typename Ms>
constexpr bool testConstexpr()
{
M m1{1};
if (static_cast<unsigned>(m1 += Ms{ 1}) != 2) return false;
if (static_cast<unsigned>(m1 += Ms{ 2}) != 4) return false;
if (static_cast<unsigned>(m1 += Ms{ 8}) != 12) return false;
if (static_cast<unsigned>(m1 -= Ms{ 1}) != 11) return false;
if (static_cast<unsigned>(m1 -= Ms{ 2}) != 9) return false;
if (static_cast<unsigned>(m1 -= Ms{ 8}) != 1) return false;
return true;
}
int main()
{
using month = std::chrono::month;
using months = std::chrono::months;
ASSERT_NOEXCEPT(std::declval<month&>() += std::declval<months&>());
ASSERT_NOEXCEPT(std::declval<month&>() -= std::declval<months&>());
ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() += std::declval<months&>()));
ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() -= std::declval<months&>()));
static_assert(testConstexpr<month, months>(), "");
for (unsigned i = 1; i <= 10; ++i)
{
month month(i);
int exp = i + 10;
while (exp > 12)
exp -= 12;
assert(static_cast<unsigned>(month += months{10}) == static_cast<unsigned>(exp));
assert(static_cast<unsigned>(month) == static_cast<unsigned>(exp));
}
for (unsigned i = 1; i <= 10; ++i)
{
month month(i);
int exp = i - 9;
while (exp < 1)
exp += 12;
assert(static_cast<unsigned>(month -= months{ 9}) == static_cast<unsigned>(exp));
assert(static_cast<unsigned>(month) == static_cast<unsigned>(exp));
}
}

View File

@ -1,47 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr bool operator==(const month& x, const month& y) noexcept;
// constexpr bool operator!=(const month& x, const month& y) noexcept;
// constexpr bool operator< (const month& x, const month& y) noexcept;
// constexpr bool operator> (const month& x, const month& y) noexcept;
// constexpr bool operator<=(const month& x, const month& y) noexcept;
// constexpr bool operator>=(const month& x, const month& y) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month = std::chrono::month;
AssertComparisons6AreNoexcept<month>();
AssertComparisons6ReturnBool<month>();
static_assert(testComparisons6Values<month>(0U ,0U), "");
static_assert(testComparisons6Values<month>(0U, 1U), "");
// Some 'ok' values as well
static_assert(testComparisons6Values<month>( 5U, 5U), "");
static_assert(testComparisons6Values<month>( 5U, 10U), "");
for (unsigned i = 1; i < 10; ++i)
for (unsigned j = 10; j < 10; ++j)
assert(testComparisons6Values<month>(i, j));
}

View File

@ -1,87 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// inline constexpr month January{1};
// inline constexpr month February{2};
// inline constexpr month March{3};
// inline constexpr month April{4};
// inline constexpr month May{5};
// inline constexpr month June{6};
// inline constexpr month July{7};
// inline constexpr month August{8};
// inline constexpr month September{9};
// inline constexpr month October{10};
// inline constexpr month November{11};
// inline constexpr month December{12};
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::January));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::February));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::March));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::April));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::May));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::June));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::July));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::August));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::September));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::October));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::November));
ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::December));
static_assert( std::chrono::January == std::chrono::month(1), "");
static_assert( std::chrono::February == std::chrono::month(2), "");
static_assert( std::chrono::March == std::chrono::month(3), "");
static_assert( std::chrono::April == std::chrono::month(4), "");
static_assert( std::chrono::May == std::chrono::month(5), "");
static_assert( std::chrono::June == std::chrono::month(6), "");
static_assert( std::chrono::July == std::chrono::month(7), "");
static_assert( std::chrono::August == std::chrono::month(8), "");
static_assert( std::chrono::September == std::chrono::month(9), "");
static_assert( std::chrono::October == std::chrono::month(10), "");
static_assert( std::chrono::November == std::chrono::month(11), "");
static_assert( std::chrono::December == std::chrono::month(12), "");
assert(std::chrono::January == std::chrono::month(1));
assert(std::chrono::February == std::chrono::month(2));
assert(std::chrono::March == std::chrono::month(3));
assert(std::chrono::April == std::chrono::month(4));
assert(std::chrono::May == std::chrono::month(5));
assert(std::chrono::June == std::chrono::month(6));
assert(std::chrono::July == std::chrono::month(7));
assert(std::chrono::August == std::chrono::month(8));
assert(std::chrono::September == std::chrono::month(9));
assert(std::chrono::October == std::chrono::month(10));
assert(std::chrono::November == std::chrono::month(11));
assert(std::chrono::December == std::chrono::month(12));
assert(static_cast<unsigned>(std::chrono::January) == 1);
assert(static_cast<unsigned>(std::chrono::February) == 2);
assert(static_cast<unsigned>(std::chrono::March) == 3);
assert(static_cast<unsigned>(std::chrono::April) == 4);
assert(static_cast<unsigned>(std::chrono::May) == 5);
assert(static_cast<unsigned>(std::chrono::June) == 6);
assert(static_cast<unsigned>(std::chrono::July) == 7);
assert(static_cast<unsigned>(std::chrono::August) == 8);
assert(static_cast<unsigned>(std::chrono::September) == 9);
assert(static_cast<unsigned>(std::chrono::October) == 10);
assert(static_cast<unsigned>(std::chrono::November) == 11);
assert(static_cast<unsigned>(std::chrono::December) == 12);
}

View File

@ -1,72 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr month operator-(const month& x, const months& y) noexcept;
// Returns: x + -y.
//
// constexpr months operator-(const month& x, const month& y) noexcept;
// Returns: If x.ok() == true and y.ok() == true, returns a value m in the range
// [months{0}, months{11}] satisfying y + m == x.
// Otherwise the value returned is unspecified.
// [Example: January - February == months{11}. —end example]
extern "C" int printf(const char *, ...);
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename M, typename Ms>
constexpr bool testConstexpr()
{
{
M m{5};
Ms offset{3};
if (m - offset != M{2}) return false;
if (m - M{2} != offset) return false;
}
// Check the example
if (M{1} - M{2} != Ms{11}) return false;
return true;
}
#include <iostream>
int main()
{
using month = std::chrono::month;
using months = std::chrono::months;
ASSERT_NOEXCEPT(std::declval<month>() - std::declval<months>());
ASSERT_NOEXCEPT(std::declval<month>() - std::declval<month>());
ASSERT_SAME_TYPE(month , decltype(std::declval<month>() - std::declval<months>()));
ASSERT_SAME_TYPE(months, decltype(std::declval<month>() - std::declval<month> ()));
static_assert(testConstexpr<month, months>(), "");
month m{6};
for (unsigned i = 1; i <= 12; ++i)
{
month m1 = m - months{i};
// months off = m - month {i};
int exp = 6 - i;
if (exp < 1)
exp += 12;
assert(static_cast<unsigned>(m1) == static_cast<unsigned>(exp));
// assert(off.count() == static_cast<unsigned>(exp));
}
}

View File

@ -1,72 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
// constexpr month operator+(const month& x, const months& y) noexcept;
// Returns: month(int{x} + y.count()).
//
// constexpr month operator+(const months& x, const month& y) noexcept;
// Returns:
// month{modulo(static_cast<long long>(int{x}) + (y.count() - 1), 12) + 1}
// where modulo(n, 12) computes the remainder of n divided by 12 using Euclidean division.
// [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
// and always produces a remainder in the range of [0, 11].
// Assuming no overflow in the signed summation, this operation results in a month
// holding a value in the range [1, 12] even if !x.ok(). —end note]
// [Example: February + months{11} == January. —end example]
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename M, typename Ms>
constexpr bool testConstexpr()
{
M m{1};
Ms offset{4};
if (m + offset != M{5}) return false;
if (offset + m != M{5}) return false;
// Check the example
if (M{2} + Ms{11} != M{1}) return false;
return true;
}
int main()
{
using month = std::chrono::month;
using months = std::chrono::months;
ASSERT_NOEXCEPT(std::declval<month>() + std::declval<months>());
ASSERT_NOEXCEPT(std::declval<months>() + std::declval<month>());
ASSERT_SAME_TYPE(month, decltype(std::declval<month>() + std::declval<months>()));
ASSERT_SAME_TYPE(month, decltype(std::declval<months>() + std::declval<month>() ));
static_assert(testConstexpr<month, months>(), "");
month my{2};
for (unsigned i = 0; i <= 15; ++i)
{
month m1 = my + months{i};
month m2 = months{i} + my;
assert(m1 == m2);
unsigned exp = i + 2;
while (exp > 12)
exp -= 12;
assert(static_cast<unsigned>(m1) == exp);
assert(static_cast<unsigned>(m2) == exp);
}
}

View File

@ -1,53 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class month;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const month& m);
//
// Effects: If m.ok() == true inserts format(os.getloc(), fmt, m) where fmt is "%b" widened to charT.
// Otherwise inserts int{m} << " is not a valid month".
//
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month& m);
//
// Effects: Streams m into os using the format specified by the NTCTS fmt.
// fmt encoding follows the rules specified in 25.11.
//
// template<class charT, class traits, class Alloc = allocator<charT>>
// basic_istream<charT, traits>&
// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
// month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
// minutes* offset = nullptr);
//
// Effects: Attempts to parse the input stream is into the month m using the format flags
// given in the NTCTS fmt as specified in 25.12. If the parse fails to decode a valid month,
// is.setstate(ios_- base::failbit) shall be called and m shall not be modified.
// If %Z is used and successfully parsed, that value will be assigned to *abbrev if
// abbrev is non-null. If %z (or a modified variant) is used and successfully parsed,
// that value will be assigned to *offset if offset is non-null.
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
std::cout << month{1};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
static_assert(std::is_trivially_copyable_v<month>, "");
static_assert(std::is_standard_layout_v<month>, "");
}

View File

@ -1,46 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
// month_weekday represents the nth weekday of a month, of an as yet unspecified year.
// constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
// Effects: Constructs an object of type month_weekday by initializing m_ with m, and wdi_ with wdi.
//
// constexpr chrono::month month() const noexcept;
// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
// constexpr bool ok() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
ASSERT_NOEXCEPT(month_weekday{month{1}, weekday_indexed{weekday{}, 1}});
constexpr month_weekday md0{month{}, weekday_indexed{}};
static_assert( md0.month() == month{}, "");
static_assert( md0.weekday_indexed() == weekday_indexed{}, "");
static_assert(!md0.ok(), "");
constexpr month_weekday md1{std::chrono::January, weekday_indexed{std::chrono::Friday, 4}};
static_assert( md1.month() == std::chrono::January, "");
static_assert( md1.weekday_indexed() == weekday_indexed{std::chrono::Friday, 4}, "");
static_assert( md1.ok(), "");
}

View File

@ -1,42 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
// constexpr chrono::month month() const noexcept;
// Returns: wd_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
constexpr weekday Sunday = std::chrono::Sunday;
ASSERT_NOEXCEPT( std::declval<const month_weekday>().month());
ASSERT_SAME_TYPE(month, decltype(std::declval<const month_weekday>().month()));
static_assert( month_weekday{}.month() == month{}, "");
for (unsigned i = 1; i <= 50; ++i)
{
month_weekday md(month{i}, weekday_indexed{Sunday, 1});
assert( static_cast<unsigned>(md.month()) == i);
}
}

View File

@ -1,51 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
// constexpr bool ok() const noexcept;
// Returns: m_.ok() && wdi_.ok().
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
constexpr weekday Sunday = std::chrono::Sunday;
ASSERT_NOEXCEPT( std::declval<const month_weekday>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_weekday>().ok()));
static_assert(!month_weekday{month{}, weekday_indexed{}}.ok(), "");
static_assert( month_weekday{std::chrono::May, weekday_indexed{Sunday, 2}}.ok(), "");
assert(!(month_weekday(std::chrono::April, weekday_indexed{Sunday, 0}).ok()));
assert( (month_weekday{std::chrono::March, weekday_indexed{Sunday, 1}}.ok()));
for (unsigned i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 6; ++j)
{
month_weekday mwd{month{i}, weekday_indexed{Sunday, j}};
assert(mwd.ok() == (j >= 1 && j <= 5));
}
// If the month is not ok, all the weekday_indexed are bad
for (unsigned i = 1; i <= 10; ++i)
assert(!(month_weekday{month{13}, weekday_indexed{Sunday, i}}.ok()));
}

View File

@ -1,43 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
// Returns: wdi_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
constexpr weekday Sunday = std::chrono::Sunday;
ASSERT_NOEXCEPT( std::declval<const month_weekday>().weekday_indexed());
ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<const month_weekday>().weekday_indexed()));
static_assert( month_weekday{month{}, weekday_indexed{}}.weekday_indexed() == weekday_indexed{}, "");
for (unsigned i = 1; i <= 10; ++i)
{
month_weekday md(std::chrono::March, weekday_indexed{Sunday, i});
assert( static_cast<unsigned>(md.weekday_indexed().weekday() == Sunday));
assert( static_cast<unsigned>(md.weekday_indexed().index() == i));
}
}

View File

@ -1,86 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
// constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
// Returns: x.month() == y.month() && x.day() == y.day().
//
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday_indexed = std::chrono::weekday_indexed;
using weekday = std::chrono::weekday;
constexpr weekday Sunday = std::chrono::Sunday;
constexpr weekday Monday = std::chrono::Monday;
AssertComparisons2AreNoexcept<month_weekday>();
AssertComparisons2ReturnBool<month_weekday>();
static_assert( testComparisons2(
month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
true), "");
static_assert( testComparisons2(
month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
month_weekday{std::chrono::January, weekday_indexed{Sunday, 2}},
false), "");
static_assert( testComparisons2(
month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
month_weekday{std::chrono::February, weekday_indexed{Sunday, 1}},
false), "");
static_assert( testComparisons2(
month_weekday{std::chrono::January, weekday_indexed{Monday, 1}},
month_weekday{std::chrono::January, weekday_indexed{Sunday, 2}},
false), "");
static_assert( testComparisons2(
month_weekday{std::chrono::January, weekday_indexed{Monday, 1}},
month_weekday{std::chrono::February, weekday_indexed{Sunday, 1}},
false), "");
// same day, different months
for (unsigned i = 1; i < 12; ++i)
for (unsigned j = 1; j < 12; ++j)
assert((testComparisons2(
month_weekday{month{i}, weekday_indexed{Sunday, 1}},
month_weekday{month{j}, weekday_indexed{Sunday, 1}},
i == j)));
// same month, different weeks
for (unsigned i = 1; i < 5; ++i)
for (unsigned j = 1; j < 5; ++j)
assert((testComparisons2(
month_weekday{month{2}, weekday_indexed{Sunday, i}},
month_weekday{month{2}, weekday_indexed{Sunday, j}},
i == j)));
// same month, different days
for (unsigned i = 0; i < 6; ++i)
for (unsigned j = 0; j < 6; ++j)
assert((testComparisons2(
month_weekday{month{2}, weekday_indexed{weekday{i}, 2}},
month_weekday{month{2}, weekday_indexed{weekday{j}, 2}},
i == j)));
}

View File

@ -1,36 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class month_weekday;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
//
// Returns: os << mwd.month() << '/' << mwd.weekday_indexed().
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday_indexed = std::chrono::weekday_indexed;
using weekday = std::chrono::weekday;
std::cout << month_weekday{month{1}, weekday_indexed{weekday{3}, 3}};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
static_assert(std::is_trivially_copyable_v<month_weekday>, "");
static_assert(std::is_standard_layout_v<month_weekday>, "");
}

View File

@ -1,60 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
// constexpr month_weekday_last(const chrono::month& m,
// const chrono::weekday_last& wdl) noexcept;
//
// Effects: Constructs an object of type month_weekday_last by
// initializing m_ with m, and wdl_ with wdl.
//
// constexpr chrono::month month() const noexcept;
// constexpr chrono::weekday_last weekday_last() const noexcept;
// constexpr bool ok() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using month_weekday_last = std::chrono::month_weekday_last;
constexpr month January = std::chrono::January;
constexpr weekday Tuesday = std::chrono::Tuesday;
ASSERT_NOEXCEPT(month_weekday_last{January, weekday_last{Tuesday}});
// bad month
constexpr month_weekday_last mwdl1{month{}, weekday_last{Tuesday}};
static_assert( mwdl1.month() == month{}, "");
static_assert( mwdl1.weekday_last() == weekday_last{Tuesday}, "");
static_assert(!mwdl1.ok(), "");
// bad weekday_last
constexpr month_weekday_last mwdl2{January, weekday_last{weekday{16}}};
static_assert( mwdl2.month() == January, "");
static_assert( mwdl2.weekday_last() == weekday_last{weekday{16}}, "");
static_assert(!mwdl2.ok(), "");
// Good month and weekday_last
constexpr month_weekday_last mwdl3{January, weekday_last{weekday{4}}};
static_assert( mwdl3.month() == January, "");
static_assert( mwdl3.weekday_last() == weekday_last{weekday{4}}, "");
static_assert( mwdl3.ok(), "");
}

View File

@ -1,42 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
// constexpr chrono::month month() const noexcept;
// Returns: m_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using month_weekday_last = std::chrono::month_weekday_last;
constexpr weekday Tuesday = std::chrono::Tuesday;
ASSERT_NOEXCEPT( std::declval<const month_weekday_last>().month());
ASSERT_SAME_TYPE(month, decltype(std::declval<const month_weekday_last>().month()));
static_assert( month_weekday_last{month{}, weekday_last{Tuesday}}.month() == month{}, "");
for (unsigned i = 1; i <= 50; ++i)
{
month_weekday_last mdl(month{i}, weekday_last{Tuesday});
assert( static_cast<unsigned>(mdl.month()) == i);
}
}

View File

@ -1,52 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
// constexpr bool ok() const noexcept;
// Returns: m_.ok() && wdl_.ok().
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using month_weekday_last = std::chrono::month_weekday_last;
constexpr month January = std::chrono::January;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr weekday_last lastTuesday = weekday_last{Tuesday};
ASSERT_NOEXCEPT( std::declval<const month_weekday_last>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_weekday_last>().ok()));
static_assert(!month_weekday_last{month{}, lastTuesday}.ok(), ""); // Bad month
static_assert(!month_weekday_last{January, weekday_last{weekday{12}}}.ok(), ""); // Bad month
static_assert( month_weekday_last{January, lastTuesday}.ok(), ""); // Both OK
for (unsigned i = 0; i <= 50; ++i)
{
month_weekday_last mwdl{month{i}, lastTuesday};
assert( mwdl.ok() == month{i}.ok());
}
for (unsigned i = 0; i <= 50; ++i)
{
month_weekday_last mwdl{January, weekday_last{weekday{i}}};
assert( mwdl.ok() == weekday_last{weekday{i}}.ok());
}
}

View File

@ -1,44 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
// constexpr chrono::weekday_last weekday_last() const noexcept;
// Returns: wdl_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using month_weekday_last = std::chrono::month_weekday_last;
constexpr month January = std::chrono::January;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr weekday_last lastTuesday = weekday_last{Tuesday};
ASSERT_NOEXCEPT( std::declval<const month_weekday_last>().weekday_last());
ASSERT_SAME_TYPE(weekday_last, decltype(std::declval<const month_weekday_last>().weekday_last()));
static_assert( month_weekday_last{month{}, lastTuesday}.weekday_last() == lastTuesday, "");
for (unsigned i = 1; i <= 50; ++i)
{
month_weekday_last mdl(January, weekday_last{weekday{i}});
assert( static_cast<unsigned>(mdl.weekday_last().weekday()) == i);
}
}

View File

@ -1,73 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
// constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
// Returns: x.month() == y.month()
//
// constexpr bool operator< (const month_weekday_last& x, const month_weekday_last& y) noexcept;
// Returns: x.month() < y.month()
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month = std::chrono::month;
using weekday_last = std::chrono::weekday_last;
using weekday = std::chrono::weekday;
using month_weekday_last = std::chrono::month_weekday_last;
constexpr month January = std::chrono::January;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr weekday Wednesday = std::chrono::Wednesday;
AssertComparisons2AreNoexcept<month_weekday_last>();
AssertComparisons2ReturnBool<month_weekday_last>();
static_assert( testComparisons2(
month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
true), "");
static_assert( testComparisons2(
month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
month_weekday_last{std::chrono::January, weekday_last{Wednesday}},
false), "");
// vary the months
for (unsigned i = 1; i < 12; ++i)
for (unsigned j = 1; j < 12; ++j)
assert((testComparisons2(
month_weekday_last{month{i}, weekday_last{Tuesday}},
month_weekday_last{month{j}, weekday_last{Tuesday}},
i == j)));
// vary the weekday
for (unsigned i = 0; i < 6; ++i)
for (unsigned j = 0; j < 6; ++j)
assert((testComparisons2(
month_weekday_last{January, weekday_last{weekday{i}}},
month_weekday_last{January, weekday_last{weekday{j}}},
i == j)));
// both different
assert((testComparisons2(
month_weekday_last{month{1}, weekday_last{weekday{1}}},
month_weekday_last{month{2}, weekday_last{weekday{2}}},
false)));
}

View File

@ -1,37 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class month_weekday_last;
//
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mdl);
//
// Returns: os << mdl.month() << "/last".
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using month_weekday_last = std::chrono::month_weekday_last;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
std::cout << month_weekday_last{month{1}, weekday_last{weekday{3}}};
}

View File

@ -1,27 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using month_weekday_last = std::chrono::month_weekday_last;
static_assert(std::is_trivially_copyable_v<month_weekday_last>, "");
static_assert(std::is_standard_layout_v<month_weekday_last>, "");
}

View File

@ -1,108 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day;
// constexpr month_day
// operator/(const month& m, const day& d) noexcept;
// Returns: {m, d}.
//
// constexpr month_day
// operator/(const day& d, const month& m) noexcept;
// Returns: m / d.
// constexpr month_day
// operator/(const month& m, int d) noexcept;
// Returns: m / day(d).
//
// constexpr month_day
// operator/(int m, const day& d) noexcept;
// Returns: month(m) / d.
//
// constexpr month_day
// operator/(const day& d, int m) noexcept;
// Returns: month(m) / d.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month_day = std::chrono::month_day;
using month = std::chrono::month;
using day = std::chrono::day;
constexpr month February = std::chrono::February;
{ // operator/(const month& m, const day& d) (and switched)
ASSERT_NOEXCEPT ( February/day{1});
ASSERT_SAME_TYPE(month_day, decltype(February/day{1}));
ASSERT_NOEXCEPT ( day{1}/February);
ASSERT_SAME_TYPE(month_day, decltype(day{1}/February));
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 30; ++j)
{
month m(i);
day d{j};
month_day md1 = m/d;
month_day md2 = d/m;
assert(md1.month() == m);
assert(md1.day() == d);
assert(md2.month() == m);
assert(md2.day() == d);
assert(md1 == md2);
}
}
{ // operator/(const month& m, int d) (NOT switched)
ASSERT_NOEXCEPT ( February/2);
ASSERT_SAME_TYPE(month_day, decltype(February/2));
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 30; ++j)
{
month m(i);
day d(j);
month_day md1 = m/j;
assert(md1.month() == m);
assert(md1.day() == d);
}
}
{ // operator/(const day& d, int m) (and switched)
ASSERT_NOEXCEPT ( day{2}/2);
ASSERT_SAME_TYPE(month_day, decltype(day{2}/2));
ASSERT_NOEXCEPT ( 2/day{2});
ASSERT_SAME_TYPE(month_day, decltype(2/day{2}));
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 30; ++j)
{
month m(i);
day d(j);
month_day md1 = d/i;
month_day md2 = i/d;
assert(md1.month() == m);
assert(md1.day() == d);
assert(md2.month() == m);
assert(md2.day() == d);
assert(md1 == md2);
}
}
}

View File

@ -1,107 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_day_last;
// constexpr month_day_last
// operator/(const month& m, last_spec) noexcept;
// Returns: month_day_last{m}.
//
// constexpr month_day_last
// operator/(int m, last_spec) noexcept;
// Returns: month(m) / last.
//
// constexpr month_day_last
// operator/(last_spec, const month& m) noexcept;
// Returns: m / last.
//
// constexpr month_day_last
// operator/(last_spec, int m) noexcept;
// Returns: month(m) / last.
//
//
// [Note: A month_day_last object can be constructed using the expression m/last or last/m,
// where m is an expression of type month. — end note]
// [Example:
// constexpr auto mdl = February/last; // mdl is the last day of February of an as yet unspecified year
// static_assert(mdl.month() == February);
// --end example]
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month = std::chrono::month;
using month_day_last = std::chrono::month_day_last;
constexpr month February = std::chrono::February;
constexpr std::chrono::last_spec last = std::chrono::last;
ASSERT_SAME_TYPE(month_day_last, decltype(last/February));
ASSERT_SAME_TYPE(month_day_last, decltype(February/last));
// Run the example
{
constexpr auto mdl = February/std::chrono::last;
static_assert(mdl.month() == February, "");
}
{ // operator/(const month& m, last_spec) and switched
ASSERT_NOEXCEPT ( last/February);
ASSERT_SAME_TYPE(month_day_last, decltype(last/February));
ASSERT_NOEXCEPT ( February/last);
ASSERT_SAME_TYPE(month_day_last, decltype(February/last));
static_assert((last/February).month() == February, "");
static_assert((February/last).month() == February, "");
for (unsigned i = 1; i < 12; ++i)
{
month m{i};
month_day_last mdl1 = last/m;
month_day_last mdl2 = m/last;
assert(mdl1.month() == m);
assert(mdl2.month() == m);
assert(mdl1 == mdl2);
}
}
{ // operator/(int, last_spec) and switched
ASSERT_NOEXCEPT ( last/2);
ASSERT_SAME_TYPE(month_day_last, decltype(last/2));
ASSERT_NOEXCEPT ( 2/last);
ASSERT_SAME_TYPE(month_day_last, decltype(2/last));
static_assert((last/2).month() == February, "");
static_assert((2/last).month() == February, "");
for (unsigned i = 1; i < 12; ++i)
{
month m{i};
month_day_last mdl1 = last/i;
month_day_last mdl2 = i/last;
assert(mdl1.month() == m);
assert(mdl2.month() == m);
assert(mdl1 == mdl2);
}
}
}

View File

@ -1,115 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday;
// constexpr month_weekday
// operator/(const month& m, const weekday_indexed& wdi) noexcept;
// Returns: {m, wdi}.
//
// constexpr month_weekday
// operator/(int m, const weekday_indexed& wdi) noexcept;
// Returns: month(m) / wdi.
//
// constexpr month_weekday
// operator/(const weekday_indexed& wdi, const month& m) noexcept;
// Returns: m / wdi. constexpr month_weekday
//
// constexpr month_weekday
// operator/(const weekday_indexed& wdi, int m) noexcept;
// Returns: month(m) / wdi.
//
// [Example:
// constexpr auto mwd = February/Tuesday[3]; // mwd is the third Tuesday of February of an as yet unspecified year
// static_assert(mwd.month() == February);
// static_assert(mwd.weekday_indexed() == Tuesday[3]);
// —end example]
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr month February = std::chrono::February;
{ // operator/(const month& m, const weekday_indexed& wdi) (and switched)
ASSERT_NOEXCEPT (February/Tuesday[2]);
ASSERT_SAME_TYPE(month_weekday, decltype(February/Tuesday[2]));
ASSERT_NOEXCEPT (Tuesday[2]/February);
ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/February));
// Run the example
{
constexpr month_weekday wdi = February/Tuesday[3];
static_assert(wdi.month() == February, "");
static_assert(wdi.weekday_indexed() == Tuesday[3], "");
}
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 6; ++j)
for (unsigned k = 1; k <= 5; ++k)
{
month m(i);
weekday_indexed wdi = weekday{j}[k];
month_weekday mwd1 = m/wdi;
month_weekday mwd2 = wdi/m;
assert(mwd1.month() == m);
assert(mwd1.weekday_indexed() == wdi);
assert(mwd2.month() == m);
assert(mwd2.weekday_indexed() == wdi);
assert(mwd1 == mwd2);
}
}
{ // operator/(int m, const weekday_indexed& wdi) (and switched)
ASSERT_NOEXCEPT (2/Tuesday[2]);
ASSERT_SAME_TYPE(month_weekday, decltype(2/Tuesday[2]));
ASSERT_NOEXCEPT (Tuesday[2]/2);
ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/2));
// Run the example
{
constexpr month_weekday wdi = 2/Tuesday[3];
static_assert(wdi.month() == February, "");
static_assert(wdi.weekday_indexed() == Tuesday[3], "");
}
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 6; ++j)
for (unsigned k = 1; k <= 5; ++k)
{
weekday_indexed wdi = weekday{j}[k];
month_weekday mwd1 = i/wdi;
month_weekday mwd2 = wdi/i;
assert(mwd1.month() == month(i));
assert(mwd1.weekday_indexed() == wdi);
assert(mwd2.month() == month(i));
assert(mwd2.weekday_indexed() == wdi);
assert(mwd1 == mwd2);
}
}
}

View File

@ -1,107 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class month_weekday_last;
// constexpr month_weekday_last
// operator/(const month& m, const weekday_last& wdl) noexcept;
// Returns: {m, wdl}.
//
// constexpr month_weekday_last
// operator/(int m, const weekday_last& wdl) noexcept;
// Returns: month(m) / wdl.
//
// constexpr month_weekday_last
// operator/(const weekday_last& wdl, const month& m) noexcept;
// Returns: m / wdl.
//
// constexpr month_weekday_last
// operator/(const weekday_last& wdl, int m) noexcept;
// Returns: month(m) / wdl.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using month_weekday_last = std::chrono::month_weekday_last;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr month February = std::chrono::February;
constexpr std::chrono::last_spec last = std::chrono::last;
{ // operator/(const month& m, const weekday_last& wdi) (and switched)
ASSERT_NOEXCEPT (February/Tuesday[last]);
ASSERT_SAME_TYPE(month_weekday_last, decltype(February/Tuesday[last]));
ASSERT_NOEXCEPT (Tuesday[last]/February);
ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/February));
// Run the example
{
constexpr month_weekday_last wdi = February/Tuesday[last];
static_assert(wdi.month() == February, "");
static_assert(wdi.weekday_last() == Tuesday[last], "");
}
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 6; ++j)
{
month m(i);
weekday_last wdi = weekday{j}[last];
month_weekday_last mwd1 = m/wdi;
month_weekday_last mwd2 = wdi/m;
assert(mwd1.month() == m);
assert(mwd1.weekday_last() == wdi);
assert(mwd2.month() == m);
assert(mwd2.weekday_last() == wdi);
assert(mwd1 == mwd2);
}
}
{ // operator/(int m, const weekday_last& wdi) (and switched)
ASSERT_NOEXCEPT (2/Tuesday[2]);
ASSERT_SAME_TYPE(month_weekday_last, decltype(2/Tuesday[last]));
ASSERT_NOEXCEPT (Tuesday[2]/2);
ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/2));
// Run the example
{
constexpr month_weekday wdi = 2/Tuesday[3];
static_assert(wdi.month() == February, "");
static_assert(wdi.weekday_indexed() == Tuesday[3], "");
}
for (int i = 1; i <= 12; ++i)
for (unsigned j = 0; j <= 6; ++j)
{
weekday_last wdi = weekday{j}[last];
month_weekday_last mwd1 = i/wdi;
month_weekday_last mwd2 = wdi/i;
assert(mwd1.month() == month(i));
assert(mwd1.weekday_last() == wdi);
assert(mwd2.month() == month(i));
assert(mwd2.weekday_last() == wdi);
assert(mwd1 == mwd2);
}
}
}

View File

@ -1,68 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year_month;
// constexpr year_month operator/(const year& y, const month& m) noexcept;
// Returns: {y, m}.
//
// constexpr year_month operator/(const year& y, int m) noexcept;
// Returns: y / month(m).
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month = std::chrono::month;
using year = std::chrono::year;
using year_month = std::chrono::year_month;
constexpr month February = std::chrono::February;
{ // operator/(const year& y, const month& m)
ASSERT_NOEXCEPT ( year{2018}/February);
ASSERT_SAME_TYPE(year_month, decltype(year{2018}/February));
static_assert((year{2018}/February).year() == year{2018}, "");
static_assert((year{2018}/February).month() == month{2}, "");
for (int i = 1000; i <= 1030; ++i)
for (unsigned j = 1; j <= 12; ++j)
{
year_month ym = year{i}/month{j};
assert(static_cast<int>(ym.year()) == i);
assert(static_cast<unsigned>(ym.month()) == j);
}
}
{ // operator/(const year& y, const int m)
ASSERT_NOEXCEPT ( year{2018}/4);
ASSERT_SAME_TYPE(year_month, decltype(year{2018}/4));
static_assert((year{2018}/2).year() == year{2018}, "");
static_assert((year{2018}/2).month() == month{2}, "");
for (int i = 1000; i <= 1030; ++i)
for (unsigned j = 1; j <= 12; ++j)
{
year_month ym = year{i}/j;
assert(static_cast<int>(ym.year()) == i);
assert(static_cast<unsigned>(ym.month()) == j);
}
}
}

View File

@ -1,192 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year_month_day;
// constexpr year_month_day
// operator/(const year_month& ym, const day& d) noexcept;
// Returns: {ym.year(), ym.month(), d}.
//
// constexpr year_month_day
// operator/(const year_month& ym, int d) noexcept;
// Returns: ym / day(d).
//
// constexpr year_month_day
// operator/(const year& y, const month_day& md) noexcept;
// Returns: y / md.month() / md.day().
//
// constexpr year_month_day
// operator/(int y, const month_day& md) noexcept;
// Returns: year(y) / md.
//
// constexpr year_month_day
// operator/(const month_day& md, const year& y) noexcept;
// Returns: y / md.
//
// constexpr year_month_day
// operator/(const month_day& md, int y) noexcept;
// Returns: year(y) / md.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using year_month = std::chrono::year_month;
using month_day = std::chrono::month_day;
using year_month_day = std::chrono::year_month_day;
using weekday = std::chrono::weekday;
constexpr month February = std::chrono::February;
constexpr year_month Feb2018{year{2018}, February};
{ // operator/(const year_month& ym, const day& d)
ASSERT_NOEXCEPT ( Feb2018/day{2});
ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/day{2}));
static_assert((Feb2018/day{2}).month() == February, "");
static_assert((Feb2018/day{2}).day() == day{2}, "");
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 28; ++k)
{
year y(i);
month m(j);
day d(k);
year_month ym(y, m);
year_month_day ymd = ym/d;
assert(ymd.year() == y);
assert(ymd.month() == m);
assert(ymd.day() == d);
}
}
{ // operator/(const year_month& ym, int d)
ASSERT_NOEXCEPT ( Feb2018/2);
ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
static_assert((Feb2018/2).month() == February, "");
static_assert((Feb2018/2).day() == day{2}, "");
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 28; ++k)
{
year y(i);
month m(j);
day d(k);
year_month ym(y, m);
year_month_day ymd = ym/k;
assert(ymd.year() == y);
assert(ymd.month() == m);
assert(ymd.day() == d);
}
}
{ // operator/(const year_month& ym, int d)
ASSERT_NOEXCEPT ( Feb2018/2);
ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
static_assert((Feb2018/2).month() == February, "");
static_assert((Feb2018/2).day() == day{2}, "");
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 28; ++k)
{
year y(i);
month m(j);
day d(k);
year_month ym(y, m);
year_month_day ymd = ym/k;
assert(ymd.year() == y);
assert(ymd.month() == m);
assert(ymd.day() == d);
}
}
{ // operator/(const year& y, const month_day& md) (and switched)
ASSERT_NOEXCEPT ( year{2018}/month_day{February, day{2}});
ASSERT_SAME_TYPE(year_month_day, decltype(year{2018}/month_day{February, day{2}}));
ASSERT_NOEXCEPT ( month_day{February, day{2}}/year{2018});
ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/year{2018}));
static_assert((year{2018}/month_day{February, day{2}}).month() == February, "" );
static_assert((year{2018}/month_day{February, day{2}}).day() == day{2}, "" );
static_assert((month_day{February, day{2}}/year{2018}).month() == February, "" );
static_assert((month_day{February, day{2}}/year{2018}).day() == day{2}, "" );
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 28; ++k)
{
year y(i);
month m(j);
day d(k);
month_day md(m, d);
year_month_day ymd1 = y/md;
year_month_day ymd2 = md/y;
assert(ymd1.year() == y);
assert(ymd2.year() == y);
assert(ymd1.month() == m);
assert(ymd2.month() == m);
assert(ymd1.day() == d);
assert(ymd2.day() == d);
assert(ymd1 == ymd2);
}
}
{ // operator/(const month_day& md, int y) (and switched)
ASSERT_NOEXCEPT ( 2018/month_day{February, day{2}});
ASSERT_SAME_TYPE(year_month_day, decltype(2018/month_day{February, day{2}}));
ASSERT_NOEXCEPT ( month_day{February, day{2}}/2018);
ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/2018));
static_assert((2018/month_day{February, day{2}}).month() == February, "" );
static_assert((2018/month_day{February, day{2}}).day() == day{2}, "" );
static_assert((month_day{February, day{2}}/2018).month() == February, "" );
static_assert((month_day{February, day{2}}/2018).day() == day{2}, "" );
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 28; ++k)
{
year y(i);
month m(j);
day d(k);
month_day md(m, d);
year_month_day ymd1 = i/md;
year_month_day ymd2 = md/i;
assert(ymd1.year() == y);
assert(ymd2.year() == y);
assert(ymd1.month() == m);
assert(ymd2.month() == m);
assert(ymd1.day() == d);
assert(ymd2.day() == d);
assert(ymd1 == ymd2);
}
}
}

View File

@ -1,129 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year_month_day_last;
// constexpr year_month_day_last
// operator/(const year_month& ym, last_spec) noexcept;
// Returns: {ym.year(), month_day_last{ym.month()}}.
// constexpr year_month_day_last
// operator/(const year& y, const month_day_last& mdl) noexcept;
// Returns: {y, mdl}.
//
// constexpr year_month_day_last
// operator/(int y, const month_day_last& mdl) noexcept;
// Returns: year(y) / mdl.
//
// constexpr year_month_day_last
// operator/(const month_day_last& mdl, const year& y) noexcept;
// Returns: y / mdl.
//
// constexpr year_month_day_last
// operator/(const month_day_last& mdl, int y) noexcept;
// Returns: year(y) / mdl.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using year_month = std::chrono::year_month;
using year = std::chrono::year;
using weekday_last = std::chrono::weekday_last;
using weekday = std::chrono::weekday;
using month_weekday_last = std::chrono::month_weekday_last;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;
constexpr month February = std::chrono::February;
constexpr std::chrono::last_spec last = std::chrono::last;
{ // operator/(const year_month& ym, last_spec)
constexpr year_month Feb2018{year{2018}, February};
ASSERT_NOEXCEPT ( Feb2018/last);
ASSERT_SAME_TYPE(year_month_day_last, decltype(Feb2018/last));
static_assert((Feb2018/last).year() == year{2018}, "");
static_assert((Feb2018/last).month() == February, "");
for (int i = 1000; i < 1010; ++i)
for (unsigned j = 1; j <= 12; ++j)
{
year y{i};
month m{j};
year_month_day_last ymdl = year_month{y,m}/last;
assert(ymdl.year() == y);
assert(ymdl.month() == m);
}
}
{ // operator/(const year& y, const month_day_last& mdl) (and switched)
ASSERT_NOEXCEPT ( year{2018}/month_day_last{February});
ASSERT_SAME_TYPE(year_month_day_last, decltype(year{2018}/month_day_last{February}));
ASSERT_NOEXCEPT ( month_day_last{February}/year{2018});
ASSERT_SAME_TYPE(year_month_day_last, decltype(month_day_last{February}/year{2018}));
static_assert((year{2018}/month_day_last{February}).month() == February, "");
static_assert((year{2018}/month_day_last{February}).year() == year{2018}, "");
static_assert((month_day_last{February}/year{2018}).month() == February, "");
static_assert((month_day_last{February}/year{2018}).year() == year{2018}, "");
for (int i = 1000; i < 1010; ++i)
for (unsigned j = 1; j <= 12; ++j)
{
year y{i};
month m{j};
year_month_day_last ymdl1 = y/month_day_last{m};
year_month_day_last ymdl2 = month_day_last{m}/y;
assert(ymdl1.month() == m);
assert(ymdl2.month() == m);
assert(ymdl2.year() == y);
assert(ymdl1.year() == y);
assert(ymdl1 == ymdl2);
}
}
{ // operator/(int y, const month_day_last& mdl) (and switched)
ASSERT_NOEXCEPT ( 2018/month_day_last{February});
ASSERT_SAME_TYPE(year_month_day_last, decltype(2018/month_day_last{February}));
ASSERT_NOEXCEPT ( month_day_last{February}/2018);
ASSERT_SAME_TYPE(year_month_day_last, decltype(month_day_last{February}/2018));
static_assert((2018/month_day_last{February}).month() == February, "");
static_assert((2018/month_day_last{February}).year() == year{2018}, "");
static_assert((month_day_last{February}/2018).month() == February, "");
static_assert((month_day_last{February}/2018).year() == year{2018}, "");
for (int i = 1000; i < 1010; ++i)
for (unsigned j = 1; j <= 12; ++j)
{
year y{i};
month m{j};
year_month_day_last ymdl1 = i/month_day_last{m};
year_month_day_last ymdl2 = month_day_last{m}/i;
assert(ymdl1.month() == m);
assert(ymdl2.month() == m);
assert(ymdl2.year() == y);
assert(ymdl1.year() == y);
assert(ymdl1 == ymdl2);
}
}
}

View File

@ -1,145 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year_month_weekday;
// constexpr year_month_weekday
// operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
// Returns: {ym.year(), ym.month(), wdi}.
//
// constexpr year_month_weekday
// operator/(const year& y, const month_weekday& mwd) noexcept;
// Returns: {y, mwd.month(), mwd.weekday_indexed()}.
//
// constexpr year_month_weekday
// operator/(int y, const month_weekday& mwd) noexcept;
// Returns: year(y) / mwd.
//
// constexpr year_month_weekday
// operator/(const month_weekday& mwd, const year& y) noexcept;
// Returns: y / mwd.
//
// constexpr year_month_weekday
// operator/(const month_weekday& mwd, int y) noexcept;
// Returns: year(y) / mwd.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using year = std::chrono::year;
using year_month = std::chrono::year_month;
using month_weekday = std::chrono::month_weekday;
using year_month_weekday = std::chrono::year_month_weekday;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr month February = std::chrono::February;
{ // operator/(const year_month& ym, const weekday_indexed& wdi)
constexpr year_month Feb2018{year{2018}, February};
ASSERT_NOEXCEPT ( Feb2018/weekday_indexed{Tuesday, 2});
ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb2018/weekday_indexed{Tuesday, 2}));
static_assert((Feb2018/weekday_indexed{Tuesday, 2}).year() == year{2018}, "" );
static_assert((Feb2018/weekday_indexed{Tuesday, 2}).month() == February, "" );
static_assert((Feb2018/weekday_indexed{Tuesday, 2}).weekday() == Tuesday, "" );
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 6; ++k)
for (unsigned l = 1; l <= 5; ++l)
{
year y(i);
month m(j);
weekday wd{k};
year_month_weekday ymd = year_month{y,m}/weekday_indexed{wd,l};
assert(ymd.year() == y);
assert(ymd.month() == m);
assert(ymd.weekday() == wd);
}
}
{ // operator/(const year& y, const month_weekday& mwd) (and switched)
constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
ASSERT_NOEXCEPT ( year{2018}/Feb1stTues);
ASSERT_SAME_TYPE(year_month_weekday, decltype(year{2018}/Feb1stTues));
ASSERT_NOEXCEPT ( Feb1stTues/year{2018});
ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/year{2018}));
static_assert((year{2018}/Feb1stTues).year() == year{2018}, "" );
static_assert((year{2018}/Feb1stTues).month() == February, "" );
static_assert((year{2018}/Feb1stTues).weekday() == Tuesday, "" );
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 6; ++k)
for (unsigned l = 1; l <= 5; ++l)
{
year y(i);
month m(j);
weekday wd{k};
month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
year_month_weekday ymd1 = y/mwd;
year_month_weekday ymd2 = mwd/y;
assert(ymd1.year() == y);
assert(ymd2.year() == y);
assert(ymd1.month() == m);
assert(ymd2.month() == m);
assert(ymd1.weekday() == wd);
assert(ymd2.weekday() == wd);
assert(ymd1 == ymd2);
}
}
{ // operator/(int y, const month_weekday& mwd) (and switched)
constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
ASSERT_NOEXCEPT ( 2018/Feb1stTues);
ASSERT_SAME_TYPE(year_month_weekday, decltype(2018/Feb1stTues));
ASSERT_NOEXCEPT ( Feb1stTues/2018);
ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/2018));
static_assert((2018/Feb1stTues).year() == year{2018}, "" );
static_assert((2018/Feb1stTues).month() == February, "" );
static_assert((2018/Feb1stTues).weekday() == Tuesday, "" );
for (int i = 1000; i < 1010; ++i)
for (int j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 6; ++k)
for (unsigned l = 1; l <= 5; ++l)
{
year y(i);
month m(j);
weekday wd{k};
month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
year_month_weekday ymd1 = i/mwd;
year_month_weekday ymd2 = mwd/i;
assert(ymd1.year() == y);
assert(ymd2.year() == y);
assert(ymd1.month() == m);
assert(ymd2.month() == m);
assert(ymd1.weekday() == wd);
assert(ymd2.weekday() == wd);
assert(ymd1 == ymd2);
}
}
}

View File

@ -1,154 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year_month_weekday_last;
// constexpr year_month_weekday_last
// operator/(const year_month& ym, const weekday_last& wdl) noexcept;
// Returns: {ym.year(), ym.month(), wdl}.
//
// constexpr year_month_weekday_last
// operator/(const year& y, const month_weekday_last& mwdl) noexcept;
// Returns: {y, mwdl.month(), mwdl.weekday_last()}.
//
// constexpr year_month_weekday_last
// operator/(int y, const month_weekday_last& mwdl) noexcept;
// Returns: year(y) / mwdl.
//
// constexpr year_month_weekday_last
// operator/(const month_weekday_last& mwdl, const year& y) noexcept;
// Returns: y / mwdl.
//
// constexpr year_month_weekday_last
// operator/(const month_weekday_last& mwdl, int y) noexcept;
// Returns: year(y) / mwdl.
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using year_month = std::chrono::year_month;
using month_weekday = std::chrono::month_weekday;
using year = std::chrono::year;
using month = std::chrono::month;
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using month_weekday_last = std::chrono::month_weekday_last;
using year_month_weekday_last = std::chrono::year_month_weekday_last;
constexpr weekday Tuesday = std::chrono::Tuesday;
constexpr month February = std::chrono::February;
{ // operator/(const year_month& ym, const weekday_last& wdl) (and switched)
constexpr year_month Feb2018{year{2018}, February};
ASSERT_NOEXCEPT ( Feb2018/weekday_last{Tuesday});
ASSERT_SAME_TYPE(year_month_weekday_last, decltype(Feb2018/weekday_last{Tuesday}));
static_assert((Feb2018/weekday_last{Tuesday}).year() == year{2018}, "");
static_assert((Feb2018/weekday_last{Tuesday}).month() == February, "");
static_assert((Feb2018/weekday_last{Tuesday}).weekday() == Tuesday, "");
for (int i = 1000; i < 1010; ++i)
for (unsigned j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 6; ++k)
{
year y{i};
month m{j};
weekday wd{k};
year_month_weekday_last ymwdl = year_month{y,m}/weekday_last{wd};
assert(ymwdl.year() == y);
assert(ymwdl.month() == m);
assert(ymwdl.weekday() == wd);
}
}
{ // operator/(const year& y, const month_weekday_last& mwdl) (and switched)
constexpr month_weekday_last FebLastTues{February, weekday_last{Tuesday}};
ASSERT_NOEXCEPT ( year{2018}/FebLastTues);
ASSERT_SAME_TYPE(year_month_weekday_last, decltype(year{2018}/FebLastTues));
ASSERT_NOEXCEPT ( FebLastTues/year{2018});
ASSERT_SAME_TYPE(year_month_weekday_last, decltype(FebLastTues/year{2018}));
static_assert((year{2018}/FebLastTues).year() == year{2018}, "");
static_assert((year{2018}/FebLastTues).month() == February, "");
static_assert((year{2018}/FebLastTues).weekday() == Tuesday, "");
static_assert((FebLastTues/year{2018}).year() == year{2018}, "");
static_assert((FebLastTues/year{2018}).month() == February, "");
static_assert((FebLastTues/year{2018}).weekday() == Tuesday, "");
for (int i = 1000; i < 1010; ++i)
for (unsigned j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 6; ++k)
{
year y{i};
month m{j};
weekday wd{k};
year_month_weekday_last ymwdl1 = y/month_weekday_last{m, weekday_last{wd}};
year_month_weekday_last ymwdl2 = month_weekday_last{m, weekday_last{wd}}/y;
assert(ymwdl1.year() == y);
assert(ymwdl2.year() == y);
assert(ymwdl1.month() == m);
assert(ymwdl2.month() == m);
assert(ymwdl1.weekday() == wd);
assert(ymwdl2.weekday() == wd);
assert(ymwdl1 == ymwdl2);
}
}
{ // operator/(int y, const month_weekday_last& mwdl) (and switched)
constexpr month_weekday_last FebLastTues{February, weekday_last{Tuesday}};
ASSERT_NOEXCEPT ( 2018/FebLastTues);
ASSERT_SAME_TYPE(year_month_weekday_last, decltype(2018/FebLastTues));
ASSERT_NOEXCEPT ( FebLastTues/2018);
ASSERT_SAME_TYPE(year_month_weekday_last, decltype(FebLastTues/2018));
static_assert((2018/FebLastTues).year() == year{2018}, "");
static_assert((2018/FebLastTues).month() == February, "");
static_assert((2018/FebLastTues).weekday() == Tuesday, "");
static_assert((FebLastTues/2018).year() == year{2018}, "");
static_assert((FebLastTues/2018).month() == February, "");
static_assert((FebLastTues/2018).weekday() == Tuesday, "");
for (int i = 1000; i < 1010; ++i)
for (unsigned j = 1; j <= 12; ++j)
for (unsigned k = 0; k <= 6; ++k)
{
year y{i};
month m{j};
weekday wd{k};
year_month_weekday_last ymwdl1 = i/month_weekday_last{m, weekday_last{wd}};
year_month_weekday_last ymwdl2 = month_weekday_last{m, weekday_last{wd}}/i;
assert(ymwdl1.year() == y);
assert(ymwdl2.year() == y);
assert(ymwdl1.month() == m);
assert(ymwdl2.month() == m);
assert(ymwdl1.weekday() == wd);
assert(ymwdl2.weekday() == wd);
assert(ymwdl1 == ymwdl2);
}
}
}

View File

@ -1,61 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_indexed;
// weekday_indexed() = default;
// constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
//
// Effects: Constructs an object of type weekday_indexed by initializing wd_ with wd and index_ with index.
// The values held are unspecified if !wd.ok() or index is not in the range [1, 5].
//
// constexpr chrono::weekday weekday() const noexcept;
// constexpr unsigned index() const noexcept;
// constexpr bool ok() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
ASSERT_NOEXCEPT(weekday_indexed{});
ASSERT_NOEXCEPT(weekday_indexed(weekday{1}, 1));
constexpr weekday_indexed wdi0{};
static_assert( wdi0.weekday() == weekday{}, "");
static_assert( wdi0.index() == 0, "");
static_assert(!wdi0.ok(), "");
constexpr weekday_indexed wdi1{std::chrono::Sunday, 2};
static_assert( wdi1.weekday() == std::chrono::Sunday, "");
static_assert( wdi1.index() == 2, "");
static_assert( wdi1.ok(), "");
for (unsigned i = 1; i <= 5; ++i)
{
weekday_indexed wdi(std::chrono::Tuesday, i);
assert( wdi.weekday() == std::chrono::Tuesday);
assert( wdi.index() == i);
assert( wdi.ok());
}
for (unsigned i = 6; i <= 20; ++i)
{
weekday_indexed wdi(std::chrono::Tuesday, i);
assert(!wdi.ok());
}
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_indexed;
// constexpr unsigned index() const noexcept;
// Returns: index_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
ASSERT_NOEXCEPT( std::declval<const weekday_indexed>().index());
ASSERT_SAME_TYPE(unsigned, decltype(std::declval<const weekday_indexed>().index()));
static_assert( weekday_indexed{}.index() == 0, "");
for (unsigned i = 1; i <= 5; ++i)
{
weekday_indexed wdi(weekday{2}, i);
assert( static_cast<unsigned>(wdi.index()) == i);
}
}

View File

@ -1,49 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_indexed;
// constexpr bool ok() const noexcept;
// Returns: wd_.ok() && 1 <= index_ && index_ <= 5
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
ASSERT_NOEXCEPT( std::declval<const weekday_indexed>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday_indexed>().ok()));
static_assert(!weekday_indexed{}.ok(), "");
static_assert( weekday_indexed{std::chrono::Sunday, 2}.ok(), "");
assert(!(weekday_indexed(std::chrono::Tuesday, 0).ok()));
for (unsigned i = 1; i <= 5; ++i)
{
weekday_indexed wdi(std::chrono::Tuesday, i);
assert( wdi.ok());
}
for (unsigned i = 6; i <= 20; ++i)
{
weekday_indexed wdi(std::chrono::Tuesday, i);
assert(!wdi.ok());
}
// Not a valid weekday
assert(!(weekday_indexed(weekday{9U}, 1).ok()));
}

View File

@ -1,39 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_indexed;
// constexpr chrono::weekday weekday() const noexcept;
// Returns: wd_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
ASSERT_NOEXCEPT( std::declval<const weekday_indexed>().weekday());
ASSERT_SAME_TYPE(std::chrono::weekday, decltype(std::declval<const weekday_indexed>().weekday()));
static_assert( weekday_indexed{}.weekday() == weekday{}, "");
static_assert( weekday_indexed{std::chrono::Tuesday, 0}.weekday() == std::chrono::Tuesday, "");
for (unsigned i = 0; i <= 6; ++i)
{
weekday_indexed wdi(weekday{i}, 2);
assert( static_cast<unsigned>(wdi.weekday()) == i);
}
}

View File

@ -1,48 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_indexed;
// constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
// Returns: x.weekday() == y.weekday() && x.index() == y.index().
// constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
// Returns: !(x == y)
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
AssertComparisons2AreNoexcept<weekday_indexed>();
AssertComparisons2ReturnBool<weekday_indexed>();
static_assert( (weekday_indexed{} == weekday_indexed{}), "");
static_assert(!(weekday_indexed{} != weekday_indexed{}), "");
static_assert(!(weekday_indexed{} == weekday_indexed{std::chrono::Tuesday, 1}), "");
static_assert( (weekday_indexed{} != weekday_indexed{std::chrono::Tuesday, 1}), "");
// Some 'ok' values as well
static_assert( (weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 2}), "");
static_assert(!(weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 2}), "");
static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 1}), "");
static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 1}), "");
static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{2}, 2}), "");
static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{2}, 2}), "");
}

View File

@ -1,36 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class weekday_indexed;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
//
// Effects: os << wdi.weekday() << '[' << wdi.index().
// If wdi.index() is in the range [1, 5], appends with ']',
// otherwise appends with " is not a valid index]".
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday_indexed = std::chrono::weekday_indexed;
using weekday = std::chrono::weekday;
std::cout << weekday_indexed{weekday{3}};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_indexed;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday_indexed = std::chrono::weekday_indexed;
static_assert(std::is_trivially_copyable_v<weekday_indexed>, "");
static_assert(std::is_standard_layout_v<weekday_indexed>, "");
}

View File

@ -1,47 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_last;
// explicit constexpr weekday_last(const chrono::weekday& wd) noexcept;
//
// Effects: Constructs an object of type weekday_last by initializing wd_ with wd.
//
// constexpr chrono::weekday weekday() const noexcept;
// constexpr bool ok() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
ASSERT_NOEXCEPT(weekday_last{weekday{}});
constexpr weekday_last wdl0{weekday{}};
static_assert( wdl0.weekday() == weekday{}, "");
static_assert( wdl0.ok(), "");
constexpr weekday_last wdl1 {weekday{1}};
static_assert( wdl1.weekday() == weekday{1}, "");
static_assert( wdl1.ok(), "");
for (unsigned i = 0; i <= 255; ++i)
{
weekday_last wdl{weekday{i}};
assert(wdl.weekday() == weekday{i});
}
}

View File

@ -1,37 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_last;
// constexpr bool ok() const noexcept;
// Returns: wd_.ok()
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
ASSERT_NOEXCEPT( std::declval<const weekday_last>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday_last>().ok()));
static_assert( weekday_last{weekday{0}}.ok(), "");
static_assert( weekday_last{weekday{1}}.ok(), "");
static_assert(!weekday_last{weekday{7}}.ok(), "");
for (unsigned i = 0; i <= 255; ++i)
assert(weekday_last{weekday{i}}.ok() == weekday{i}.ok());
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_last;
// constexpr chrono::weekday weekday() const noexcept;
// Returns: wd_
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
ASSERT_NOEXCEPT( std::declval<const weekday_last>().weekday());
ASSERT_SAME_TYPE(weekday, decltype(std::declval<const weekday_last>().weekday()));
for (unsigned i = 0; i <= 255; ++i)
assert(weekday_last{weekday{i}}.weekday() == weekday{i});
}

View File

@ -1,43 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_last;
// constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
// constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
AssertComparisons2AreNoexcept<weekday_last>();
AssertComparisons2ReturnBool<weekday_last>();
static_assert(testComparisons2Values<weekday_last>(weekday{0}, weekday{0}), "");
static_assert(testComparisons2Values<weekday_last>(weekday{0}, weekday{1}), "");
// Some 'ok' values as well
static_assert(testComparisons2Values<weekday_last>(weekday{2}, weekday{2}), "");
static_assert(testComparisons2Values<weekday_last>(weekday{2}, weekday{3}), "");
for (unsigned i = 0; i < 6; ++i)
for (unsigned j = 0; j < 6; ++j)
assert(testComparisons2Values<weekday_last>(weekday{i}, weekday{j}));
}

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class weekday_last;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
//
// Returns: os << wdl.weekday() << "[last]".
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using weekday_last = std::chrono::weekday_last;
using weekday = std::chrono::weekday;
std::cout << weekday_last{weekday{3}};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday_last;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday_last = std::chrono::weekday_last;
static_assert(std::is_trivially_copyable_v<weekday_last>, "");
static_assert(std::is_standard_layout_v<weekday_last>, "");
}

View File

@ -1,51 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// weekday() = default;
// explicit constexpr weekday(unsigned wd) noexcept;
// constexpr weekday(const sys_days& dp) noexcept;
// explicit constexpr weekday(const local_days& dp) noexcept;
//
// explicit constexpr operator unsigned() const noexcept;
// Effects: Constructs an object of type weekday by initializing m_ with m.
// The value held is unspecified if d is not in the range [0, 255].
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
ASSERT_NOEXCEPT(weekday{});
ASSERT_NOEXCEPT(weekday(1));
ASSERT_NOEXCEPT(static_cast<unsigned>(weekday(1)));
constexpr weekday m0{};
static_assert(static_cast<unsigned>(m0) == 0, "");
constexpr weekday m1{1};
static_assert(static_cast<unsigned>(m1) == 1, "");
for (unsigned i = 0; i <= 255; ++i)
{
weekday m(i);
assert(static_cast<unsigned>(m) == i);
}
// TODO - sys_days and local_days ctor tests
}

View File

@ -1,53 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr weekday& operator--() noexcept;
// constexpr weekday operator--(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "../../euclidian.h"
template <typename WD>
constexpr bool testConstexpr()
{
WD wd{1};
if (static_cast<unsigned>(--wd) != 0) return false;
if (static_cast<unsigned>(wd--) != 0) return false;
if (static_cast<unsigned>(wd) != 6) return false;
return true;
}
int main()
{
using weekday = std::chrono::weekday;
ASSERT_NOEXCEPT(--(std::declval<weekday&>()) );
ASSERT_NOEXCEPT( (std::declval<weekday&>())--);
ASSERT_SAME_TYPE(weekday , decltype( std::declval<weekday&>()--));
ASSERT_SAME_TYPE(weekday&, decltype(--std::declval<weekday&>() ));
static_assert(testConstexpr<weekday>(), "");
for (unsigned i = 0; i <= 6; ++i)
{
weekday wd(i);
assert((static_cast<unsigned>(--wd) == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
assert((static_cast<unsigned>(wd--) == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, 2)));
}
}

View File

@ -1,53 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr weekday& operator++() noexcept;
// constexpr weekday operator++(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "../../euclidian.h"
template <typename WD>
constexpr bool testConstexpr()
{
WD wd{5};
if (static_cast<unsigned>(++wd) != 6) return false;
if (static_cast<unsigned>(wd++) != 6) return false;
if (static_cast<unsigned>(wd) != 0) return false;
return true;
}
int main()
{
using weekday = std::chrono::weekday;
ASSERT_NOEXCEPT(++(std::declval<weekday&>()) );
ASSERT_NOEXCEPT( (std::declval<weekday&>())++);
ASSERT_SAME_TYPE(weekday , decltype( std::declval<weekday&>()++));
ASSERT_SAME_TYPE(weekday&, decltype(++std::declval<weekday&>() ));
static_assert(testConstexpr<weekday>(), "");
for (unsigned i = 0; i <= 6; ++i)
{
weekday wd(i);
assert((static_cast<unsigned>(++wd) == euclidian_addition<unsigned, 0, 6>(i, 1)));
assert((static_cast<unsigned>(wd++) == euclidian_addition<unsigned, 0, 6>(i, 1)));
assert((static_cast<unsigned>(wd) == euclidian_addition<unsigned, 0, 6>(i, 2)));
}
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr bool ok() const noexcept;
// Returns: wd_ <= 6
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
ASSERT_NOEXCEPT( std::declval<const weekday>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday>().ok()));
static_assert( weekday{0}.ok(), "");
static_assert( weekday{1}.ok(), "");
static_assert(!weekday{7}.ok(), "");
for (unsigned i = 0; i <= 6; ++i)
assert(weekday{i}.ok());
for (unsigned i = 7; i <= 255; ++i)
assert(!weekday{i}.ok());
}

View File

@ -1,59 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr weekday_indexed operator[](unsigned index) const noexcept;
// constexpr weekday_last operator[](last_spec) const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "../../euclidian.h"
int main()
{
using weekday = std::chrono::weekday;
using weekday_last = std::chrono::weekday_last;
using weekday_indexed = std::chrono::weekday_indexed;
constexpr weekday Sunday = std::chrono::Sunday;
ASSERT_NOEXCEPT( std::declval<weekday>()[1U]);
ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<weekday>()[1U]));
ASSERT_NOEXCEPT( std::declval<weekday>()[std::chrono::last]);
ASSERT_SAME_TYPE(weekday_last, decltype(std::declval<weekday>()[std::chrono::last]));
static_assert(Sunday[2].weekday() == Sunday, "");
static_assert(Sunday[2].index () == 2, "");
for (unsigned i = 0; i <= 6; ++i)
{
weekday wd(i);
weekday_last wdl = wd[std::chrono::last];
assert(wdl.weekday() == wd);
assert(wdl.ok());
}
for (unsigned i = 0; i <= 6; ++i)
for (unsigned j = 1; j <= 5; ++j)
{
weekday wd(i);
weekday_indexed wdi = wd[j];
assert(wdi.weekday() == wd);
assert(wdi.index() == j);
assert(wdi.ok());
}
}

View File

@ -1,63 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr weekday& operator+=(const days& d) noexcept;
// constexpr weekday& operator-=(const days& d) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "../../euclidian.h"
template <typename M, typename Ms>
constexpr bool testConstexpr()
{
M m1{1};
if (static_cast<unsigned>(m1 += Ms{ 1}) != 2) return false;
if (static_cast<unsigned>(m1 += Ms{ 2}) != 4) return false;
if (static_cast<unsigned>(m1 += Ms{ 4}) != 1) return false;
if (static_cast<unsigned>(m1 -= Ms{ 1}) != 0) return false;
if (static_cast<unsigned>(m1 -= Ms{ 2}) != 5) return false;
if (static_cast<unsigned>(m1 -= Ms{ 4}) != 1) return false;
return true;
}
int main()
{
using weekday = std::chrono::weekday;
using days = std::chrono::days;
ASSERT_NOEXCEPT( std::declval<weekday&>() += std::declval<days&>());
ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() += std::declval<days&>()));
ASSERT_NOEXCEPT( std::declval<weekday&>() -= std::declval<days&>());
ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() -= std::declval<days&>()));
static_assert(testConstexpr<weekday, days>(), "");
for (unsigned i = 0; i <= 6; ++i)
{
weekday wd(i);
assert((static_cast<unsigned>(wd += days{3}) == euclidian_addition<unsigned, 0, 6>(i, 3)));
assert((static_cast<unsigned>(wd) == euclidian_addition<unsigned, 0, 6>(i, 3)));
}
for (unsigned i = 0; i <= 6; ++i)
{
weekday wd(i);
assert((static_cast<unsigned>(wd -= days{4}) == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
}
}

View File

@ -1,42 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
// constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using weekday = std::chrono::weekday;
AssertComparisons2AreNoexcept<weekday>();
AssertComparisons2ReturnBool<weekday>();
static_assert(testComparisons2Values<weekday>(0U ,0U), "");
static_assert(testComparisons2Values<weekday>(0U, 1U), "");
// Some 'ok' values as well
static_assert(testComparisons2Values<weekday>(5U, 5U), "");
static_assert(testComparisons2Values<weekday>(5U, 2U), "");
for (unsigned i = 0; i < 6; ++i)
for (unsigned j = 0; j < 6; ++j)
assert(testComparisons2Values<weekday>(i, j));
}

View File

@ -1,62 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// inline constexpr weekday Sunday{0};
// inline constexpr weekday Monday{1};
// inline constexpr weekday Tuesday{2};
// inline constexpr weekday Wednesday{3};
// inline constexpr weekday Thursday{4};
// inline constexpr weekday Friday{5};
// inline constexpr weekday Saturday{6};
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Sunday));
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Monday));
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Tuesday));
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Wednesday));
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Thursday));
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Friday));
ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Saturday));
static_assert( std::chrono::Sunday == std::chrono::weekday(0), "");
static_assert( std::chrono::Monday == std::chrono::weekday(1), "");
static_assert( std::chrono::Tuesday == std::chrono::weekday(2), "");
static_assert( std::chrono::Wednesday == std::chrono::weekday(3), "");
static_assert( std::chrono::Thursday == std::chrono::weekday(4), "");
static_assert( std::chrono::Friday == std::chrono::weekday(5), "");
static_assert( std::chrono::Saturday == std::chrono::weekday(6), "");
assert(std::chrono::Sunday == std::chrono::weekday(0));
assert(std::chrono::Monday == std::chrono::weekday(1));
assert(std::chrono::Tuesday == std::chrono::weekday(2));
assert(std::chrono::Wednesday == std::chrono::weekday(3));
assert(std::chrono::Thursday == std::chrono::weekday(4));
assert(std::chrono::Friday == std::chrono::weekday(5));
assert(std::chrono::Saturday == std::chrono::weekday(6));
assert(static_cast<unsigned>(std::chrono::Sunday) == 0);
assert(static_cast<unsigned>(std::chrono::Monday) == 1);
assert(static_cast<unsigned>(std::chrono::Tuesday) == 2);
assert(static_cast<unsigned>(std::chrono::Wednesday) == 3);
assert(static_cast<unsigned>(std::chrono::Thursday) == 4);
assert(static_cast<unsigned>(std::chrono::Friday) == 5);
assert(static_cast<unsigned>(std::chrono::Saturday) == 6);
}

View File

@ -1,76 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr weekday operator-(const weekday& x, const days& y) noexcept;
// Returns: x + -y.
//
// constexpr days operator-(const weekday& x, const weekday& y) noexcept;
// Returns: If x.ok() == true and y.ok() == true, returns a value d in the range
// [days{0}, days{6}] satisfying y + d == x.
// Otherwise the value returned is unspecified.
// [Example: Sunday - Monday == days{6}. —end example]
extern "C" int printf(const char *, ...);
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "../../euclidian.h"
template <typename WD, typename Ds>
constexpr bool testConstexpr()
{
{
WD wd{5};
Ds offset{3};
if (wd - offset != WD{2}) return false;
if (wd - WD{2} != offset) return false;
}
// Check the example
if (WD{0} - WD{1} != Ds{6}) return false;
return true;
}
int main()
{
using weekday = std::chrono::weekday;
using days = std::chrono::days;
ASSERT_NOEXCEPT( std::declval<weekday>() - std::declval<days>());
ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() - std::declval<days>()));
ASSERT_NOEXCEPT( std::declval<weekday>() - std::declval<weekday>());
ASSERT_SAME_TYPE(days, decltype(std::declval<weekday>() - std::declval<weekday>()));
static_assert(testConstexpr<weekday, days>(), "");
for (unsigned i = 0; i <= 6; ++i)
for (unsigned j = 0; j <= 6; ++j)
{
weekday wd = weekday{i} - days{j};
assert(wd + days{j} == weekday{i});
assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, j)));
}
for (unsigned i = 0; i <= 6; ++i)
for (unsigned j = 0; j <= 6; ++j)
{
days d = weekday{j} - weekday{i};
assert(weekday{i} + d == weekday{j});
}
}

View File

@ -1,70 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
// constexpr weekday operator+(const days& x, const weekday& y) noexcept;
// Returns: weekday(int{x} + y.count()).
//
// constexpr weekday operator+(const weekday& x, const days& y) noexcept;
// Returns:
// weekday{modulo(static_cast<long long>(unsigned{x}) + y.count(), 7)}
// where modulo(n, 7) computes the remainder of n divided by 7 using Euclidean division.
// [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
// and always produces a remainder in the range of [0, 6].
// Assuming no overflow in the signed summation, this operation results in a weekday
// holding a value in the range [0, 6] even if !x.ok(). —end note]
// [Example: Monday + days{6} == Sunday. —end example]
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "../../euclidian.h"
template <typename M, typename Ms>
constexpr bool testConstexpr()
{
M m{1};
Ms offset{4};
if (m + offset != M{5}) return false;
if (offset + m != M{5}) return false;
// Check the example
if (M{1} + Ms{6} != M{0}) return false;
return true;
}
int main()
{
using weekday = std::chrono::weekday;
using days = std::chrono::days;
ASSERT_NOEXCEPT( std::declval<weekday>() + std::declval<days>());
ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() + std::declval<days>()));
ASSERT_NOEXCEPT( std::declval<days>() + std::declval<weekday>());
ASSERT_SAME_TYPE(weekday, decltype(std::declval<days>() + std::declval<weekday>()));
static_assert(testConstexpr<weekday, days>(), "");
for (unsigned i = 0; i <= 6; ++i)
for (unsigned j = 0; j <= 6; ++j)
{
weekday wd1 = weekday{i} + days{j};
weekday wd2 = days{j} + weekday{i};
assert(wd1 == wd2);
assert((static_cast<unsigned>(wd1) == euclidian_addition<unsigned, 0, 6>(i, j)));
assert((static_cast<unsigned>(wd2) == euclidian_addition<unsigned, 0, 6>(i, j)));
}
}

View File

@ -1,56 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: *
// <chrono>
// class weekday;
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
//
// Effects: If wd.ok() == true inserts format(os.getloc(), fmt, wd) where fmt is "%a" widened to charT.
// Otherwise inserts unsigned{wd} << " is not a valid weekday".
//
// template<class charT, class traits>
// basic_ostream<charT, traits>&
// to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const weekday& wd);
//
// Effects: Streams wd into os using the format specified by the NTCTS fmt.
// fmt encoding follows the rules specified in 25.11.
//
// template<class charT, class traits, class Alloc = allocator<charT>>
// basic_istream<charT, traits>&
// from_stream(basic_istream<charT, traits>& is, const charT* fmt,
// weekday& wd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
// minutes* offset = nullptr);
//
// Effects: Attempts to parse the input stream is into the weekday wd using
// the format flags given in the NTCTS fmt as specified in 25.12.
// If the parse fails to decode a valid weekday, is.setstate(ios_- base::failbit)
// shall be called and wd shall not be modified.
// If %Z is used and successfully parsed, that value will be assigned
// to *abbrev if abbrev is non-null.
// If %z (or a modified variant) is used and successfully parsed,
// that value will be assigned to *offset if offset is non-null.
#include <chrono>
#include <type_traits>
#include <cassert>
#include <iostream>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
std::cout << weekday{3};
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class weekday;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using weekday = std::chrono::weekday;
static_assert(std::is_trivially_copyable_v<weekday>, "");
static_assert(std::is_standard_layout_v<weekday>, "");
}

View File

@ -1,46 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// year() = default;
// explicit constexpr year(int m) noexcept;
// explicit constexpr operator int() const noexcept;
// Effects: Constructs an object of type year by initializing y_ with y.
// The value held is unspecified if d is not in the range [0, 255].
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using year = std::chrono::year;
ASSERT_NOEXCEPT(year{});
ASSERT_NOEXCEPT(year(0U));
ASSERT_NOEXCEPT(static_cast<int>(year(0U)));
constexpr year y0{};
static_assert(static_cast<int>(y0) == 0, "");
constexpr year y1{1};
static_assert(static_cast<int>(y1) == 1, "");
for (int i = 0; i <= 2550; i += 7)
{
year year(i);
assert(static_cast<int>(year) == i);
}
}

View File

@ -1,52 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr year& operator--() noexcept;
// constexpr year operator--(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename Y>
constexpr bool testConstexpr()
{
Y y1{10};
if (static_cast<int>(--y1) != 9) return false;
if (static_cast<int>(y1--) != 9) return false;
if (static_cast<int>(y1) != 8) return false;
return true;
}
int main()
{
using year = std::chrono::year;
ASSERT_NOEXCEPT(--(std::declval<year&>()) );
ASSERT_NOEXCEPT( (std::declval<year&>())--);
ASSERT_SAME_TYPE(year , decltype( std::declval<year&>()--));
ASSERT_SAME_TYPE(year&, decltype(--std::declval<year&>() ));
static_assert(testConstexpr<year>(), "");
for (int i = 11000; i <= 11020; ++i)
{
year year(i);
assert(static_cast<int>(--year) == i - 1);
assert(static_cast<int>(year--) == i - 1);
assert(static_cast<int>(year) == i - 2);
}
}

View File

@ -1,52 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr year& operator++() noexcept;
// constexpr year operator++(int) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename Y>
constexpr bool testConstexpr()
{
Y y1{10};
if (static_cast<int>(++y1) != 11) return false;
if (static_cast<int>(y1++) != 11) return false;
if (static_cast<int>(y1) != 12) return false;
return true;
}
int main()
{
using year = std::chrono::year;
ASSERT_NOEXCEPT(++(std::declval<year&>()) );
ASSERT_NOEXCEPT( (std::declval<year&>())++);
ASSERT_SAME_TYPE(year , decltype( std::declval<year&>()++));
ASSERT_SAME_TYPE(year&, decltype(++std::declval<year&>() ));
static_assert(testConstexpr<year>(), "");
for (int i = 11000; i <= 11020; ++i)
{
year year(i);
assert(static_cast<int>(++year) == i + 1);
assert(static_cast<int>(year++) == i + 1);
assert(static_cast<int>(year) == i + 2);
}
}

View File

@ -1,53 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr bool is_is_leap() const noexcept;
// y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0)
//
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using year = std::chrono::year;
ASSERT_NOEXCEPT( year(1).is_leap());
ASSERT_SAME_TYPE(bool, decltype(year(1).is_leap()));
static_assert(!year{1}.is_leap(), "");
static_assert(!year{2}.is_leap(), "");
static_assert(!year{3}.is_leap(), "");
static_assert( year{4}.is_leap(), "");
assert( year{-2000}.is_leap());
assert( year{ -400}.is_leap());
assert(!year{ -300}.is_leap());
assert(!year{ -200}.is_leap());
assert(!year{ 200}.is_leap());
assert(!year{ 300}.is_leap());
assert( year{ 400}.is_leap());
assert(!year{ 1997}.is_leap());
assert(!year{ 1998}.is_leap());
assert(!year{ 1999}.is_leap());
assert( year{ 2000}.is_leap());
assert(!year{ 2001}.is_leap());
assert(!year{ 2002}.is_leap());
assert(!year{ 2003}.is_leap());
assert( year{ 2004}.is_leap());
assert(!year{ 2100}.is_leap());
}

View File

@ -1,53 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr bool ok() const noexcept;
// Returns: min() <= y_ && y_ <= max().
//
// static constexpr year min() noexcept;
// Returns year{ 32767};
// static constexpr year max() noexcept;
// Returns year{-32767};
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using year = std::chrono::year;
ASSERT_NOEXCEPT( std::declval<const year>().ok());
ASSERT_SAME_TYPE(bool, decltype(std::declval<const year>().ok()));
ASSERT_NOEXCEPT( year::max());
ASSERT_SAME_TYPE(year, decltype(year::max()));
ASSERT_NOEXCEPT( year::min());
ASSERT_SAME_TYPE(year, decltype(year::min()));
static_assert(static_cast<int>(year::min()) == -32767, "");
static_assert(static_cast<int>(year::max()) == 32767, "");
assert(year{-20001}.ok());
assert(year{ -2000}.ok());
assert(year{ -1}.ok());
assert(year{ 0}.ok());
assert(year{ 1}.ok());
assert(year{ 2000}.ok());
assert(year{ 20001}.ok());
static_assert(!year{-32768}.ok(), "");
}

View File

@ -1,51 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr year operator+() const noexcept;
// constexpr year operator-() const noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename Y>
constexpr bool testConstexpr()
{
Y y1{1};
if (static_cast<int>(+y1) != 1) return false;
if (static_cast<int>(-y1) != -1) return false;
return true;
}
int main()
{
using year = std::chrono::year;
using years = std::chrono::years;
ASSERT_NOEXCEPT(+std::declval<year>());
ASSERT_NOEXCEPT(-std::declval<year>());
ASSERT_SAME_TYPE(year, decltype(+std::declval<year>()));
ASSERT_SAME_TYPE(year, decltype(-std::declval<year>()));
static_assert(testConstexpr<year>(), "");
for (int i = 10000; i <= 10020; ++i)
{
year year(i);
assert(static_cast<int>(+year) == i);
assert(static_cast<int>(-year) == -i);
}
}

View File

@ -1,57 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr year& operator+=(const years& d) noexcept;
// constexpr year& operator-=(const years& d) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <typename Y, typename Ys>
constexpr bool testConstexpr()
{
Y y1{1};
if (static_cast<int>(y1 += Ys{ 1}) != 2) return false;
if (static_cast<int>(y1 += Ys{ 2}) != 4) return false;
if (static_cast<int>(y1 += Ys{ 8}) != 12) return false;
if (static_cast<int>(y1 -= Ys{ 1}) != 11) return false;
if (static_cast<int>(y1 -= Ys{ 2}) != 9) return false;
if (static_cast<int>(y1 -= Ys{ 8}) != 1) return false;
return true;
}
int main()
{
using year = std::chrono::year;
using years = std::chrono::years;
ASSERT_NOEXCEPT(std::declval<year&>() += std::declval<years>());
ASSERT_NOEXCEPT(std::declval<year&>() -= std::declval<years>());
ASSERT_SAME_TYPE(year&, decltype(std::declval<year&>() += std::declval<years>()));
ASSERT_SAME_TYPE(year&, decltype(std::declval<year&>() -= std::declval<years>()));
static_assert(testConstexpr<year, years>(), "");
for (int i = 10000; i <= 10020; ++i)
{
year year(i);
assert(static_cast<int>(year += years{10}) == i + 10);
assert(static_cast<int>(year) == i + 10);
assert(static_cast<int>(year -= years{ 9}) == i + 1);
assert(static_cast<int>(year) == i + 1);
}
}

View File

@ -1,47 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr bool operator==(const year& x, const year& y) noexcept;
// constexpr bool operator!=(const year& x, const year& y) noexcept;
// constexpr bool operator< (const year& x, const year& y) noexcept;
// constexpr bool operator> (const year& x, const year& y) noexcept;
// constexpr bool operator<=(const year& x, const year& y) noexcept;
// constexpr bool operator>=(const year& x, const year& y) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_comparisons.h"
int main()
{
using year = std::chrono::year;
AssertComparisons6AreNoexcept<year>();
AssertComparisons6ReturnBool<year>();
static_assert(testComparisons6Values<year>(0,0), "");
static_assert(testComparisons6Values<year>(0,1), "");
// Some 'ok' values as well
static_assert(testComparisons6Values<year>( 5, 5), "");
static_assert(testComparisons6Values<year>( 5,10), "");
for (int i = 1; i < 10; ++i)
for (int j = 1; j < 10; ++j)
assert(testComparisons6Values<year>(i, j));
}

View File

@ -1,26 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <chrono>
// class year;
// constexpr year operator""y(unsigned long long y) noexcept;
#include <chrono>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
int main()
{
using std::chrono::year;
year d1 = 1234y; // expected-error-re {{no matching literal operator for call to 'operator""y' {{.*}}}}
}

Some files were not shown because too many files have changed in this diff Show More