libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

comparisons.pass.cpp (1966B)


      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
     10 
     11 // <chrono>
     12 // class weekday_indexed;
     13 
     14 // constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
     15 //   Returns: x.weekday() == y.weekday() && x.index() == y.index().
     16 // constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
     17 //   Returns: !(x == y)
     18 
     19 #include <chrono>
     20 #include <type_traits>
     21 #include <cassert>
     22 
     23 #include "test_macros.h"
     24 #include "test_comparisons.h"
     25 
     26 int main()
     27 {
     28     using weekday         = std::chrono::weekday;
     29     using weekday_indexed = std::chrono::weekday_indexed;
     30 
     31     AssertComparisons2AreNoexcept<weekday_indexed>();
     32     AssertComparisons2ReturnBool<weekday_indexed>();
     33 
     34     static_assert( (weekday_indexed{} == weekday_indexed{}), "");
     35     static_assert(!(weekday_indexed{} != weekday_indexed{}), "");
     36 
     37     static_assert(!(weekday_indexed{} == weekday_indexed{std::chrono::Tuesday, 1}), "");
     38     static_assert( (weekday_indexed{} != weekday_indexed{std::chrono::Tuesday, 1}), "");
     39 
     40 //  Some 'ok' values as well
     41     static_assert( (weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 2}), "");
     42     static_assert(!(weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 2}), "");
     43 
     44     static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 1}), "");
     45     static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 1}), "");
     46     static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{2}, 2}),  "");
     47     static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{2}, 2}),  "");
     48 }