|
micro-test-plus 6.0.1
µTest++ Testing Framework
|
Internal implementation details for the µTest++ framework. More...
Namespaces | |
| namespace | anonymous_namespace{expression-formatter.cpp} |
| Local helpers of the expression formatter. | |
| namespace | anonymous_namespace{reporter-tap.cpp} |
| Local helpers of the TAP reporter. | |
| namespace | anonymous_namespace{reporter.cpp} |
| Local helpers of the reporter base class. | |
| namespace | comparison_lookup |
| Names for the checks of the comparison operators, looked up as the apply() functions look them up. | |
| namespace | math |
| Internal mathematical utilities for the µTest++ testing framework. | |
Classes | |
| struct | and_op |
| Logical AND comparator struct template. More... | |
| struct | approx_op |
| Approximate comparator struct template. More... | |
| struct | array_operand |
| An array operand of a comparator, other than a character array. More... | |
| struct | basic_c_string |
| A C string operand of a comparator. More... | |
| struct | binary_op |
| Common base struct template for binary comparators. More... | |
| class | bound_callable |
| Function object that holds a callable and the additional arguments it is invoked with. More... | |
| struct | callable_op |
| Common base struct for callable-wrapping operators. More... | |
| class | callable_ref |
| Non-owning reference to a callable invoked with a Self_T& argument. More... | |
| struct | callable_result |
| The result of the invocation of the callable of a check. More... | |
| class | check_result |
| The result of one check, reported when destroyed. More... | |
| struct | colours |
| Colours used to highlight pass and fail results in test reports. More... | |
| struct | compare_op |
| Relational comparator struct template. More... | |
| struct | comparison_integer |
The integer type used to compare a value of type T. More... | |
| struct | comparison_integer< T > |
| The integer type used to compare a character type. More... | |
| struct | equal_to |
| Equality tag for compare_op. More... | |
| class | expression_formatter |
| Formats values and expressions into an owned string buffer. More... | |
| struct | failed_requirement |
| The exception thrown to stop a test case after a failed require(). More... | |
| struct | failure_info |
| The details of a check, displayed when it fails. More... | |
| struct | floating_point_constant |
| Struct template representing a generic floating-point constant with custom size and precision. More... | |
| struct | greater |
| Greater than tag for compare_op. More... | |
| struct | greater_equal |
| Greater than or equal tag for compare_op. More... | |
| struct | indentation |
| Parameterised stream manipulator for outputting indentation. More... | |
| struct | integral_constant |
| Struct template representing a generic integral constant. More... | |
| struct | integral_min_magnitude |
| Struct template representing the absolute value of the minimum of a signed integral type, as written in a literal. More... | |
| struct | is_bool_wrapper |
| Trait marking the wrappers of a bool, whose condition is ambiguous. More... | |
| struct | is_bool_wrapper< std::optional< T > > |
| The specialisation for std::optional<bool>. | |
| struct | is_bool_wrapper< std::shared_ptr< T > > |
| The specialisation for std::shared_ptr of bool. | |
| struct | is_bool_wrapper< std::unique_ptr< T, Deleter_T > > |
| The specialisation for std::unique_ptr of bool. | |
| struct | less |
| Less than tag for compare_op. More... | |
| struct | less_equal |
| Less than or equal tag for compare_op. More... | |
| struct | named_bool |
| Struct representing a named boolean constant, created by the _b literal. More... | |
| struct | not_equal_to |
| Non-equality tag for compare_op. More... | |
| struct | not_op |
| Logical NOT comparator struct template. More... | |
| struct | nothrow_op |
| Operator struct to check if an expression does not throw any exception. More... | |
| struct | op |
| Empty base struct for the framework expression types. More... | |
| struct | or_op |
| Logical OR comparator struct template. More... | |
| struct | output_route |
| The destinations of a record. More... | |
| struct | plain_text |
| Writes values as text, as the messages of the checks are written. More... | |
| struct | predicate_op |
| Unary predicate struct template. More... | |
| struct | range_element |
| The type of the elements of a range, as iterated by a range-based for statement. More... | |
| struct | range_element< T > |
| The type of the elements of a range with begin() and end() members. More... | |
| class | reporter |
| Abstract base class for the reporters that display test results, including operand values for failures. More... | |
| class | reporter_human |
| Human (standard output) implementation of reporter. More... | |
| class | reporter_tap |
| TAP (Test Anything Protocol) implementation of reporter. More... | |
| class | runnable_base |
| Non-template base for all runnable objects (suites and test cases). More... | |
| class | stopwatch |
| Measures the elapsed time of an operation. More... | |
| struct | throws_op |
| Operator struct template to check if an expression throws a specific exception. More... | |
| struct | throws_op< void > |
| Operator struct to check if an expression throws any exception. More... | |
| class | timestamp |
| Deprecated clock reading. More... | |
| struct | unary_op |
| Common base struct template for unary comparators. More... | |
| struct | value |
| Struct template representing a generic value, accessible via a getter. More... | |
| struct | value< T > |
| Struct template representing a floating-point value with precision control. More... | |
| struct | value_base |
| Base struct template providing common storage and accessors for run-time value-wrapper types. More... | |
Concepts | |
| concept | ambiguous_condition |
| Concept satisfied by the wrappers of a bool, whose condition is ambiguous. | |
| concept | character |
| Concept satisfied by the character types. | |
| concept | character_pointer |
| Concept satisfied by the pointers to the character types. | |
| concept | comparable |
| Concept satisfied when two operands can be compared by the comparator selected by Op. | |
| concept | comparable_operands |
| Concept satisfied when the operands of a comparator can be written and compared. | |
| concept | container_like |
| Concept satisfied when T provides both begin() and end() member functions returning an iterator and its sentinel. | |
| concept | formattable_range |
| Concept satisfied when T is a range that the formatter writes element by element. | |
| concept | free_printable |
| Concept satisfied by the types that have a free operator<< for the formatter. | |
| concept | free_range |
| Concept satisfied when T provides begin() and end() only as functions found by argument-dependent lookup. | |
| concept | function_pointer_pair |
| Concept satisfied by two pointers, one of which points to a function. | |
| concept | generic_callable |
| Concept satisfied by a callable object whose call operator is not a single non-template member function. | |
| concept | has_value |
| Concept satisfied when T is a framework compile-time constant. | |
| Concept satisfied when T is a callable object that returns a printable message. | |
| concept | legacy_checkable |
| Concept satisfied when a type was accepted by expect() and require() before the exclusion of the suspicious conditions. | |
| concept | member_printable |
| Concept satisfied by the types that the formatter writes with one of its own member functions operator<<. | |
| Concept satisfied when T can be appended to the message of a check. | |
| concept | sign_mixed_integers |
| Concept satisfied by two integer types of different signedness. | |
| concept | static_suite_body |
| The body of a static suite written for v5.0.1, whose first parameter is a static_suite& reference. | |
| concept | string_like |
| Concept satisfied when T is a string, convertible to a std::basic_string_view of a character type. | |
| concept | suite_body |
| Concept satisfied by a callable object that can be the body of a suite. | |
| concept | suspicious_condition |
| Concept satisfied when a type is contextually convertible to bool, but is most likely not a condition. | |
| concept | tag_has_symbol |
| Concept satisfied when the tag of a comparator or of a predicate has a symbol that can be written. | |
| concept | test_body |
| Concept satisfied by a callable object that can be the body of a test case. | |
| concept | test_values_range |
| Concept satisfied when T is a range of values for test_each(). | |
| concept | test_values_tuple |
| Concept satisfied when T is a tuple of values for test_each(). | |
| concept | unsupported_condition |
| Concept satisfied by a value that expect() and require() do not accept. | |
Typedefs | |
| using | c_string = basic_c_string<char> |
| The C string operand of char strings. | |
| template<class T> | |
| using | comparison_integer_t = typename comparison_integer<T>::type |
Alias of the integer type used to compare the type T. | |
| template<class T> | |
| using | comparison_operand_t = unwrapped_t<decltype (detail::as_operand (std::declval<T> ()))> |
| The type with which an operand of a comparator is compared. | |
| using | runner_totals = counters |
| Deprecated name of counters. | |
| template<class T> | |
| using | stored_operand_t |
| The type with which an expression stores an operand. | |
| using | timestamps = stopwatch |
| Deprecated name of stopwatch. | |
| template<class T> | |
| using | unwrapped_t |
| The type of an operand, after the framework wrappers are removed by detail::unwrap(). | |
Enumerations | |
| enum class | check_kind { expectation , requirement } |
| The kind of a check, which determines what happens when it fails. More... | |
| enum class | comparison : unsigned char { equal , not_equal , greater , greater_equal , less , less_equal } |
| The comparison operators, as the template argument of the comparable concept. More... | |
| enum class | record_kind : uint8_t { info , suite_heading , suite_result , test_case_heading , test_case_result , skipped , passed_check , failed_check , total , abort } |
| The kinds of records written by the reporters. More... | |
| enum class | throw_outcome : unsigned char { none , std_exception , unknown_exception } |
| The kind of exception thrown by the callable of a check. More... | |
Functions | |
| template<typename Lhs_T, typename Rhs_T> | |
| and_op (Lhs_T &&, Rhs_T &&) -> and_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > > | |
| Deduction guide for the logical AND comparator. | |
| void | append_control_escape (std::string &text, char c) |
| Appends the escape sequence of a control character. | |
| template<class T> requires std::is_arithmetic_v<T> | |
| void | append_number (std::string &buffer, T v) |
| Appends the shortest decimal representation of a numeric value to a buffer. | |
| template<class T> | |
| void | append_pointer (std::string &buffer, T *v) |
| Appends the hexadecimal address of a pointer to a buffer. | |
| template<class Lhs_T, class Rhs_T, class Epsilon_T> | |
| approx_op (Lhs_T &&, Rhs_T &&, Epsilon_T &&) -> approx_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T >, stored_operand_t< Epsilon_T > > | |
| Deduction guide for the approximate comparator. | |
| template<class T> | |
| constexpr comparison_integer_t< T > | as_comparison_integer (const T value) noexcept |
| Converts an integer or a character to the type used to compare it. | |
| template<class T> | |
| constexpr auto | as_operand (T &&t) noexcept -> decltype(auto) |
| Prepares an operand of a comparator. | |
| template<typename Self_T, typename Callable_T, typename... Args_T> | |
| auto | bind_callable (Callable_T &&callable, Args_T &&... arguments) |
| Creates the function object that holds the body of a test case or suite. | |
| template<class Lhs_T, class Rhs_T, class Compare_T> | |
| compare_op (Lhs_T &&, Rhs_T &&, Compare_T) -> compare_op< stored_operand_t< decltype(detail::as_operand(std::declval< Lhs_T >()))>, stored_operand_t< decltype(detail::as_operand(std::declval< Rhs_T >()))>, Compare_T > | |
| Deduction guide for the relational comparator. | |
| template<class Lhs_T, class Rhs_T, class Epsilon_T> | |
| constexpr bool | differ_by_at_most (Lhs_T lhs, Rhs_T rhs, Epsilon_T epsilon) |
| Tells whether two numbers differ by at most a tolerance. | |
| reporter & | endl (reporter &stream) |
| Output stream manipulator for ending a line in test reports. | |
| void | escape_control_characters (std::string &name) |
| Escapes the control characters of a name. | |
| indentation | indent (size_t level) |
| Factory function that creates an indentation manipulator. | |
| template<class T, char... Cs> | |
| constexpr auto | integral_literal (void) |
| Creates the compile-time constant of an integer literal. | |
| template<class T, class R> requires (container_like<R> and std::three_way_comparable_with< T, typename range_element<R>::type>) | |
| constexpr auto | operator<=> (const array_operand< T > &lhs, const R &rhs) |
| Orders an array operand and a range lexicographically. | |
| template<character Char_T> | |
| constexpr std::strong_ordering | operator<=> (const basic_c_string< Char_T > &lhs, const basic_c_string< Char_T > &rhs) noexcept |
| Orders two C string operands. | |
| template<character Char_T> | |
| constexpr std::strong_ordering | operator<=> (const basic_c_string< Char_T > &lhs, std::type_identity_t< std::basic_string_view< Char_T > > rhs) noexcept |
| Orders a C string operand and a string. | |
| template<class T, class R> requires (container_like<R> and std::equality_comparable_with< T, typename range_element<R>::type>) | |
| constexpr bool | operator== (const array_operand< T > &lhs, const R &rhs) |
| Compares an array operand with a range for equality. | |
| template<character Char_T> | |
| constexpr bool | operator== (const basic_c_string< Char_T > &lhs, const basic_c_string< Char_T > &rhs) noexcept |
| Compares two C string operands for equality. | |
| template<character Char_T> | |
| constexpr bool | operator== (const basic_c_string< Char_T > &lhs, std::nullptr_t) noexcept |
| Checks whether a C string operand is a null pointer. | |
| template<character Char_T> | |
| constexpr bool | operator== (const basic_c_string< Char_T > &lhs, std::type_identity_t< std::basic_string_view< Char_T > > rhs) noexcept |
| Compares a C string operand with a string. | |
| template<typename Lhs_T, typename Rhs_T> | |
| or_op (Lhs_T &&, Rhs_T &&) -> or_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > > | |
| Deduction guide for the logical OR comparator. | |
| template<class T, class Predicate_T> | |
| predicate_op (T &&, Predicate_T) -> predicate_op< stored_operand_t< decltype(detail::as_operand(std::declval< T >()))>, Predicate_T > | |
| Deduction guide for the unary predicate. | |
| void | read_clock (timespec &ts) noexcept |
| Reads the system clock. | |
| template<class Tag_T> | |
| constexpr void | reject_compare_tag (void) noexcept |
| Stops the compilation of a compare_op whose tag is rejected, with a message that tells why. | |
| template<comparison Op, class Lhs_T, class Rhs_T> | |
| constexpr void | reject_comparison (void) noexcept |
| Stops the compilation of a comparator whose operands are rejected, with a message that tells why. | |
| template<class Tag_T> | |
| constexpr void | reject_predicate_tag (void) noexcept |
| Stops the compilation of a predicate_op whose tag is rejected, with a message that tells why. | |
| template<typename Callable_T, typename... Args_T> | |
| constexpr void | reject_suite_body (void) noexcept |
| Stops the compilation with a message that tells what the body of a suite takes. | |
| template<typename Callable_T, typename... Args_T> | |
| constexpr void | reject_test_body (void) noexcept |
| Stops the compilation with a message that tells what the body of a test case takes. | |
| template<class Self_T, class Values_T, class Callable_T> | |
| void | test_each_value (Self_T &self, const located_name &name, Values_T &&values, Callable_T &callable) |
| Adds and runs a test case for each value. | |
| template<class T> | |
| decltype(auto) constexpr | unwrap (const T &t) |
| Returns the value wrapped by a framework type, or the operand itself. | |
| template<class T> | |
| constexpr decltype(auto) | unwrap (const T &t) |
| Returns the value wrapped by a framework type, or the operand itself. | |
| template<class Lhs_T, class Rhs_T> requires (extension::has_epsilon<Lhs_T> or extension::has_epsilon<Rhs_T>) | |
| constexpr bool | within_tolerance (const Lhs_T &lhs, const Rhs_T &rhs) |
| Deprecated check whether two operands are equal within the tolerance of the floating-point wrappers. | |
Variables | |
| constexpr colours | colours_none {} |
| Predefined colour set, without escape sequences. | |
| constexpr colours | colours_red_green |
| Predefined colour set, with green for pass and red for fail. | |
| template<typename... Ts> | |
| constexpr bool | dependent_false_v = false |
| A value that is always false, but depends on the template arguments. | |
The detail namespace encapsulates the internal mechanisms, helper structures, and implementation utilities employed by the µTest++ testing framework. These components do not form part of the public API and may be modified without prior notice.
Within this namespace, one will find the deprecated value wrappers (declared in deprecated.h), the value unwrapping helper, comparator structures for logical and relational operations, mechanisms for exception checking, the reporters, the check result, and the expression formatter.
All definitions within detail are intended exclusively for internal use; the applications do not need to name them.
The type to which as_operand() converts the char arrays, including the string literals, and the char pointers; the framework itself names basic_c_string, and the alias is kept for the tests that name the type of a comparator.
| using micro_os_plus::micro_test_plus::detail::comparison_integer_t = typename comparison_integer<T>::type |
Used by sign_mixed_integers, to tell the signedness, and by as_comparison_integer(), to convert the operands.
| T | The type of the operand. |
Definition at line 326 of file detail-inlines.h.
| using micro_os_plus::micro_test_plus::detail::comparison_operand_t = unwrapped_t<decltype (detail::as_operand (std::declval<T> ()))> |
The type of the operand after as_operand() and unwrap(), without references and qualifiers; for example detail::basic_c_string<char> for a string literal.
| T | The type deduced for the operand, possibly a reference. |
Definition at line 386 of file detail-inlines.h.
| using micro_os_plus::micro_test_plus::detail::stored_operand_t |
Applied by the deduction guides and the factory functions to the type deduced for a forwarding reference: X& (or const X&) for an lvalue, X for an rvalue.
An lvalue is copied into the expression, so that an expression built in a function from its parameters, and returned, does not refer to the destroyed locals of that function. An rvalue is moved into the expression, so that an expression that outlives the statement, like auto op = eq (f (), 1);, does not refer to a destroyed temporary.
The arrays and the character pointers are first converted by as_operand() to basic_c_string or array_operand, which are stored, but which refer to the characters or to the elements of the operand, without copying them; such an expression is valid only as long as the operand.
Only an lvalue of a class type that cannot be copied (for example a std::unique_ptr) is stored as a const reference; such a reference remains valid only as long as the named operand, which is always the case within the statement that checks the expression.
| T | The type deduced for a forwarding reference. |
| using micro_os_plus::micro_test_plus::detail::unwrapped_t |
| T | The type of the operand, possibly a reference. |
Without references and qualifiers; for example int for a to_i wrapper and for a 42_i literal, and the type itself for the other operands. Used by extension::approx_operand and by comparison_operand_t.
|
strong |
An enumeration rather than a Boolean flag, so that the call sites name the kind of the check.
Definition at line 93 of file check-result.h.
|
strong |
A single concept, parametrised by the operator, checks the operands of all the comparators (eq(), ne(), gt(), ge(), lt(), and le()).
| Enumerator | |
|---|---|
| equal | The == operator, checked by eq(). |
| not_equal | The != operator, checked by ne(). |
| greater | The > operator, checked by gt(). |
| greater_equal | The >= operator, checked by ge(). |
| less | The < operator, checked by lt(). |
| less_equal | The <= operator, checked by le(). |
Definition at line 416 of file detail-inlines.h.
|
strong |
The output policy, which decides where each kind of record is written at each verbosity level, is in reporter::route(). The concrete reporters only format the records and ask where they go.
Definition at line 160 of file reporter.h.
|
strong |
Kept only when the check failed, to be written in the report.
Definition at line 1335 of file detail.h.
| micro_os_plus::micro_test_plus::detail::and_op | ( | Lhs_T && | , |
| Rhs_T && | ) -> and_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > > |
Deduces Lhs_T and Rhs_T from the constructor arguments, so that and_op{ lhs, rhs } can be written without explicit template arguments. The operand types are deduced as forwarding references, and stored as stored_operand_t selects.
| void micro_os_plus::micro_test_plus::detail::append_control_escape | ( | std::string & | text, |
| char | c ) |
Writes the usual escape of the character (\\0, \\a, \\b, \\t, \\n, \\v, \\f, or \\r), or \\xHH for the other ones. Used for the characters of the messages and of the names that would otherwise reach the console and the output files unchanged. Defined in src/expression-formatter.cpp.
| text | The text to append to. |
| c | The control character. |
The usual escapes for the characters that have one; the other ones, including DEL, as \\xHH.
Definition at line 401 of file expression-formatter.cpp.
References append_control_escape().
Referenced by append_control_escape(), micro_os_plus::micro_test_plus::detail::anonymous_namespace{expression-formatter.cpp}::append_plain(), escape_control_characters(), and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<().
| void micro_os_plus::micro_test_plus::detail::append_number | ( | std::string & | buffer, |
| T | v ) |
| T | The numeric type to format. |
| buffer | The string to append to. |
| v | The value to format. |
The value is formatted into a local buffer, which is then appended to buffer.
For long double, a platform-specific path is chosen:
For all other numeric types, std::to_chars is called directly, providing locale-independent formatting. The snprintf() path uses the decimal point of the C locale, which is . unless the application changes it with setlocale().
Definition at line 1348 of file detail-inlines.h.
References append_number().
Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::append_first_difference(), append_number(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), and micro_os_plus::micro_test_plus::detail::reporter::operator<<().
| void micro_os_plus::micro_test_plus::detail::append_pointer | ( | std::string & | buffer, |
| T * | v ) |
Shared by the reporter and the expression_formatter, so that the pointers are displayed identically in the messages and in the expressions. Pointers to const or volatile objects, and function pointers, are accepted too.
| T | The type pointed to (an object or a function type). |
| buffer | The string to append to. |
| v | The pointer. |
Null pointers are rendered as "0x0", regardless of the platform, avoiding platform-specific representations such as "(nil)" on Linux/glibc. Non-null pointers are formatted with snprintf(), using the p specifier.
The p specifier expects a void*. Object pointers are converted implicitly to const volatile void*, which accepts any qualification, and the qualifiers are then removed with const_cast; a reinterpret_cast to void* would not compile for pointers to const objects. The object is not accessed. Function pointers, which do not convert to void* implicitly, use reinterpret_cast.
Definition at line 1454 of file detail-inlines.h.
References append_pointer().
Referenced by append_pointer(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), and micro_os_plus::micro_test_plus::detail::reporter::operator<<().
| micro_os_plus::micro_test_plus::detail::approx_op | ( | Lhs_T && | , |
| Rhs_T && | , | ||
| Epsilon_T && | ) -> approx_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T >, stored_operand_t< Epsilon_T > > |
Deduces Lhs_T, Rhs_T, and Epsilon_T from the constructor arguments, which are stored as stored_operand_t selects.
|
nodiscardconstexprnoexcept |
The conversion keeps the value, since the type has the same size and signedness. Applied to both operands of the std::cmp_*() functions, which do not accept the character types.
| T | The type of the operand. |
| value | The operand. |
Definition at line 343 of file detail-inlines.h.
References as_comparison_integer().
Referenced by micro_os_plus::micro_test_plus::detail::equal_to::apply(), micro_os_plus::micro_test_plus::detail::greater::apply(), micro_os_plus::micro_test_plus::detail::greater_equal::apply(), micro_os_plus::micro_test_plus::detail::less::apply(), micro_os_plus::micro_test_plus::detail::less_equal::apply(), micro_os_plus::micro_test_plus::detail::not_equal_to::apply(), and as_comparison_integer().
|
nodiscardconstexprnoexcept |
The arrays and the pointers of the character types (char, wchar_t, char8_t, char16_t, and char32_t, but not signed char or unsigned char, which are byte buffers) are converted to basic_c_string, so that they are compared by content; the other arrays, including those of volatile characters, are converted to array_operand, so that they are compared element by element, the functions to function pointers, and all other operands are returned unchanged, so the other pointers, including the pointers to volatile characters, and the functions are compared by address.
The other operands are forwarded, so that the comparator moves a temporary, and refers to a named operand.
| T | The type deduced for the forwarding reference. |
| t | The operand. |
Arrays of the character types are converted using their size as a bound, pointers to them using the null terminator; the const qualifier of the characters is ignored. The volatile characters are not strings, since basic_c_string cannot refer to them: an array of them is converted to array_operand, like the other arrays, and compared element by element, and a pointer to them is forwarded, and compared by address, like the other pointers. The functions are converted to function pointers. Every other operand is forwarded, unchanged, as an lvalue or an rvalue reference.
The qualifiers of an array are those of its elements, so the element type is taken from the type of the argument, not from the type without qualifiers, which would lose the volatile of the elements, and the conversion to the pointer to const elements would not compile.
Definition at line 1725 of file detail-inlines.h.
References as_operand().
Referenced by micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::predicate_op< T, Predicate_T >::predicate_op(), as_operand(), compare_op(), micro_os_plus::micro_test_plus::eq(), micro_os_plus::micro_test_plus::ge(), micro_os_plus::micro_test_plus::gt(), micro_os_plus::micro_test_plus::le(), micro_os_plus::micro_test_plus::lt(), and micro_os_plus::micro_test_plus::ne().
|
nodiscard |
Without additional arguments, the callable already has the signature void (Self_T&), and a copy of it is returned, without a wrapper.
Otherwise, a bound_callable stores copies of the callable and of the arguments (decayed, as by auto), since a suite may run after the caller's temporaries are gone; the callable receives the copies as non-const lvalues. A reference parameter thus refers to the copy; to refer to the caller's object, pass a pointer, or std::ref(), which converts to a T& parameter (an auto& parameter receives the std::reference_wrapper itself).
The returned object holds a copy of the callable (decayed, as by auto) when there are no additional arguments; otherwise it is a bound_callable that holds copies of the callable and of the arguments, and passes the arguments after the leading reference, which is passed when the body is invoked. No memory is allocated, other than by the copies themselves.
A suite stores the object in a std::function, since it runs later; a test case, which runs immediately, refers to it with a callable_ref.
| Self_T | The type referred to by the first parameter of the callable (test_case or suite). |
| Callable_T | The type of the callable object. |
| Args_T | The types of the additional callable arguments. |
| callable | A generic callable object, usually a lambda. |
| arguments | A possibly empty list of arguments forwarded to the callable after the leading Self_T& reference. |
Definition at line 344 of file test-inlines.h.
References bind_callable().
Referenced by bind_callable(), and micro_os_plus::micro_test_plus::detail::runnable_base::create_test_case().
| micro_os_plus::micro_test_plus::detail::compare_op | ( | Lhs_T && | , |
| Rhs_T && | , | ||
| Compare_T | ) -> compare_op< stored_operand_t< decltype(detail::as_operand(std::declval< Lhs_T >()))>, stored_operand_t< decltype(detail::as_operand(std::declval< Rhs_T >()))>, Compare_T > |
Deduces Lhs_T, Rhs_T, and Compare_T from the constructor arguments, so that compare_op{ lhs, rhs, equal_to{} } can be written without explicit template arguments. The operand types are deduced as forwarding references, prepared by as_operand(), and stored as stored_operand_t selects.
References as_operand(), and differ_by_at_most().
|
nodiscardconstexpr |
If the three values are integers, the distance is computed exactly, as an unsigned value, also for operands of mixed signedness, and compared with the tolerance with std::cmp_less_equal(), so that neither overflows nor wraps around. Otherwise, the values are converted to their common floating-point type, and the absolute value of the difference is compared with the tolerance. A negative tolerance, or a NaN, makes the result false.
| Lhs_T | The arithmetic type of the first value. |
| Rhs_T | The arithmetic type of the second value. |
| Epsilon_T | The arithmetic type of the tolerance. |
| lhs | The first value. |
| rhs | The second value. |
| epsilon | The tolerance. |
| true | The distance between the values is less than or equal to the tolerance. |
| false | Otherwise. |
For the integers, the larger value is selected with std::cmp_less(), and the distance is computed in std::uintmax_t: when both values have the same sign, as the modular difference of their conversions, which is exact; otherwise, as the sum of the larger value and of the magnitude of the negative one. A sum that does not fit in std::uintmax_t is flagged as an overflow, and gives false, since the true distance is larger than any tolerance. The tolerance is compared with std::cmp_less_equal(), so a negative one gives false.
For the other types, the values are converted to their common type, which is a floating-point one, so std::int64_t values compared with a float tolerance lose precision; the comparison is inclusive, so a distance equal to the tolerance succeeds. Two equal values, including two infinities of the same sign, whose difference would be NaN, are at the distance zero; a NaN operand always fails.
Definition at line 940 of file detail-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::abs(), and differ_by_at_most().
Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), compare_op(), and differ_by_at_most().
Calls reporter::end_line(), which appends a line ending to the internal buffer. Unlike std::endl, it does not flush; the buffer is written later, by the concrete reporters.
| stream | Reference to the reporter instance. |
The endl function calls reporter::end_line(), which appends a newline character to the buffer of the specified reporter.
Definition at line 218 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::end_line(), and endl().
Referenced by endl(), micro_os_plus::micro_test_plus::detail::reporter_human::fail_suite(), micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_prefix(), micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_suffix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix(), micro_os_plus::micro_test_plus::detail::reporter_human::output_pass_suffix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_suffix(), and micro_os_plus::micro_test_plus::detail::reporter_tap::pass_without_text().
| void micro_os_plus::micro_test_plus::detail::escape_control_characters | ( | std::string & | name | ) |
Replaces, in place, the control characters other than the tab, including the line feed and the NUL, with their escape sequences, so that the names reach the console and the output files as one line of visible text. Defined in src/test.cpp.
| name | The name to escape. |
The text is scanned first, so that a name without control characters is not touched. The tab is kept; all the other control characters, including the line feed and the NUL, and DEL, are replaced.
Definition at line 80 of file test.cpp.
References append_control_escape(), and escape_control_characters().
Referenced by micro_os_plus::micro_test_plus::located_name::located_name(), micro_os_plus::micro_test_plus::located_name::located_name(), micro_os_plus::micro_test_plus::located_name::located_name(), micro_os_plus::micro_test_plus::located_name::located_name(), and escape_control_characters().
|
inlinenodiscard |
Returns an indentation aggregate initialised with level.
Allows writing reporter << indent(n) instead of constructing the manipulator explicitly.
| level | The number of four-space indentation levels. |
Definition at line 64 of file reporter-inlines.h.
References indent().
Referenced by micro_os_plus::micro_test_plus::detail::reporter_human::begin_test_case(), micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case(), micro_os_plus::micro_test_plus::detail::reporter_human::display_open_heading(), micro_os_plus::micro_test_plus::detail::reporter_tap::display_open_heading(), micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite(), micro_os_plus::micro_test_plus::detail::reporter_human::end_test_case(), micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case(), micro_os_plus::micro_test_plus::detail::reporter_human::fail_suite(), micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite(), indent(), micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix(), micro_os_plus::micro_test_plus::detail::reporter_human::output_pass_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::pass_without_text(), micro_os_plus::micro_test_plus::detail::reporter_human::skip_test_case(), and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case().
|
nodiscardconstexpr |
| T | The integral type of the literal. |
| Cs | The characters of the literal, as received by a literal operator template. |
Used by the integer literal operators (_i, _u8, etc.).
The value is checked by math::integer_magnitude(), which accepts, for the signed types, the absolute value of the minimum; this value does not fit in T, so it is represented by integral_min_magnitude<T>.
Definition at line 581 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::integral_constant< N >::integral_constant(), micro_os_plus::micro_test_plus::detail::math::integer_magnitude(), and integral_literal().
Referenced by integral_literal(), micro_os_plus::micro_test_plus::literals::operator""_c(), micro_os_plus::micro_test_plus::literals::operator""_i(), micro_os_plus::micro_test_plus::literals::operator""_i16(), micro_os_plus::micro_test_plus::literals::operator""_i32(), micro_os_plus::micro_test_plus::literals::operator""_i64(), micro_os_plus::micro_test_plus::literals::operator""_i8(), micro_os_plus::micro_test_plus::literals::operator""_l(), micro_os_plus::micro_test_plus::literals::operator""_ll(), micro_os_plus::micro_test_plus::literals::operator""_s(), micro_os_plus::micro_test_plus::literals::operator""_sc(), micro_os_plus::micro_test_plus::literals::operator""_u(), micro_os_plus::micro_test_plus::literals::operator""_u16(), micro_os_plus::micro_test_plus::literals::operator""_u32(), micro_os_plus::micro_test_plus::literals::operator""_u64(), micro_os_plus::micro_test_plus::literals::operator""_u8(), micro_os_plus::micro_test_plus::literals::operator""_uc(), micro_os_plus::micro_test_plus::literals::operator""_ul(), micro_os_plus::micro_test_plus::literals::operator""_ull(), and micro_os_plus::micro_test_plus::literals::operator""_us().
|
nodiscardconstexpr |
| T | The element type of the array operand. |
| R | The type of the range. |
| lhs | The array operand. |
| rhs | The range, which may be another array operand. |
A range that is a prefix of the other is the lesser one.
Definition at line 1696 of file detail-inlines.h.
References micro_os_plus::micro_test_plus::detail::array_operand< T >::begin(), micro_os_plus::micro_test_plus::detail::array_operand< T >::end(), and operator<=>().
|
nodiscardconstexprnoexcept |
| Char_T | The character type. |
| lhs | The left operand. |
| rhs | The right operand. |
A null pointer orders before any string.
Definition at line 1594 of file detail-inlines.h.
Referenced by operator<=>().
|
nodiscardconstexprnoexcept |
| Char_T | The character type. |
| lhs | The C string operand. |
| rhs | The string. |
A null pointer orders before any string.
Definition at line 1610 of file detail-inlines.h.
|
nodiscardconstexpr |
| T | The element type of the array operand. |
| R | The type of the range. |
| lhs | The array operand. |
| rhs | The range, which may be another array operand. |
| true | The ranges have the same size and equal elements. |
| false | Otherwise. |
Ranges of different sizes are not equal, without comparing any element. The elements are compared as the scalar operands of eq() are, with equal_to::apply(), so that integers of different signedness are compared by value, not by converting the signed one to the unsigned type.
Definition at line 1681 of file detail-inlines.h.
References micro_os_plus::micro_test_plus::detail::array_operand< T >::begin(), and micro_os_plus::micro_test_plus::detail::array_operand< T >::end().
|
nodiscardconstexprnoexcept |
| Char_T | The character type. |
| lhs | The left operand. |
| rhs | The right operand. |
| true | Both are null, or both are strings with the same characters. |
| false | Otherwise. |
Two null pointers are equal; a null pointer is not equal to any string, not even an empty one.
Definition at line 1555 of file detail-inlines.h.
|
nodiscardconstexprnoexcept |
| Char_T | The character type. |
| lhs | The C string operand. |
| true | The operand is a null pointer. |
| false | Otherwise. |
Returns whether the operand is a null pointer.
Definition at line 1584 of file detail-inlines.h.
|
nodiscardconstexprnoexcept |
Also used for the standard strings of the same character type, which convert to the string view, and, as a rewritten candidate, with the operands in the reverse order.
| Char_T | The character type. |
| lhs | The C string operand. |
| rhs | The string. |
| true | The operand is not null and has the same characters. |
| false | Otherwise. |
A null pointer is not equal to any string.
Definition at line 1571 of file detail-inlines.h.
| micro_os_plus::micro_test_plus::detail::or_op | ( | Lhs_T && | , |
| Rhs_T && | ) -> or_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > > |
Deduces Lhs_T and Rhs_T from the constructor arguments, so that or_op{ lhs, rhs } can be written without explicit template arguments. The operand types are deduced as forwarding references, and stored as stored_operand_t selects.
| micro_os_plus::micro_test_plus::detail::predicate_op | ( | T && | , |
| Predicate_T | ) -> predicate_op< stored_operand_t< decltype(detail::as_operand(std::declval< T >()))>, Predicate_T > |
Deduces T and Predicate_T from the constructor arguments, so that predicate_op{ t, even{} } can be written without explicit template arguments. The operand type is deduced as a forwarding reference, prepared by as_operand(), and stored as stored_operand_t selects.
|
noexcept |
Isolates the platform-specific access to the system clock, used by stopwatch and by the deprecated timestamp class. The clock is monotonic on POSIX; without a clock, ts is left unchanged, so the callers clear it first when a zero value must mean that the clock was not read.
| [out] | ts | The timespec where the reading is stored. |
On Windows, the current time is captured via timespec_get() with TIME_UTC. On POSIX platforms with CLOCK_MONOTONIC defined, clock_gettime(CLOCK_MONOTONIC) is used to obtain a monotonic reading. On platforms where neither macro is defined, ts is left unchanged.
Definition at line 66 of file stopwatch.cpp.
References read_clock().
Referenced by micro_os_plus::micro_test_plus::detail::timestamp::timestamp(), read_clock(), micro_os_plus::micro_test_plus::detail::stopwatch::start(), micro_os_plus::micro_test_plus::detail::stopwatch::stop(), micro_os_plus::micro_test_plus::detail::stopwatch::timestamp_begin(), and micro_os_plus::micro_test_plus::detail::stopwatch::timestamp_end().
|
constexprnoexcept |
Always fails the static assertion that applies, since it is called only when extension::compare_tag is not satisfied: the missing or unprintable symbol is reported first, then the apply() that cannot be called with the operands, or whose result is not convertible to bool.
| Tag_T | The tag of the comparator. |
Definition at line 778 of file detail-inlines.h.
References reject_compare_tag().
Referenced by reject_compare_tag().
|
constexprnoexcept |
Always fails the static assertion that applies, since it is called only when comparable_operands is not satisfied: an operand that cannot be written is reported first, then the operator that the operands do not support. Called by the overloads of the comparators that accept the rejected operands, so that the compiler shows this message instead of a list of the unsatisfied constraints.
| Op | The comparison of the comparator. |
| Lhs_T | The type of the left operand. |
| Rhs_T | The type of the right operand. |
Definition at line 557 of file detail-inlines.h.
References equal, greater, greater_equal, less, not_equal, and reject_comparison().
Referenced by reject_comparison().
|
constexprnoexcept |
As reject_compare_tag(), for the tag of a predicate, whose apply() takes one operand; called only when extension::predicate_tag is not satisfied.
| Tag_T | The tag of the predicate. |
Definition at line 815 of file detail-inlines.h.
References reject_predicate_tag().
Referenced by reject_predicate_tag().
|
constexprnoexcept |
Always fails the static assertion that applies, since it is called only when suite_body is not satisfied. A body that cannot be copied, or a body written for a test case, is recognised, to say so.
Called by the overloads of runner::add_suite() and of the static_suite constructor that are selected when the callable is not a valid body, as reject_test_body() is for the test cases.
| Callable_T | The type of the callable. |
| Args_T | The types of the additional arguments. |
Definition at line 448 of file test-inlines.h.
References dependent_false_v, and reject_suite_body().
Referenced by micro_os_plus::micro_test_plus::runner::add_suite(), and reject_suite_body().
|
constexprnoexcept |
Always fails the static assertion that applies, since it is called only when test_body is not satisfied. A body written for a suite is recognised, to say so.
Called by the overloads of test_case::test() and suite::test() that are selected when the callable is not a valid body, so that the diagnostic names the mistake in the terms of the application, instead of the concepts and the instantiation stack. Never called at run time.
| Callable_T | The type of the callable. |
| Args_T | The types of the additional arguments. |
Definition at line 422 of file test-inlines.h.
References dependent_false_v, and reject_test_body().
Referenced by reject_test_body().
| void micro_os_plus::micro_test_plus::detail::test_each_value | ( | Self_T & | self, |
| const located_name & | name, | ||
| Values_T && | values, | ||
| Callable_T & | callable ) |
For each value, the name is built in a local string, which lives while the test case runs, since a test case runs within the call to test(), and the test case is added with test(), with the location of the call to test_each(). The callable receives each value as a const lvalue, referring to the element itself; neither the values nor the callable are copied. The values of a range are iterated by a range-based for statement, and those of a tuple are expanded by std::apply(), in order.
The common implementation of test_case::test_each() and suite::test_each().
| Self_T | The type of the test case or suite. |
| Values_T | The type of the range or tuple of values. |
| Callable_T | The type of the callable object. |
| self | The test case or suite to which the test cases are added. |
| name | The common name of the test cases. |
| values | The range or tuple of values. |
| callable | The callable object, invoked with the test case and each value. |
Definition at line 1029 of file test-inlines.h.
References micro_os_plus::micro_test_plus::detail::plain_text::append(), micro_os_plus::micro_test_plus::located_name::location(), micro_os_plus::micro_test_plus::located_name::name(), and test_each_value().
Referenced by micro_os_plus::micro_test_plus::suite::test_each(), micro_os_plus::micro_test_plus::suite::test_each(), micro_os_plus::micro_test_plus::test_case::test_each(), micro_os_plus::micro_test_plus::test_case::test_each(), and test_each_value().
|
nodiscardconstexpr |
Always call it qualified, as detail::unwrap(), so that argument-dependent lookup cannot select a function of the application, defined in the namespace of an operand.
The operand is returned by reference, without a copy; the result is valid only as long as the operand.
| T | The type of the operand. |
| t | The operand. |
If the type T is a framework expression type (see extension::is_op) that provides a get() member function, it is invoked and its result returned. Otherwise a reference to the argument itself is returned, so that the types of the application, even those with a get() member function, are compared with their own operators, without a copy. The selection is performed at compile time via if constexpr with an inline requires expression; the return type is deduced with decltype (auto) from the selected branch.
Definition at line 98 of file detail-inlines.h.
References unwrap().
Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::predicate_op< T, Predicate_T >::predicate_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs(), micro_os_plus::micro_test_plus::detail::unary_op< T >::operand(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs(), unwrap(), and within_tolerance().
|
nodiscardconstexpr |
If the type T is a framework expression type (see extension::is_op) that provides a get() member function, it is invoked and its result returned. Otherwise a reference to the argument itself is returned, so that the types of the application, even those with a get() member function, are compared with their own operators, without a copy. The selection is performed at compile time via if constexpr with an inline requires expression; the return type is deduced with decltype (auto) from the selected branch.
Always call it qualified, as detail::unwrap(), so that argument-dependent lookup cannot select a function of the application, defined in the namespace of an operand.
The operand is returned by reference, without a copy; the result is valid only as long as the operand.
| T | The type of the operand. |
| t | The operand. |
Definition at line 98 of file detail-inlines.h.
References unwrap().
Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::predicate_op< T, Predicate_T >::predicate_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs(), micro_os_plus::micro_test_plus::detail::unary_op< T >::operand(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs(), unwrap(), and within_tolerance().
|
inlineconstexpr |
Used by the formatters that write the messages of the checks, which are never coloured; all members are empty strings.
Definition at line 184 of file expression-formatter.h.
Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter(), and micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter().
|
inlineconstexpr |
Assigned by reporters that output to a colour-capable terminal; the members are, in order, the reset, pass, and fail ANSI escape sequences.
Definition at line 171 of file expression-formatter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter_human::reporter_human().
|
inlineconstexpr |
Used as the condition of the static_assert of the functions that reject an argument, so that they fail only when instantiated, and their diagnostic has the message, not the concepts that were not satisfied.
| Ts | The template arguments to depend on. |
Definition at line 1258 of file test.h.
Referenced by reject_suite_body(), and reject_test_body().