|
| concept | CppSpec::Util::is_container |
| | Concept for checking whether T is a container type.
|
| concept | CppSpec::Util::is_streamable |
| | Checks whether T can be streamed.
|
| concept | CppSpec::Util::is_functional |
| concept | CppSpec::Util::is_not_functional |
| concept | CppSpec::Util::is_c_string |
| | Checks whether T is a C string: a pointer to char, const or not, or a char array, which decays to one.
|
| concept | CppSpec::Util::is_wide_character |
| | Checks whether T is a character type that std::ostream does not print as a character: wchar_t, char8_t, char16_t or char32_t.
|
| concept | CppSpec::Util::is_non_text_character_pointer |
| | Checks whether T is a pointer to a character type other than char: signed char, unsigned char, or a wide character type.
|
| concept | CppSpec::Util::is_string_like |
| | Checks whether T is text that CppSpec::string_view_of() can view: a C string, or a type that converts to std::string_view, such as std::string and std::string_view.
|
| concept | CppSpec::Util::compares_start_and_end |
| | Checks whether to_start_with and to_end_with compare an actual value of type A with an expected one of type E: text with text, a range with a range element by element, or a range of char with text.
|
| concept | CppSpec::Util::is_cmp_integer |
| | Checks whether T is an integer type that std::cmp_less and its kin accept: every integral type but bool and the character types (int8_t and uint8_t are in).
|
| concept | CppSpec::Util::not_c_string |
|
| std::string | CppSpec::Util::strip_type_keywords (std::string_view name) |
| | Removes the enum , class , struct and union keywords MSVC writes before every type in a type name.
|
| std::string | CppSpec::Util::demangle (const char *name) |
|
template<typename A, typename B> |
| constexpr bool | CppSpec::Util::less (const A &a, const B &b) |
| | a < b, by value when both are integers (std::cmp_less, so a negative signed value is below any unsigned one), and with < otherwise.
|
|
template<typename A, typename B> |
| constexpr bool | CppSpec::Util::less_equal (const A &a, const B &b) |
| | a <= b, by value when both are integers (std::cmp_less_equal), and with <= otherwise.
|
|
template<typename A, typename B> |
| constexpr bool | CppSpec::Util::greater (const A &a, const B &b) |
| | a > b, by value when both are integers (std::cmp_greater), and with > otherwise.
|
|
template<typename A, typename B> |
| constexpr bool | CppSpec::Util::greater_equal (const A &a, const B &b) |
| | a >= b, by value when both are integers (std::cmp_greater_equal), and with >= otherwise.
|
| std::string | CppSpec::Util::join (std::ranges::range auto &iterable, const std::string &separator="") |
| | Implode a string.
|
|
std::string | CppSpec::Util::join_endl (std::ranges::range auto &&iterable) |
| template<Util::is_string_like T> |
| constexpr std::optional< std::string_view > | CppSpec::string_view_of (const T &text) |
| | View text as a std::string_view, the one form the string matchers and the printer compare and print.
|
|
std::optional< std::string_view > | CppSpec::string_view_of (const std::string &&text)=delete |
Utility functions and classes.
template<Util::is_string_like T>
| std::optional< std::string_view > CppSpec::string_view_of |
( |
const T & | text | ) |
|
|
nodiscardconstexpr |
View text as a std::string_view, the one form the string matchers and the printer compare and print.
A char array passed here itself is read up to its first NUL and no further than its end. A char array given to expect() or to a matcher has already decayed to a pointer by the time it is viewed, so it is read as a C string, up to its first NUL, and must be NUL-terminated; wrap a fixed-size buffer in std::string_view(buffer, size).
A null C string is no text at all: it equals only another null C string, the matchers that search text fail on it, negated or not, whether it is the actual value or the text looked for, and it prints as nullptr.
A temporary std::string is refused, because the view would outlive its text.
- Parameters
-
| text | a std::string, std::string_view, char array or char pointer |
- Returns
- a view of the text, or std::nullopt for a null C string
| std::string CppSpec::Util::strip_type_keywords |
( |
std::string_view | name | ) |
|
|
inline |
Removes the enum , class , struct and union keywords MSVC writes before every type in a type name.
MSVC names std::vector<Colour> as class std::vector<enum Colour,class std::allocator<enum Colour> >; without the keywords it reads std::vector<Colour,std::allocator<Colour> >. A keyword is removed only where it starts a word, so a name such as my_class Foo is kept whole.
- Parameters
-
- Returns
- the name without the keywords