Skip to content

Commit

Permalink
doxygen metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Nov 21, 2023
1 parent b7f2791 commit 3b44a8c
Show file tree
Hide file tree
Showing 10 changed files with 1,094 additions and 689 deletions.
10 changes: 9 additions & 1 deletion include/micro-os-plus/detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace micro_os_plus::micro_test_plus
// --------------------------------------------------------------------------

/**
* @brief Implementation details, not part of the public API.
* @brief Namespace with implementation details, not part of the public API.
*/
namespace detail
{
Expand Down Expand Up @@ -678,6 +678,10 @@ namespace micro_os_plus::micro_test_plus

// ------------------------------------------------------------------------

/**
* @brief Base class for a deferred reporter, that collects the
* messages into a string.
*/
class deferred_reporter_base
{
public:
Expand Down Expand Up @@ -708,6 +712,10 @@ namespace micro_os_plus::micro_test_plus
std::string message_{};
};

/**
* @brief Class template for a deferred reporter specific
* to an expression.
*/
template <class Expr_T>
class deferred_reporter : public deferred_reporter_base
{
Expand Down
40 changes: 40 additions & 0 deletions include/micro-os-plus/inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@ namespace micro_os_plus::micro_test_plus

// --------------------------------------------------------------------------

/**
* @details
* A test case is a sequence of test conditions (or simply tests,
* or checks), which are expectations/assumptions, i.e. conditions
* expected to be true.
*
* Tests are based on logical expressions, which usually compute
* a result and compare it to an expected value.
* For C++ projects, it is also possible to check if, while
* evaluating an expression, exceptions are thrown or not.
* Each test either succeeds or fails.
* For expectations, the runner keeps counts of successful
* and failed tests.
*
* A test case has a name, a function which performs the checks, and
* possibly arguments.
*
* The `test_case` implementation invokes the function with
* the provided arguments, and reports the results.
*
* @par Example
*
* ```cpp
* test_case ("Check answer with comparator", [] {
* expect (eq (compute_answer (), 42)) << "answer is 42";
* });
* ```
*/
template <typename Callable_T, typename... Args_T>
void
test_case (const char* name, Callable_T&& callable, Args_T&&... arguments)
Expand Down Expand Up @@ -120,6 +148,18 @@ namespace micro_os_plus::micro_test_plus
// --------------------------------------------------------------------------
namespace utility
{
/**
* @details
* For tests handling strings, this function template allows
* to split a string into a vector of substrings, using a delimiter.
*
* @par Example
* ```cpp
* expect (std::vector<std::string_view>{ "a", "b" }
* == utility::split<std::string_view> ("a.b", "."))
* << "a.b splits into [a,b]";
* ```
*/
template <class T = std::string_view, class Delim_T>
[[nodiscard]] auto
split (T input, Delim_T delim) -> std::vector<T>
Expand Down
106 changes: 105 additions & 1 deletion include/micro-os-plus/literals.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,43 @@ namespace micro_os_plus::micro_test_plus
*/
namespace literals
{
/**
* @ingroup mtp-literals
* @brief Operator to convert to `int`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_i ()
{
return type_traits::integral_constant<math::num<int, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `short`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_s ()
{
return type_traits::integral_constant<math::num<short, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `char`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_c ()
{
return type_traits::integral_constant<math::num<char, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `signed char`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_sc ()
Expand All @@ -77,27 +93,43 @@ namespace micro_os_plus::micro_test_plus
math::num<signed char, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `long`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_l ()
{
return type_traits::integral_constant<math::num<long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `long long`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_ll ()
{
return type_traits::integral_constant<math::num<long long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `unsigned`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_u ()
{
return type_traits::integral_constant<math::num<unsigned, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `unsigned char`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_uc ()
Expand All @@ -106,6 +138,10 @@ namespace micro_os_plus::micro_test_plus
math::num<unsigned char, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `unsigned short`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_us ()
Expand All @@ -114,6 +150,10 @@ namespace micro_os_plus::micro_test_plus
math::num<unsigned short, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `unsigned long`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_ul ()
Expand All @@ -122,6 +162,10 @@ namespace micro_os_plus::micro_test_plus
math::num<unsigned long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `unsigned long long`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_ull ()
Expand All @@ -130,6 +174,10 @@ namespace micro_os_plus::micro_test_plus
math::num<unsigned long long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `int8_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_i8 ()
Expand All @@ -138,6 +186,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::int8_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `int16_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_i16 ()
Expand All @@ -146,6 +198,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::int16_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `int32_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_i32 ()
Expand All @@ -154,6 +210,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::int32_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `int64_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_i64 ()
Expand All @@ -162,6 +222,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::int64_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `uint8_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_u8 ()
Expand All @@ -170,6 +234,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::uint8_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `uint16_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_u16 ()
Expand All @@ -178,6 +246,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::uint16_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `uint32_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_u32 ()
Expand All @@ -186,6 +258,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::uint32_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `uint64_t`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_u64 ()
Expand All @@ -194,6 +270,10 @@ namespace micro_os_plus::micro_test_plus
math::num<std::uint64_t, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `float`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_f ()
Expand All @@ -204,6 +284,10 @@ namespace micro_os_plus::micro_test_plus
math::den_size<unsigned long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `double`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_d ()
Expand All @@ -214,6 +298,10 @@ namespace micro_os_plus::micro_test_plus
math::den_size<unsigned long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `long double`.
*/
template <char... Cs>
[[nodiscard]] constexpr auto
operator""_ld ()
Expand All @@ -224,6 +312,10 @@ namespace micro_os_plus::micro_test_plus
math::den_size<unsigned long long, Cs...> ()>{};
}

/**
* @ingroup mtp-literals
* @brief Operator to convert to `bool`.
*/
constexpr auto
operator""_b (const char* name, decltype (sizeof ("")) size)
{
Expand Down Expand Up @@ -255,6 +347,11 @@ namespace micro_os_plus::micro_test_plus

// --------------------------------------------------------------------------

/**
* @addtogroup mtp-literals
* @{
*/

// Wrappers that can be used to convert dynamic values to specific types
// that are recognised by the comparators.
// The syntax is similar to function calls, like `_i(expression)`, but the
Expand Down Expand Up @@ -283,7 +380,14 @@ namespace micro_os_plus::micro_test_plus
using _d = type_traits::value<double>;
using _ld = type_traits::value<long double>;

// Template for wrapping any other type.
/**
* @}
*/

/**
* @ingroup mtp-literals
* @brief Template for wrapping any other type.
*/
template <class T>
struct _t : type_traits::value<T>
{
Expand Down
Loading

0 comments on commit 3b44a8c

Please sign in to comment.