brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · cb84550 Raw
42 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <system_error>11 12// class error_condition13 14// strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept15 16#include <system_error>17#include <cassert>18 19#include "test_macros.h"20#include "test_comparisons.h"21 22int main(int, char**) {23  AssertOrderAreNoexcept<std::error_condition>();24  AssertOrderReturn<std::strong_ordering, std::error_condition>();25 26  // Same error category27  std::error_condition ec1a = std::error_condition(1, std::generic_category());28  std::error_condition ec1b = std::error_condition(1, std::generic_category());29  std::error_condition ec2  = std::error_condition(2, std::generic_category());30 31  assert(testOrder(ec1a, ec1b, std::strong_ordering::equal));32  assert(testOrder(ec1a, ec2, std::strong_ordering::less));33 34  // Different error category35  const std::error_condition& ec3 = std::error_condition(2, std::system_category());36 37  bool isLess = ec2 < ec3;38  assert(testOrder(ec2, ec3, isLess ? std::strong_ordering::less : std::strong_ordering::greater));39 40  return 0;41}42