Skip to main content

detail.h File

C++ header file with declarations for the µTest++ internals. More...

Included Headers

#include <stdio.h> #include <string>

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespacedetail

Internal implementation details for the µTest++ framework. More...

Classes Index

structand_<Lhs_T, Rhs_T>

Logical AND comparator struct template. More...

structassertion<Expr_T>

Assertion struct template for parameter passing to the evaluator. More...

classdeferred_reporter<Expr_T>

Deferred reporter class template for a specific expression. More...

classdeferred_reporter_base

Base class for a deferred reporter that collects messages into a string. More...

structeq_<Lhs_T, Rhs_T>

Equality comparator struct template. More...

structge_<Lhs_T, Rhs_T>

Greater than or equal comparator struct template. More...

structgt_<Lhs_T, Rhs_T>

Greater than comparator struct template. More...

structle_<Lhs_T, Rhs_T>

Less than or equal comparator struct template. More...

structlt_<Lhs_T, Rhs_T>

Less than comparator struct template. More...

structne_<Lhs_T, Rhs_T>

Non-equality comparator struct template. More...

structnot_<T>

Logical NOT comparator struct template. More...

structnothrow_<Callable_T>

Operator struct template to check if an expression does not throw any exception. More...

structor_<Lhs_T, Rhs_T>

Logical OR comparator struct template. More...

structthrows_<Callable_T, Exception_T>

Operator struct template to check if an expression throws a specific exception. More...

structthrows_<Callable_T, void>

Operator struct template to check if an expression throws any exception. More...

Functions Index

template <typename Lhs_T, typename Rhs_T>
and_ (const Lhs_T &, const Rhs_T &) -> and_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
eq_ (const Lhs_T &, const Rhs_T &) -> eq_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
ge_ (const Lhs_T &, const Rhs_T &) -> ge_< Lhs_T, Rhs_T >
template <class T>
constexpr autoget (const T &t)

Generic getter function template for value retrieval. More...

template <class T>
constexpr auto get_impl (const T &t, int) -> decltype(t.get())

Generic getter function template for value retrieval. More...

template <class T>
constexpr auto get_impl (const T &t,...) -> decltype(auto)

Fallback variadic getter function template. More...

template <typename Lhs_T, typename Rhs_T>
gt_ (const Lhs_T &, const Rhs_T &) -> gt_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
le_ (const Lhs_T &, const Rhs_T &) -> le_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
lt_ (const Lhs_T &, const Rhs_T &) -> lt_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
ne_ (const Lhs_T &, const Rhs_T &) -> ne_< Lhs_T, Rhs_T >
template <typename T>
not_ (const T &) -> not_< T >
template <typename Lhs_T, typename Rhs_T>
or_ (const Lhs_T &, const Rhs_T &) -> or_< Lhs_T, Rhs_T >

Description

C++ header file with declarations for the µTest++ internals.

This header provides the declarations for the internal components of the µTest++ framework, encapsulated within the micro_os_plus::micro_test_plus::detail namespace. It defines the core mechanisms, helper structures, and utility templates that underpin the framework's assertion handling, value retrieval, comparator logic, deferred reporting, and exception checking facilities.

All definitions reside within the micro_os_plus::micro_test_plus::detail namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

The header files are organised within the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

This file is intended solely for internal use within the framework and should not be included directly by user code.

Functions

and_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::and_ (const Lhs_T &, const Rhs_T &)

Definition at line 1287 of file detail.h.

eq_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::eq_ (const Lhs_T &, const Rhs_T &)

Definition at line 405 of file detail.h.

ge_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::ge_ (const Lhs_T &, const Rhs_T &)

Definition at line 870 of file detail.h.

get()

template <class T>
auto micro_os_plus::micro_test_plus::detail::get (const T & t)
nodiscard constexpr

Generic getter function template for value retrieval.

Template Parameters
T

The type from which the value is to be retrieved.

Parameters
t

The object or value to be accessed.

Returns

The value obtained via the relevant getter implementation.

The get function template invokes the appropriate getter implementation to retrieve the value from the provided object or type. This function ensures consistent access to values for both custom and standard types within the framework.

The primary implementation attempts to invoke a get() method if it exists, which is recommended for user-defined types to ensure consistent value access. If the type does not provide a get() method, the fallback variadic implementation simply returns the original argument.

The get function template delegates to these implementations, enabling seamless support for a wide range of types in test expressions and comparators.

All definitions are intended for internal use within the framework and are implemented in the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

Definition at line 223 of file detail.h.

223 get (const T& t)
224 {
225 // Call the variadic function, basically to force it return `t`.
226 return get_impl<T> (t, 0);
227 }

Reference micro_os_plus::micro_test_plus::detail::get_impl.

Referenced by micro_os_plus::micro_test_plus::detail::and_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::or_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::and_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::rhs, micro_os_plus::micro_test_plus::detail::or_< Lhs_T, Rhs_T >::rhs and micro_os_plus::micro_test_plus::detail::not_< T >::value.

get_impl()

template <class T>
decltype(t.get()) micro_os_plus::micro_test_plus::detail::get_impl (const T & t, int)
nodiscard constexpr

Generic getter function template for value retrieval.

Template Parameters
T

The type from which the value is to be retrieved.

Parameters
t

The object or value to be accessed.

Returns

The value obtained via the relevant getter implementation.

The get function template invokes the appropriate getter implementation to retrieve the value from the provided object or type. This function ensures consistent access to values for both custom and standard types within the framework.

The primary implementation attempts to invoke a get() method if it exists, which is recommended for user-defined types to ensure consistent value access. If the type does not provide a get() method, the fallback variadic implementation simply returns the original argument.

The get function template delegates to these implementations, enabling seamless support for a wide range of types in test expressions and comparators.

All definitions are intended for internal use within the framework and are implemented in the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

Definition at line 160 of file detail.h.

160 get_impl (const T& t, int) -> decltype (t.get ())
161 {
162 return t.get ();
163 }

Referenced by micro_os_plus::micro_test_plus::detail::get.

get_impl()

template <class T>
decltype(auto) micro_os_plus::micro_test_plus::detail::get_impl (const T & t, ...)
nodiscard constexpr

Fallback variadic getter function template.

Template Parameters
T

The type from which the value is to be retrieved.

Parameters
t

The object or value to be accessed.

Returns

The original argument t.

The get_impl function template serves as a fallback mechanism for value retrieval when the provided type does not implement a get() member function. It simply returns the first argument, discarding any additional parameters.

This approach ensures that both custom types (with a get() method) and standard types (without a get() method) are supported seamlessly within the framework's generic getter utilities.

All definitions are intended for internal use within the framework and are implemented in the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

Definition at line 189 of file detail.h.

189 get_impl (const T& t, ...) -> decltype (auto)
190 {
191 return t;
192 }

gt_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::gt_ (const Lhs_T &, const Rhs_T &)

Definition at line 721 of file detail.h.

le_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::le_ (const Lhs_T &, const Rhs_T &)

Definition at line 1168 of file detail.h.

lt_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::lt_ (const Lhs_T &, const Rhs_T &)

Definition at line 1018 of file detail.h.

ne_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::ne_ (const Lhs_T &, const Rhs_T &)

Definition at line 574 of file detail.h.

not_()

template <typename T>
micro_os_plus::micro_test_plus::detail::not_ (const T &)

Definition at line 1498 of file detail.h.

or_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::or_ (const Lhs_T &, const Rhs_T &)

Definition at line 1406 of file detail.h.

File Listing

The file content with the documentation metadata removed is:

1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * 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 be
9 * 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 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
41
42#ifndef MICRO_TEST_PLUS_DETAIL_H_
43#define MICRO_TEST_PLUS_DETAIL_H_
44
45// ----------------------------------------------------------------------------
46
47#ifdef __cplusplus
48
49// ----------------------------------------------------------------------------
50
51#include <stdio.h>
52#include <string>
53
54// ----------------------------------------------------------------------------
55
56#if defined(__GNUC__)
57#pragma GCC diagnostic push
58#pragma GCC diagnostic ignored "-Wpadded"
59#pragma GCC diagnostic ignored "-Waggregate-return"
60#if defined(__clang__)
61#pragma clang diagnostic ignored "-Wc++98-compat"
62#endif
63#endif
64
66{
67 // --------------------------------------------------------------------------
68
92 namespace detail
93 {
111 template <class Expr_T>
112 struct assertion
113 {
117 Expr_T expr{};
118
123 };
124
125 // ------------------------------------------------------------------------
126
127 // in C++14/17/20, a function template with a deduced return type
128 // (auto) cannot be used before its definition is visible.
129 // Therefore it is not possible to split definitions.
130
158 template <class T>
159 [[nodiscard]] constexpr auto
160 get_impl (const T& t, int) -> decltype (t.get ())
161 {
162 return t.get ();
163 }
164
187 template <class T>
188 [[nodiscard]] constexpr auto
189 get_impl (const T& t, ...) -> decltype (auto)
190 {
191 return t;
192 }
193
221 template <class T>
222 [[nodiscard]] constexpr auto
223 get (const T& t)
224 {
225 // Call the variadic function, basically to force it return `t`.
226 return get_impl<T> (t, 0);
227 }
228
229 // ------------------------------------------------------------------------
230
258 template <class Lhs_T, class Rhs_T>
260 {
272 constexpr eq_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
273 : lhs_{ lhs }, rhs_{ rhs }, value_{
274 [&]
275 {
276 // This lambda is called in the constructor to
277 // evaluate the comparison.
278 using std::operator==;
279 using std::operator<;
280
281#if defined(__GNUC__)
282#pragma GCC diagnostic push
283#pragma GCC diagnostic ignored "-Wfloat-equal"
284#pragma GCC diagnostic ignored "-Wconversion"
285#pragma GCC diagnostic ignored "-Wdouble-promotion"
286#pragma GCC diagnostic ignored "-Wsign-compare"
287#if defined(__clang__)
288#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
289#pragma clang diagnostic ignored "-Wpedantic"
290#endif
291#endif
294 {
295 // If both types have values (like numeric constants),
296 // compare them directly.
297 return Lhs_T::value == Rhs_T::value;
298 }
299 else if constexpr (type_traits::has_epsilon_v<Lhs_T>
301 {
302 // If both values have precision, compare them using
303 // the smalles precision.
304 return math::abs (get (lhs) - get (rhs))
305 < math::min_value (Lhs_T::epsilon,
306 Rhs_T::epsilon);
307 }
308 else if constexpr (type_traits::has_epsilon_v<Lhs_T>)
309 {
310 // If only the left operand has precision, use it.
311 return math::abs (get (lhs) - get (rhs))
312 < Lhs_T::epsilon;
313 }
314 else if constexpr (type_traits::has_epsilon_v<Rhs_T>)
315 {
316 // If only the right operand has precision, use it.
317 return math::abs (get (lhs) - get (rhs))
318 < Rhs_T::epsilon;
319 }
320 else
321 {
322 // Call the generic getters, which might
323 // either call the type get() or return the value.
324 return get (lhs) == get (rhs);
325 }
326#if defined(__GNUC__)
327#pragma GCC diagnostic pop
328#endif
329 }()
330 }
331 {
332 }
333
345 [[nodiscard]] constexpr
346 operator bool () const
347 {
348 return value_;
349 }
350
363 [[nodiscard]] constexpr auto
364 lhs (void) const
365 {
366 return get (lhs_);
367 }
368
381 [[nodiscard]] constexpr auto
382 rhs (void) const
383 {
384 return get (rhs_);
385 }
386
390 const Lhs_T lhs_{};
391
395 const Rhs_T rhs_{};
396
400 const bool value_{};
401 };
402
403 // Deduction guide.
404 template <typename Lhs_T, typename Rhs_T>
405 eq_ (const Lhs_T&, const Rhs_T&) -> eq_<Lhs_T, Rhs_T>;
406
407 // ------------------------------------------------------------------------
408
436 template <class Lhs_T, class Rhs_T>
438 {
450 constexpr ne_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
451 : lhs_{ lhs }, rhs_{ rhs }, value_{
452 [&]
453 {
454 using std::operator==;
455 using std::operator!=;
456 using std::operator>;
457
458#if defined(__GNUC__)
459#pragma GCC diagnostic push
460#pragma GCC diagnostic ignored "-Wfloat-equal"
461#pragma GCC diagnostic ignored "-Wconversion"
462#pragma GCC diagnostic ignored "-Wdouble-promotion"
463#pragma GCC diagnostic ignored "-Wsign-compare"
464#if defined(__clang__)
465#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
466#pragma clang diagnostic ignored "-Wpedantic"
467#endif
468#endif
471 {
472 return Lhs_T::value != Rhs_T::value;
473 }
474 else if constexpr (type_traits::has_epsilon_v<Lhs_T>
475 and type_traits::has_epsilon_v<Rhs_T>)
476 {
477 return math::abs (get (lhs_) - get (rhs_))
478 > math::min_value (Lhs_T::epsilon,
479 Rhs_T::epsilon);
480 }
481 else if constexpr (type_traits::has_epsilon_v<Lhs_T>)
482 {
483 return math::abs (get (lhs_) - get (rhs_))
484 > Lhs_T::epsilon;
485 }
486 else if constexpr (type_traits::has_epsilon_v<Rhs_T>)
487 {
488 return math::abs (get (lhs_) - get (rhs_))
489 > Rhs_T::epsilon;
490 }
491 else
492 {
493 return get (lhs_) != get (rhs_);
494 }
495#if defined(__GNUC__)
496#pragma GCC diagnostic pop
497#endif
498 }()
499 }
500 {
501 }
502
514 [[nodiscard]] constexpr
515 operator bool () const
516 {
517 return value_;
518 }
519
532 [[nodiscard]] constexpr auto
533 lhs (void) const
534 {
535 return get (lhs_);
536 }
537
550 [[nodiscard]] constexpr auto
551 rhs (void) const
552 {
553 return get (rhs_);
554 }
555
559 const Lhs_T lhs_{};
560
564 const Rhs_T rhs_{};
565
569 const bool value_{};
570 };
571
572 // Deduction guide.
573 template <typename Lhs_T, typename Rhs_T>
574 ne_ (const Lhs_T&, const Rhs_T&) -> ne_<Lhs_T, Rhs_T>;
575
576 // ------------------------------------------------------------------------
577
603 template <class Lhs_T, class Rhs_T>
605 {
617 constexpr gt_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
618 : lhs_{ lhs }, rhs_{ rhs },
619 value_{ [&]
620 {
621 using std::operator>;
622
623#if defined(__GNUC__)
624#pragma GCC diagnostic push
625#pragma GCC diagnostic ignored "-Wconversion"
626#pragma GCC diagnostic ignored "-Wdouble-promotion"
627#pragma GCC diagnostic ignored "-Wsign-compare"
628#if defined(__clang__)
629#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
630#pragma clang diagnostic ignored "-Wpedantic"
631#endif
632#endif
635 {
636 return Lhs_T::value > Rhs_T::value;
637 }
638 else
639 {
640 return get (lhs_) > get (rhs_);
641 }
642#if defined(__GNUC__)
643#pragma GCC diagnostic pop
644#endif
645 }() }
646 {
647 }
648
661 [[nodiscard]] constexpr
662 operator bool () const
663 {
664 return value_;
665 }
666
679 [[nodiscard]] constexpr auto
680 lhs (void) const
681 {
682 return get (lhs_);
683 }
684 [[nodiscard]] constexpr auto
685
698 rhs (void) const
699 {
700 return get (rhs_);
701 }
702
706 const Lhs_T lhs_{};
707
711 const Rhs_T rhs_{};
712
716 const bool value_{};
717 };
718
719 // Deduction guide.
720 template <typename Lhs_T, typename Rhs_T>
721 gt_ (const Lhs_T&, const Rhs_T&) -> gt_<Lhs_T, Rhs_T>;
722
723 // ------------------------------------------------------------------------
724
750 template <class Lhs_T, class Rhs_T>
752 {
766 constexpr ge_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
767 : lhs_{ lhs }, rhs_{ rhs },
768 value_{ [&]
769 {
770 using std::operator>=;
771
772#if defined(__GNUC__)
773#pragma GCC diagnostic push
774#pragma GCC diagnostic ignored "-Wconversion"
775#pragma GCC diagnostic ignored "-Wdouble-promotion"
776#pragma GCC diagnostic ignored "-Wsign-compare"
777#if defined(__clang__)
778#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
779#pragma clang diagnostic ignored "-Wpedantic"
780#endif
781#endif
784 {
785 return Lhs_T::value >= Rhs_T::value;
786 }
787 else
788 {
789 return get (lhs_) >= get (rhs_);
790 }
791#if defined(__GNUC__)
792#pragma GCC diagnostic pop
793#endif
794 }() }
795 {
796 }
797
810 [[nodiscard]] constexpr
811 operator bool () const
812 {
813 return value_;
814 }
815
828 [[nodiscard]] constexpr auto
829 lhs (void) const
830 {
831 return get (lhs_);
832 }
833
846 [[nodiscard]] constexpr auto
847 rhs (void) const
848 {
849 return get (rhs_);
850 }
851
855 const Lhs_T lhs_{};
856
860 const Rhs_T rhs_{};
861
865 const bool value_{};
866 };
867
868 // Deduction guide.
869 template <typename Lhs_T, typename Rhs_T>
870 ge_ (const Lhs_T&, const Rhs_T&) -> ge_<Lhs_T, Rhs_T>;
871
872 // ------------------------------------------------------------------------
873
899 template <class Lhs_T, class Rhs_T>
901 {
913 constexpr lt_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
914 : lhs_{ lhs }, rhs_{ rhs },
915 value_{ [&]
916 {
917 using std::operator<;
918
919#if defined(__GNUC__)
920#pragma GCC diagnostic push
921#pragma GCC diagnostic ignored "-Wconversion"
922#pragma GCC diagnostic ignored "-Wdouble-promotion"
923#pragma GCC diagnostic ignored "-Wsign-compare"
924#if defined(__clang__)
925#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
926#pragma clang diagnostic ignored "-Wpedantic"
927#endif
928#endif
931 {
932 return Lhs_T::value < Rhs_T::value;
933 }
934 else
935 {
936 return get (lhs_) < get (rhs_);
937 }
938#if defined(__GNUC__)
939#pragma GCC diagnostic pop
940#endif
941 }() }
942 {
943 }
944
957 [[nodiscard]] constexpr
958 operator bool () const
959 {
960 return value_;
961 }
962
975 [[nodiscard]] constexpr auto
976 lhs (void) const
977 {
978 return get (lhs_);
979 }
980
993 [[nodiscard]] constexpr auto
994 rhs (void) const
995 {
996 return get (rhs_);
997 }
998
999 private:
1003 const Lhs_T lhs_{};
1004
1008 const Rhs_T rhs_{};
1009
1013 const bool value_{};
1014 };
1015
1016 // Deduction guide.
1017 template <typename Lhs_T, typename Rhs_T>
1018 lt_ (const Lhs_T&, const Rhs_T&) -> lt_<Lhs_T, Rhs_T>;
1019
1020 // ------------------------------------------------------------------------
1021
1047 template <class Lhs_T, class Rhs_T>
1049 {
1063 constexpr le_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
1064 : lhs_{ lhs }, rhs_{ rhs },
1065 value_{ [&]
1066 {
1067 using std::operator<=;
1068
1069#if defined(__GNUC__)
1070#pragma GCC diagnostic push
1071#pragma GCC diagnostic ignored "-Wconversion"
1072#pragma GCC diagnostic ignored "-Wdouble-promotion"
1073#pragma GCC diagnostic ignored "-Wsign-compare"
1074#if defined(__clang__)
1075#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
1076#pragma clang diagnostic ignored "-Wpedantic"
1077#endif
1078#endif
1081 {
1082 return Lhs_T::value <= Rhs_T::value;
1083 }
1084 else
1085 {
1086 return get (lhs_) <= get (rhs_);
1087 }
1088#if defined(__GNUC__)
1089#pragma GCC diagnostic pop
1090#endif
1091 }() }
1092 {
1093 }
1094
1107 [[nodiscard]] constexpr
1108 operator bool () const
1109 {
1110 return value_;
1111 }
1112
1125
1126 [[nodiscard]] constexpr auto
1127 lhs (void) const
1128 {
1129 return get (lhs_);
1130 }
1131
1144 [[nodiscard]] constexpr auto
1145 rhs (void) const
1146 {
1147 return get (rhs_);
1148 }
1149
1153 const Lhs_T lhs_{};
1154
1158 const Rhs_T rhs_{};
1159
1163 const bool value_{};
1164 };
1165
1166 // Deduction guide.
1167 template <typename Lhs_T, typename Rhs_T>
1168 le_ (const Lhs_T&, const Rhs_T&) -> le_<Lhs_T, Rhs_T>;
1169
1170 // ------------------------------------------------------------------------
1171
1196 template <class Lhs_T, class Rhs_T>
1198 {
1210 constexpr and_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
1211 : lhs_{ lhs }, rhs_{ rhs },
1212 value_{ static_cast<bool> (lhs) and static_cast<bool> (rhs) }
1213 {
1214 }
1215
1227 [[nodiscard]] constexpr
1228 operator bool () const
1229 {
1230 return value_;
1231 }
1232
1245 [[nodiscard]] constexpr auto
1246 lhs (void) const
1247 {
1248 return get (lhs_);
1249 }
1250
1263 [[nodiscard]] constexpr auto
1264 rhs (void) const
1265 {
1266 return get (rhs_);
1267 }
1268
1272 const Lhs_T lhs_{};
1273
1277 const Rhs_T rhs_{};
1278
1282 const bool value_{};
1283 };
1284
1285 // Deduction guide.
1286 template <typename Lhs_T, typename Rhs_T>
1287 and_ (const Lhs_T&, const Rhs_T&) -> and_<Lhs_T, Rhs_T>;
1288
1289 // ------------------------------------------------------------------------
1290
1315 template <class Lhs_T, class Rhs_T>
1317 {
1329 constexpr or_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
1330 : lhs_{ lhs }, rhs_{ rhs },
1331 value_{ static_cast<bool> (lhs) or static_cast<bool> (rhs) }
1332 {
1333 }
1334
1346 [[nodiscard]] constexpr
1347 operator bool () const
1348 {
1349 return value_;
1350 }
1351
1364 [[nodiscard]] constexpr auto
1365 lhs (void) const
1366 {
1367 return get (lhs_);
1368 }
1369
1382 [[nodiscard]] constexpr auto
1383 rhs (void) const
1384 {
1385 return get (rhs_);
1386 }
1387
1391 const Lhs_T lhs_{};
1392
1396 const Rhs_T rhs_{};
1397
1401 const bool value_{};
1402 };
1403
1404 // Deduction guide.
1405 template <typename Lhs_T, typename Rhs_T>
1406 or_ (const Lhs_T&, const Rhs_T&) -> or_<Lhs_T, Rhs_T>;
1407
1408 // ------------------------------------------------------------------------
1409
1433 template <class T>
1435 {
1446 explicit constexpr not_ (const T& t = {})
1447 : t_{ t }, value_{ not static_cast<bool> (t) }
1448 {
1449 }
1450
1462 [[nodiscard]] constexpr
1463 operator bool () const
1464 {
1465 return value_;
1466 }
1467
1479 [[nodiscard]] constexpr auto
1480 value () const
1481 {
1482 return get (t_);
1483 }
1484
1488 const T t_{};
1489
1493 const bool value_{};
1494 };
1495
1496 // Deduction guide.
1497 template <typename T>
1498 not_ (const T&) -> not_<T>;
1499
1500 // ------------------------------------------------------------------------
1501
1502#if defined(__cpp_exceptions)
1503
1530 template <class Callable_T, class Exception_T = void>
1532 {
1544 constexpr explicit throws_ (const Callable_T& func)
1545 : value_{ [&func]
1546 {
1547 try
1548 {
1549 func ();
1550 }
1551 catch (const Exception_T&)
1552 {
1553 return true;
1554 }
1555 catch (...)
1556 {
1557 return false;
1558 }
1559 return false;
1560 }() }
1561 {
1562 }
1563
1576 [[nodiscard]] constexpr
1577 operator bool () const
1578 {
1579 return value_;
1580 }
1581
1585 const bool value_{};
1586 };
1587
1588 // ------------------------------------------------------------------------
1589
1614 template <class Callable_T>
1615 struct throws_<Callable_T, void> : type_traits::op
1616 {
1628 constexpr explicit throws_ (const Callable_T& func)
1629 : value_{ [&func]
1630 {
1631 try
1632 {
1633 func ();
1634 }
1635 catch (...)
1636 {
1637 return true;
1638 }
1639 return false;
1640 }() }
1641 {
1642 }
1643
1655 [[nodiscard]] constexpr
1656 operator bool () const
1657 {
1658 return value_;
1659 }
1660
1664 const bool value_{};
1665 };
1666
1667 // ------------------------------------------------------------------------
1668
1693 template <class Callable_T>
1695 {
1706 constexpr explicit nothrow_ (const Callable_T& func)
1707 : value_{ [&func]
1708 {
1709 try
1710 {
1711 func ();
1712 }
1713 catch (...)
1714 {
1715 return false;
1716 }
1717 return true;
1718 }() }
1719 {
1720 }
1721
1733 [[nodiscard]] constexpr
1734 operator bool () const
1735 {
1736 return value_;
1737 }
1738
1742 const bool value_{};
1743 };
1744
1745#endif
1746
1747 // ------------------------------------------------------------------------
1748
1768 {
1769 public:
1777 const reflection::source_location location);
1778
1783
1792 template <class T>
1793 auto&
1794 operator<< (const T& msg);
1795
1808 [[nodiscard]] constexpr bool
1809 value () const
1810 {
1811 return value_;
1812 }
1813
1814 protected:
1818 bool value_{};
1819
1824 bool abort_ = false;
1825
1830
1835 std::string message_{};
1836 };
1837
1838 // ------------------------------------------------------------------------
1839
1858 template <class Expr_T>
1860 {
1861 public:
1874 constexpr explicit deferred_reporter (
1875 const Expr_T& expr, bool abort,
1876 const reflection::source_location& location);
1877
1882
1883 protected:
1887 const Expr_T expr_{};
1888 };
1889
1890 // ------------------------------------------------------------------------
1891 } // namespace detail
1892
1893 // --------------------------------------------------------------------------
1894} // namespace micro_os_plus::micro_test_plus
1895
1896#if defined(__GNUC__)
1897#pragma GCC diagnostic pop
1898#endif
1899
1900// ----------------------------------------------------------------------------
1901
1902#endif // __cplusplus
1903
1904// ----------------------------------------------------------------------------
1905
1906#endif // MICRO_TEST_PLUS_DETAIL_H_
1907
1908// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.14.0.