xref: /llvm-project/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp (revision 2b26ee6e790574e05c3c9a562bc37897daf0f384)
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <system_error>
10 
11 // class error_category
12 
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 
23 int 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 _WIN32
33   // On windows, system_category is distinct.
34   LIBCPP_ASSERT(m1 == m2);
35 #endif
36   assert(m2 != m3);
37 
38   return 0;
39 }
40