micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
details-inlines.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 *
11 * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12 * released under the terms of the Boost Version 1.0 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
44
45#ifndef MICRO_TEST_PLUS_DETAILS_INLINES_H_
46#define MICRO_TEST_PLUS_DETAILS_INLINES_H_
47
48// ----------------------------------------------------------------------------
49
50#ifdef __cplusplus
51
52// ----------------------------------------------------------------------------
53
54#include <stdio.h>
55#include <cstring>
56// #include "test-reporter.h"
57
58// ----------------------------------------------------------------------------
59
60#if defined(__GNUC__)
61#pragma GCC diagnostic push
62#pragma GCC diagnostic ignored "-Waggregate-return"
63#if defined(__clang__)
64#pragma clang diagnostic ignored "-Wc++98-compat"
65#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
66#endif
67#endif
68
70{
71 // --------------------------------------------------------------------------
72
73 namespace detail
74 {
75 // ------------------------------------------------------------------------
76
88 template <class T>
89 auto&
91 {
92 if constexpr (std::is_arithmetic_v<T>)
93 {
94 message_.append (std::to_string (msg));
95 }
96 else
97 {
98 message_.append (msg);
99 }
100 return *this;
101 }
102
103 // ------------------------------------------------------------------------
104
116 template <class Expr_T>
118 const Expr_T& expr, bool abort,
119 const reflection::source_location& location)
120 : deferred_reporter_base{ static_cast<bool> (expr), location },
121 expr_{ expr }
122 {
123#if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
124 printf ("%s\n", __PRETTY_FUNCTION__);
125#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
126 abort_ = abort;
127 }
128
141 template <class Expr_T>
143 {
144 if (value_)
145 {
146 reporter.pass (expr_, message_);
147 }
148 else
149 {
151 }
152 }
153
154 // ------------------------------------------------------------------------
155 } // namespace detail
156
157 // --------------------------------------------------------------------------
158} // namespace micro_os_plus::micro_test_plus
159
160#if defined(__GNUC__)
161#pragma GCC diagnostic pop
162#endif
163
164// ----------------------------------------------------------------------------
165
166#endif // __cplusplus
167
168// ----------------------------------------------------------------------------
169
170#endif // MICRO_TEST_PLUS_DETAILS_INLINES_H_
171
172// ----------------------------------------------------------------------------
const reflection::source_location location_
Stores the source location associated with the report.
Definition detail.h:1806
std::string message_
String to collect the expectation message passed via operator<<().
Definition detail.h:1812
bool abort_
Indicates whether the reporting should abort further processing.
Definition detail.h:1801
deferred_reporter_base(bool value, const reflection::source_location location)
Constructs a deferred reporter base.
auto & operator<<(const T &msg)
Appends a message to the reporter.
bool value_
Stores the result value of the report.
Definition detail.h:1795
constexpr deferred_reporter(const Expr_T &expr, bool abort, const reflection::source_location &location)
Constructs a deferred reporter for a specific expression.
const Expr_T expr_
Stores the expression under evaluation.
Definition detail.h:1864
~deferred_reporter()
Destructor for the deferred reporter.
Local implementation of source location information for diagnostics.
Definition reflection.h:137
Internal implementation details for the µTest++ framework.
Primary namespace for the µTest++ testing framework.
test_reporter reporter
Global instance of test_reporter.