16#ifndef MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
17#define MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
25#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
26#include <micro-os-plus/config.h>
41#pragma GCC diagnostic push
42#pragma GCC diagnostic ignored "-Wpadded"
43#pragma GCC diagnostic ignored "-Waggregate-return"
45#pragma clang diagnostic ignored "-Wc++98-compat"
46#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
47#pragma clang diagnostic ignored "-Wctad-maybe-unsupported"
72 initialize (
int argc,
char* argv[],
const char* name =
"Main");
98 template <
typename Callable_T,
typename... Args_T>
100 test_case (
const char* name, Callable_T&& callable, Args_T&&... arguments);
177#if defined(__cpp_exceptions)
186 template <
class Exception_T,
class Callable_T>
187 [[nodiscard]]
constexpr auto
188 throws (
const Callable_T& func)
200 template <
class Callable_T>
201 [[nodiscard]]
constexpr auto
202 throws (
const Callable_T& func)
214 template <
class Callable_T>
215 [[nodiscard]]
constexpr auto
234 template <
class Lhs_T,
class Rhs_T>
235 [[nodiscard]]
constexpr auto
236 eq (
const Lhs_T& lhs,
const Rhs_T& rhs)
251 template <
class Lhs_T,
class Rhs_T>
252 [[nodiscard]]
constexpr auto
253 eq (Lhs_T* lhs, Rhs_T* rhs)
267 template <
class Lhs_T,
class Rhs_T>
268 [[nodiscard]]
constexpr auto
269 ne (
const Lhs_T& lhs,
const Rhs_T& rhs)
283 template <
class Lhs_T,
class Rhs_T>
284 [[nodiscard]]
constexpr auto
285 ne (Lhs_T* lhs, Rhs_T* rhs)
299 template <
class Lhs_T,
class Rhs_T>
300 [[nodiscard]]
constexpr auto
301 gt (
const Lhs_T& lhs,
const Rhs_T& rhs)
315 template <
class Lhs_T,
class Rhs_T>
316 [[nodiscard]]
constexpr auto
317 gt (Lhs_T* lhs, Rhs_T* rhs)
331 template <
class Lhs_T,
class Rhs_T>
332 [[nodiscard]]
constexpr auto
333 ge (
const Lhs_T& lhs,
const Rhs_T& rhs)
347 template <
class Lhs_T,
class Rhs_T>
348 [[nodiscard]]
constexpr auto
349 ge (Lhs_T* lhs, Rhs_T* rhs)
363 template <
class Lhs_T,
class Rhs_T>
364 [[nodiscard]]
constexpr auto
365 lt (
const Lhs_T& lhs,
const Rhs_T& rhs)
379 template <
class Lhs_T,
class Rhs_T>
380 [[nodiscard]]
constexpr auto
381 lt (Lhs_T* lhs, Rhs_T* rhs)
395 template <
class Lhs_T,
class Rhs_T>
396 [[nodiscard]]
constexpr auto
397 le (
const Lhs_T& lhs,
const Rhs_T& rhs)
411 template <
class Lhs_T,
class Rhs_T>
412 [[nodiscard]]
constexpr auto
413 le (Lhs_T* lhs, Rhs_T* rhs)
429 template <
class Expr_T>
430 [[nodiscard]]
constexpr auto
449 template <
class Lhs_T,
class Rhs_T>
450 [[nodiscard]]
constexpr auto
451 _and (
const Lhs_T& lhs,
const Rhs_T& rhs)
469 template <
class Lhs_T,
class Rhs_T>
470 [[nodiscard]]
constexpr auto
471 _or (
const Lhs_T& lhs,
const Rhs_T& rhs)
480 [[nodiscard]]
constexpr auto
481 mut (
const T& t)
noexcept -> T&
483 return const_cast<T&
> (t);
505 [[nodiscard]]
constexpr auto
515 [[nodiscard]]
constexpr auto
527 [[nodiscard]]
constexpr auto
530 return detail::eq_{
static_cast<T&&
> (lhs),
static_cast<T&&
> (rhs) };
539 [[nodiscard]]
constexpr auto
542 return detail::ne_{
static_cast<T&&
> (lhs),
static_cast<T&&
> (rhs) };
550 template <
class Lhs_T,
class Rhs_T,
554 [[nodiscard]]
constexpr auto
565 template <
class Lhs_T,
class Rhs_T,
569 [[nodiscard]]
constexpr auto
580 template <
class Lhs_T,
class Rhs_T,
584 [[nodiscard]]
constexpr auto
595 template <
class Lhs_T,
class Rhs_T,
599 [[nodiscard]]
constexpr auto
610 template <
class Lhs_T,
class Rhs_T,
614 [[nodiscard]]
constexpr auto
615 operator< (
const Lhs_T& lhs,
const Rhs_T& rhs)
625 template <
class Lhs_T,
class Rhs_T,
629 [[nodiscard]]
constexpr auto
630 operator<= (
const Lhs_T& lhs,
const Rhs_T& rhs)
640 template <
class Lhs_T,
class Rhs_T,
644 [[nodiscard]]
constexpr auto
645 operator and (
const Lhs_T& lhs,
const Rhs_T& rhs)
655 template <
class Lhs_T,
class Rhs_T,
659 [[nodiscard]]
constexpr auto
660 operator or (
const Lhs_T& lhs,
const Rhs_T& rhs)
670 template <
class T, type_traits::requires_t<type_traits::is_op_v<T>> = 0>
671 [[nodiscard]]
constexpr auto
672 operator not(
const T& t)
688 is_match (std::string_view input, std::string_view pattern);
699 template <
class T,
class Delim_T>
701 split (T input, Delim_T delim) -> std::vector<T>;
709#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", unsigned int line={}) noexcept
Reporter to display the test results. For failed tests it prints the actual values of the operands,...
The test runner. It maintains a list of test suites which automatically register themselves in their ...
Base class for all test suites.
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.
Separate namespace with custom operators.
typename requires_< Cond >::type requires_t
constexpr auto is_convertible_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.