17#ifndef MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
18#define MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
26#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
27#include <micro-os-plus/config.h>
42#pragma GCC diagnostic push
43#pragma GCC diagnostic ignored "-Wpadded"
44#pragma GCC diagnostic ignored "-Waggregate-return"
46#pragma clang diagnostic ignored "-Wc++98-compat"
47#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
48#pragma clang diagnostic ignored "-Wctad-maybe-unsupported"
73 initialize (
int argc,
char* argv[],
const char* name =
"Main");
99 template <
typename Callable_T,
typename... Args_T>
101 test_case (
const char* name, Callable_T&& callable, Args_T&&... arguments);
178#if defined(__cpp_exceptions)
187 template <
class Exception_T,
class Callable_T>
188 [[nodiscard]]
constexpr auto
189 throws (
const Callable_T& func)
201 template <
class Callable_T>
202 [[nodiscard]]
constexpr auto
203 throws (
const Callable_T& func)
215 template <
class Callable_T>
216 [[nodiscard]]
constexpr auto
235 template <
class Lhs_T,
class Rhs_T>
236 [[nodiscard]]
constexpr auto
237 eq (
const Lhs_T& lhs,
const Rhs_T& rhs)
252 template <
class Lhs_T,
class Rhs_T>
253 [[nodiscard]]
constexpr auto
254 eq (Lhs_T* lhs, Rhs_T* rhs)
268 template <
class Lhs_T,
class Rhs_T>
269 [[nodiscard]]
constexpr auto
270 ne (
const Lhs_T& lhs,
const Rhs_T& rhs)
284 template <
class Lhs_T,
class Rhs_T>
285 [[nodiscard]]
constexpr auto
286 ne (Lhs_T* lhs, Rhs_T* rhs)
300 template <
class Lhs_T,
class Rhs_T>
301 [[nodiscard]]
constexpr auto
302 gt (
const Lhs_T& lhs,
const Rhs_T& rhs)
316 template <
class Lhs_T,
class Rhs_T>
317 [[nodiscard]]
constexpr auto
318 gt (Lhs_T* lhs, Rhs_T* rhs)
332 template <
class Lhs_T,
class Rhs_T>
333 [[nodiscard]]
constexpr auto
334 ge (
const Lhs_T& lhs,
const Rhs_T& rhs)
348 template <
class Lhs_T,
class Rhs_T>
349 [[nodiscard]]
constexpr auto
350 ge (Lhs_T* lhs, Rhs_T* rhs)
364 template <
class Lhs_T,
class Rhs_T>
365 [[nodiscard]]
constexpr auto
366 lt (
const Lhs_T& lhs,
const Rhs_T& rhs)
380 template <
class Lhs_T,
class Rhs_T>
381 [[nodiscard]]
constexpr auto
382 lt (Lhs_T* lhs, Rhs_T* rhs)
396 template <
class Lhs_T,
class Rhs_T>
397 [[nodiscard]]
constexpr auto
398 le (
const Lhs_T& lhs,
const Rhs_T& rhs)
412 template <
class Lhs_T,
class Rhs_T>
413 [[nodiscard]]
constexpr auto
414 le (Lhs_T* lhs, Rhs_T* rhs)
430 template <
class Expr_T>
431 [[nodiscard]]
constexpr auto
450 template <
class Lhs_T,
class Rhs_T>
451 [[nodiscard]]
constexpr auto
452 _and (
const Lhs_T& lhs,
const Rhs_T& rhs)
470 template <
class Lhs_T,
class Rhs_T>
471 [[nodiscard]]
constexpr auto
472 _or (
const Lhs_T& lhs,
const Rhs_T& rhs)
481 [[nodiscard]]
constexpr auto
482 mut (
const T& t)
noexcept -> T&
484 return const_cast<T&
> (t);
506 [[nodiscard]]
constexpr auto
516 [[nodiscard]]
constexpr auto
528 [[nodiscard]]
constexpr auto
531 return detail::eq_{
static_cast<T&&
> (lhs),
static_cast<T&&
> (rhs) };
540 [[nodiscard]]
constexpr auto
543 return detail::ne_{
static_cast<T&&
> (lhs),
static_cast<T&&
> (rhs) };
551 template <
class Lhs_T,
class Rhs_T,
555 [[nodiscard]]
constexpr auto
566 template <
class Lhs_T,
class Rhs_T,
570 [[nodiscard]]
constexpr auto
581 template <
class Lhs_T,
class Rhs_T,
585 [[nodiscard]]
constexpr auto
596 template <
class Lhs_T,
class Rhs_T,
600 [[nodiscard]]
constexpr auto
611 template <
class Lhs_T,
class Rhs_T,
615 [[nodiscard]]
constexpr auto
616 operator< (
const Lhs_T& lhs,
const Rhs_T& rhs)
626 template <
class Lhs_T,
class Rhs_T,
630 [[nodiscard]]
constexpr auto
631 operator<= (
const Lhs_T& lhs,
const Rhs_T& rhs)
641 template <
class Lhs_T,
class Rhs_T,
645 [[nodiscard]]
constexpr auto
646 operator and (
const Lhs_T& lhs,
const Rhs_T& rhs)
656 template <
class Lhs_T,
class Rhs_T,
660 [[nodiscard]]
constexpr auto
661 operator or (
const Lhs_T& lhs,
const Rhs_T& rhs)
671 template <
class T, type_traits::requires_t<type_traits::is_op_v<T>> = 0>
672 [[nodiscard]]
constexpr auto
673 operator not(
const T& t)
689 is_match (std::string_view input, std::string_view pattern);
700 template <
class T,
class Delim_T>
702 split (T input, Delim_T delim) -> std::vector<T>;
710#pragma GCC diagnostic pop
Class template for a deferred reporter specific to an expression.
Local implementation of the std::source_location.
static constexpr auto current(const char *file="unknown", int line={}) noexcept
constexpr auto assume(const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current())
Check a condition and, if false, abort.
constexpr auto nothrow(const Callable_T &func)
Check if a callable doesn't throw an exception.
constexpr auto expect(const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current())
Evaluate a generic condition and report the results.
constexpr auto le(const Lhs_T &lhs, const Rhs_T &rhs)
Generic less than or equal comparator.
constexpr auto ge(const Lhs_T &lhs, const Rhs_T &rhs)
Generic greater than or equal comparator.
constexpr auto ne(const Lhs_T &lhs, const Rhs_T &rhs)
Generic non-equality comparator.
constexpr auto lt(const Lhs_T &lhs, const Rhs_T &rhs)
Generic less than comparator.
constexpr auto gt(const Lhs_T &lhs, const Rhs_T &rhs)
Generic greater than comparator.
constexpr auto eq(const Lhs_T &lhs, const Rhs_T &rhs)
Generic equality comparator. Matches any non-pointer type.
int exit_code(void)
Complete the test and return the exit code.
void initialize(int argc, char *argv[], const char *name="Main")
Initialize the test framework.
constexpr auto _and(const Lhs_T &lhs, const Rhs_T &rhs)
Generic logical and.
constexpr auto _or(const Lhs_T &lhs, const Rhs_T &rhs)
Generic logical or.
constexpr auto _not(const Expr_T &expr)
Generic logical not.
constexpr auto operator>=(const Lhs_T &lhs, const Rhs_T &rhs)
Greater than or equal operator. It matches only if at least one operand is of local type (derived fro...
constexpr auto operator<=(const Lhs_T &lhs, const Rhs_T &rhs)
Less than or equal operator. It matches only if at least one operand is of local type (derived from l...
constexpr auto operator>(const Lhs_T &lhs, const Rhs_T &rhs)
Greater than operator. It matches only if at least one operand is of local type (derived from local o...
constexpr auto operator<(const Lhs_T &lhs, const Rhs_T &rhs)
Less than operator. It matches only if at least one operand is of local type (derived from local op).
constexpr auto operator!=(std::string_view lhs, std::string_view rhs)
Non-equality operator for string_view objects.
constexpr auto operator==(std::string_view lhs, std::string_view rhs)
Equality operator for string_view objects.
void test_case(const char *name, Callable_T &&callable, Args_T &&... arguments)
Define and execute a test case.
auto split(T input, Delim_T delim) -> std::vector< T >
Split a string into a vector of sub-strings.
bool is_match(std::string_view input, std::string_view pattern)
Check if a string matches a pattern.
typename requires_< Cond >::type requires_t
static constexpr auto has_value_v
constexpr auto mut(const T &t) noexcept -> T &
Generic mutator, to remove const from any type.
test_suite_base * current_test_suite
Greater than or equal comparator.
Less than or equal comparator.
Operator to check if the expression does not throw any exception.
Operator to check if the expression throws a specific exception.