1// Copyright 2023 Peter Dimov.
2// Distributed under the Boost Software License, Version 1.0.
3// http://www.boost.org/LICENSE_1_0.txt
4
5#include <boost/system/error_category.hpp>
6#include <boost/core/lightweight_test.hpp>
7#include <boost/core/snprintf.hpp>
8#include <system_error>
9
10// get_user_category
11
12class user_category: public boost::system::error_category
13{
14public:
15
16 virtual const char * name() const noexcept
17 {
18 return "user";
19 }
20
21 virtual std::string message( int ev ) const
22 {
23 char buffer[ 256 ];
24 boost::core::snprintf( s: buffer, maxlen: sizeof( buffer ), format: "user message %d", ev );
25
26 return buffer;
27 }
28};
29
30boost::system::error_category const & get_user_category()
31{
32 static user_category instance;
33 return instance;
34}
35
36//
37
38bool init_lwt = (boost::core::lwt_init(), true);
39
40std::error_category const & cat = get_user_category();
41
42int main()
43{
44 BOOST_TEST_CSTR_EQ( cat.name(), "user" );
45 return boost::report_errors();
46}
47

source code of boost/libs/system/test/std_interop_test16.cpp