FCF_TEST macro
Package: fcfTest
File: test.hpp
Available from version: 1.0.1
The basic assertion macro. Checks a logical expression and, if it fails, throws
The macro is designed to perform checks (assertions) within test scenarios.
Arguments
- The value of the checked expression. If this expression is false, the test is interrupted and the error is displayed.
- [OPTIONAL] The variables that will be displayed with their values if the check is unsuccessful.
Detailed description
- Evaluates expression
-
If the result is
false :* Generates an error message containing:
- A text representation of the original expression.
- The path to the file and line number where the error occurred.
- A list of the names and current values of all passed variables arguments
* Throws a
std::runtime_error exception. -
If the result is
true :* Continues execution without further action.
Example:
int expected = 10;
int actual = get_value();
// Check the value with context output on error
FCF_TEST (actual == expected, actual, expected);
Output:
Test error: actual == expected [FILE: main.cpp:15]
Values:
actual: 7
expected: 10
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.