libsir 2.2.5
Standard Incident Reporter
Loading...
Searching...
No Matches
tests++.hh
1/*
2 * tests++.hh
3 *
4 * Version: 2.2.5
5 *
6 * ----------------------------------------------------------------------------
7 *
8 * SPDX-License-Identifier: MIT
9 *
10 * Copyright (c) 2018-2024 Ryan M. Lederman <lederman@gmail.com>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy of
13 * this software and associated documentation files (the "Software"), to deal in
14 * the Software without restriction, including without limitation the rights to
15 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16 * the Software, and to permit persons to whom the Software is furnished to do so,
17 * subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in all
20 * copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * ----------------------------------------------------------------------------
30 */
31
32#ifndef _SIR_TESTSXX_HH_INCLUDED
33# define _SIR_TESTSXX_HH_INCLUDED
34
35# include "sir.hh"
36# include "tests_shared.h"
37
38# if defined(_MSC_VER) && !defined(__PRETTY_FUNCTION__)
39# define __PRETTY_FUNCTION__ __FUNCSIG__
40# endif
41
48namespace sir::tests
49{
55 bool raii_init_cleanup();
56
63
69 bool error_handling();
70
76 bool exception_handling();
77
83 bool std_format();
84
90 bool boost_format();
91
97 bool fmt_format();
98
104 bool std_iostream_format();
105
111 //bool ();
112} // !namespace sir::tests
113
121# define _SIR_TEST_COMMENCE \
122 bool pass = true; \
123 try {
124
126# define _SIR_TEST_ON_EXCEPTION(what) \
127 ERROR_MSG("unexpected exception in %s: '%s'", __PRETTY_FUNCTION__, what); \
128 pass = false; \
129 if (sir_isinitialized()) \
130 [[maybe_unused]] bool unused = sir_cleanup()
131
133# define _SIR_TEST_ON_EXPECTED_EXCEPTION(what) \
134 TEST_MSG(SIR_GREEN("expected exception in %s: '%s'"), __PRETTY_FUNCTION__, what)
135
137# define _SIR_TEST_COMPLETE \
138 } catch (const std::exception& ex) { \
139 _SIR_TEST_ON_EXCEPTION(ex.what()); \
140 } catch (...) { \
141 _SIR_TEST_ON_EXCEPTION(SIR_UNKNOWN); \
142 } \
143 return PRINT_RESULT_RETURN(pass);
144
145#endif // !_SIR_TESTSXX_HH_INCLUDED
libsir C++ wrapper tests.
Definition tests++.hh:49
bool manual_init_cleanup()
Ensure that manual initialization and cleanup is working properly.
Definition tests++.cc:167
bool error_handling()
Ensure that the C++ wrapper properly handles errors from libsir.
Definition tests++.cc:197
bool boost_format()
If boost::format support is enabled, ensure that it is working properly.
Definition tests++.cc:321
bool fmt_format()
If fmt::format support is enabled, ensure that it is working properly.
Definition tests++.cc:343
bool raii_init_cleanup()
Ensure that RAII loggers are functioning properly.
Definition tests++.cc:125
bool std_format()
If std::format support is enabled, ensure that it is working properly.
Definition tests++.cc:300
bool std_iostream_format()
If std::iostream support is enabled, ensure that it is working properly.
Definition tests++.cc:364
bool exception_handling()
Ensure that exceptions are properly constructed in various ways.
Definition tests++.cc:250
C++ interface to libsir.