micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
literals.h File Reference

C++ header file with declarations for the µTest++ user-defined literals and type wrappers. More...

#include <cstdint>
#include "type-traits.h"
#include "math.h"

Go to the source code of this file.

Classes

struct  micro_os_plus::micro_test_plus::_t< T >
 Deprecated generic strongly-typed wrapper for explicit type conversion. More...
struct  micro_os_plus::micro_test_plus::to_t< T >
 Generic strongly-typed wrapper for explicit type conversion. More...

Namespaces

namespace  micro_os_plus
 The primary namespace for the µOS++ framework.
namespace  micro_os_plus::micro_test_plus
 Primary namespace for the µTest++ testing framework.
namespace  micro_os_plus::micro_test_plus::literals
 User-defined literals and type wrappers for the µTest++ testing framework.

Typedefs

Deprecated Type Wrappers

Strongly-typed wrappers for explicit type conversion.

These type aliases provide wrappers for converting values and expressions to specific types for use with µTest++ comparators and test expressions.

The _i, _u8, etc. forms are now deprecated as of version 3.2.0. Please use the preferred to_* type wrappers for new code, as they offer improved clarity and consistency.

Deprecated
Use the corresponding to_* type wrappers instead (since 3.2.0).
using micro_os_plus::micro_test_plus::_b = type_traits::value<bool>
 Strongly-typed wrapper for bool values.
using micro_os_plus::micro_test_plus::_c = type_traits::value<char>
 Strongly-typed wrapper for char values.
using micro_os_plus::micro_test_plus::_d = type_traits::value<double>
 Strongly-typed wrapper for double values.
using micro_os_plus::micro_test_plus::_f = type_traits::value<float>
 Strongly-typed wrapper for float values.
using micro_os_plus::micro_test_plus::_i = type_traits::value<int>
 Strongly-typed wrapper for int values.
using micro_os_plus::micro_test_plus::_i16 = type_traits::value<std::int16_t>
 Strongly-typed wrapper for std::int16_t values.
using micro_os_plus::micro_test_plus::_i32 = type_traits::value<std::int32_t>
 Strongly-typed wrapper for std::int32_t values.
using micro_os_plus::micro_test_plus::_i64 = type_traits::value<std::int64_t>
 Strongly-typed wrapper for std::int64_t values.
using micro_os_plus::micro_test_plus::_i8 = type_traits::value<std::int8_t>
 Strongly-typed wrapper for std::int8_t values.
using micro_os_plus::micro_test_plus::_l = type_traits::value<long>
 Strongly-typed wrapper for long values.
using micro_os_plus::micro_test_plus::_ld = type_traits::value<long double>
 Strongly-typed wrapper for long double values.
using micro_os_plus::micro_test_plus::_ll = type_traits::value<long long>
 Strongly-typed wrapper for long long values.
using micro_os_plus::micro_test_plus::_s = type_traits::value<short>
 Strongly-typed wrapper for short values.
using micro_os_plus::micro_test_plus::_sc = type_traits::value<signed char>
 Strongly-typed wrapper for signed char values.
using micro_os_plus::micro_test_plus::_u = type_traits::value<unsigned>
 Strongly-typed wrapper for unsigned values.
using micro_os_plus::micro_test_plus::_u16 = type_traits::value<std::uint16_t>
 Strongly-typed wrapper for std::uint16_t values.
using micro_os_plus::micro_test_plus::_u32 = type_traits::value<std::uint32_t>
 Strongly-typed wrapper for std::uint32_t values.
using micro_os_plus::micro_test_plus::_u64 = type_traits::value<std::uint64_t>
 Strongly-typed wrapper for std::uint64_t values.
using micro_os_plus::micro_test_plus::_u8 = type_traits::value<std::uint8_t>
 Strongly-typed wrapper for std::uint8_t values.
using micro_os_plus::micro_test_plus::_uc = type_traits::value<unsigned char>
 Strongly-typed wrapper for unsigned char values.
using micro_os_plus::micro_test_plus::_ul = type_traits::value<unsigned long>
 Strongly-typed wrapper for unsigned long values.
using micro_os_plus::micro_test_plus::_ull = type_traits::value<unsigned long long>
 Strongly-typed wrapper for unsigned long long values.
using micro_os_plus::micro_test_plus::_us = type_traits::value<unsigned short>
 Strongly-typed wrapper for unsigned short values.
Type Wrappers

Strongly-typed wrappers for converting dynamic values and expressions to specific types recognised by µTest++ comparators.

These type aliases provide a modern, type-safe mechanism for explicitly converting values to the required types for µTest++ test expressions and comparators. Each alias is a wrapper around type_traits::value<T>, ensuring that the value is treated as the specified type within the framework.

The to_* forms are the preferred approach since version 3.2.0, superseding the older _i, _u8, etc. aliases, which are now deprecated.

Example
int x = 42;
auto wrapped = to_i{x}; // Explicitly treat x as an int for test
comparison
type_traits::value< int > to_i
Strongly-typed wrapper for int values.
Definition literals.h:718
Since
3.2.0
using micro_os_plus::micro_test_plus::to_b = type_traits::value<bool>
 Strongly-typed wrapper for bool values.
using micro_os_plus::micro_test_plus::to_c = type_traits::value<char>
 Strongly-typed wrapper for char values.
using micro_os_plus::micro_test_plus::to_d = type_traits::value<double>
 Strongly-typed wrapper for double values.
using micro_os_plus::micro_test_plus::to_f = type_traits::value<float>
 Strongly-typed wrapper for float values.
using micro_os_plus::micro_test_plus::to_i = type_traits::value<int>
 Strongly-typed wrapper for int values.
using micro_os_plus::micro_test_plus::to_i16 = type_traits::value<std::int16_t>
 Strongly-typed wrapper for std::int16_t values.
using micro_os_plus::micro_test_plus::to_i32 = type_traits::value<std::int32_t>
 Strongly-typed wrapper for std::int32_t values.
using micro_os_plus::micro_test_plus::to_i64 = type_traits::value<std::int64_t>
 Strongly-typed wrapper for std::int64_t values.
using micro_os_plus::micro_test_plus::to_i8 = type_traits::value<std::int8_t>
 Strongly-typed wrapper for std::int8_t values.
using micro_os_plus::micro_test_plus::to_l = type_traits::value<long>
 Strongly-typed wrapper for long values.
using micro_os_plus::micro_test_plus::to_ld = type_traits::value<long double>
 Strongly-typed wrapper for long double values.
using micro_os_plus::micro_test_plus::to_ll = type_traits::value<long long>
 Strongly-typed wrapper for long long values.
using micro_os_plus::micro_test_plus::to_s = type_traits::value<short>
 Strongly-typed wrapper for short values.
using micro_os_plus::micro_test_plus::to_sc = type_traits::value<signed char>
 Strongly-typed wrapper for signed char values.
using micro_os_plus::micro_test_plus::to_u = type_traits::value<unsigned>
 Strongly-typed wrapper for unsigned values.
using micro_os_plus::micro_test_plus::to_u16 = type_traits::value<std::uint16_t>
 Strongly-typed wrapper for std::uint16_t values.
using micro_os_plus::micro_test_plus::to_u32 = type_traits::value<std::uint32_t>
 Strongly-typed wrapper for std::uint32_t values.
using micro_os_plus::micro_test_plus::to_u64 = type_traits::value<std::uint64_t>
 Strongly-typed wrapper for std::uint64_t values.
using micro_os_plus::micro_test_plus::to_u8 = type_traits::value<std::uint8_t>
 Strongly-typed wrapper for std::uint8_t values.
using micro_os_plus::micro_test_plus::to_uc = type_traits::value<unsigned char>
 Strongly-typed wrapper for unsigned char values.
using micro_os_plus::micro_test_plus::to_ul = type_traits::value<unsigned long>
 Strongly-typed wrapper for unsigned long values.
using micro_os_plus::micro_test_plus::to_ull = type_traits::value<unsigned long long>
 Strongly-typed wrapper for unsigned long long values.
using micro_os_plus::micro_test_plus::to_us = type_traits::value<unsigned short>
 Strongly-typed wrapper for unsigned short values.

Functions

constexpr auto micro_os_plus::micro_test_plus::literals::operator""_b (const char *name, decltype(sizeof("")) size)
 User-defined literal operator to convert to bool.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_c ()
 User-defined literal operator to convert to char.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_d ()
 User-defined literal operator to convert to double.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_f ()
 User-defined literal operator to convert to float.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_i ()
 User-defined literal operator to convert to int.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_i16 ()
 User-defined literal operator to convert to int16_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_i32 ()
 User-defined literal operator to convert to int32_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_i64 ()
 User-defined literal operator to convert to int64_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_i8 ()
 User-defined literal operator to convert to int8_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_l ()
 User-defined literal operator to convert to long.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_ld ()
 User-defined literal operator to convert to long double.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_ll ()
 User-defined literal operator to convert to long long.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_s ()
 User-defined literal operator to convert to short.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_sc ()
 User-defined literal operator to convert to signed char.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_u ()
 User-defined literal operator to convert to unsigned.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_u16 ()
 User-defined literal operator to convert to uint16_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_u32 ()
 User-defined literal operator to convert to uint32_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_u64 ()
 User-defined literal operator to convert to uint64_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_u8 ()
 User-defined literal operator to convert to uint8_t.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_uc ()
 User-defined literal operator to convert to unsigned char.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_ul ()
 User-defined literal operator to convert to unsigned long.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_ull ()
 User-defined literal operator to convert to unsigned long long.
template<char... Cs>
constexpr auto micro_os_plus::micro_test_plus::literals::operator""_us ()
 User-defined literal operator to convert to unsigned short.

Detailed Description

This header provides the declarations for the user-defined literal operators and type wrappers used within the µTest++ framework. It defines interfaces for generating strongly-typed integral, floating-point, and boolean constants at compile time, enabling expressive and type-safe test expressions.

The declared literal operators support a wide range of C++ fundamental types, allowing constants to be suffixed with type-specific identifiers (such as _i, _u16, _f, _d, _b, etc.) to produce values that integrate seamlessly with the µTest++ comparators and reporting mechanisms.

In addition to literal operators, this header declares both deprecated and modern type wrappers for explicit type conversion, supporting enhanced clarity and type safety in test conditions. The preferred to_* forms are recommended for new code, while the older _i, _u8, etc. aliases are retained for backwards compatibility.

All definitions reside within the micro_os_plus::micro_test_plus::literals 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 for internal use within the framework and should not be included directly by user code.

Definition in file literals.h.