micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
String Operators

Overloaded operators for string comparison. More...

Functions

constexpr auto micro_os_plus::micro_test_plus::operators::operator!= (std::string_view lhs, std::string_view rhs)
 Non-equality operator for string_view objects.
constexpr auto micro_os_plus::micro_test_plus::operators::operator== (std::string_view lhs, std::string_view rhs)
 Equality operator for string_view objects.

Detailed Description

The µTest++ framework provides overloaded operators specifically for comparing string types, such as std::string_view. These operators enable clear and expressive assertions when verifying string values within test cases, supporting both equality and inequality checks.

By using these dedicated string operators, developers can write concise and readable tests that accurately reflect the intended logic. The framework ensures that string comparisons are performed correctly and that any failed checks are reported with both the actual and expected values for straightforward diagnostics.

Examples
#include <string_view>
using namespace std::literals; // For the "sv" literal.
// ...
mt::test_case ("Operators", [] {
using namespace micro_test_plus::operators;
mt::expect (std::string_view{ compute_ultimate_answer () } == "forty-two"sv)
<< "ultimate answer == 'forty-two'";
});
Primary namespace for the µTest++ testing framework.

Function Documentation

◆ operator!=()

auto micro_os_plus::micro_test_plus::operators::operator!= ( std::string_view lhs,
std::string_view rhs )
nodiscardconstexpr
Parameters
[in]lhsThe left hand side std::string_view operand.
[in]rhsThe right hand side std::string_view operand.
Returns
A comparator object that evaluates to true if the string views are not equal.

This overload of the non-equality operator enables direct comparison of two std::string_view objects within the µTest++ framework. It constructs a comparator object that can be used in test expectations and assertions to verify that two string views are not equal.

Definition at line 149 of file operators.h.

◆ operator==()

auto micro_os_plus::micro_test_plus::operators::operator== ( std::string_view lhs,
std::string_view rhs )
nodiscardconstexpr
Parameters
[in]lhsThe left hand side std::string_view operand.
[in]rhsThe right hand side std::string_view operand.
Returns
A comparator object that evaluates to true if the string views are equal.

This overload of the equality operator enables direct comparison of two std::string_view objects within the µTest++ framework. It constructs a comparator object that can be used in test expectations and assertions to verify that two string views are equal.

Definition at line 128 of file operators.h.