brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · f7f4313 Raw
40 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 9// <system_error>10 11// class error_category12 13// virtual string message(int ev) const = 0;14 15#include <system_error>16#include <cassert>17#include <string>18 19#include <stdio.h>20 21#include "test_macros.h"22 23int main(int, char**) {24  const std::error_category& e_cat1 = std::generic_category();25  const std::error_category& e_cat2 = std::system_category();26  std::string m1                    = e_cat1.message(5);27  std::string m2                    = e_cat2.message(5);28  std::string m3                    = e_cat2.message(6);29  assert(!m1.empty());30  assert(!m2.empty());31  assert(!m3.empty());32#ifndef _WIN3233  // On windows, system_category is distinct.34  LIBCPP_ASSERT(m1 == m2);35#endif36  assert(m2 != m3);37 38  return 0;39}40