|
waLBerla 7.3
|
Unit testing toolkit for waLBerla.
This toolkit of test utilities is designed to facilitate unit testing of the waLBerla framework.
See also Testing in the V8 core contributors guide.
Tests are grouped into test executables. We thematically group as many tests as sensible into a single executable to accelerate compilation times. Test executables follow the naming scheme TestX.cpp. To register a test executable with CMake, use the waLBerla_add_test_executable function:
Every test executable must include the following scaffolding, where the tests are registered with a TestsRunner instance:
The individual tests (MyTest1, MyTest2, ...) are zero-argument void functions. To automatically run the tests, they must further be registered with CTest in the CMakeLists.txt, using walberla_v8_add_tests:
Here, TestX is the name of the test application, the IDS are the test names as passed to the TestsRunner.
Tests should be written using the assertion functions from this module, listed below.
Classes | |
| class | walberla::v8::testing::TestsRunner |
| Primary test orchestrator. More... | |
| class | walberla::v8::testing::with_tolerance |
| Floating-point near-equality assertions with given tolerances. More... | |
Functions | |
| std::filesystem::path | walberla::v8::testing::tmp_dir () |
| Create and obtain a unique temporary directory. | |
| void | walberla::v8::testing::assert_true (bool cond, const std::source_location loc=std::source_location::current()) |
| Check if the given boolean condition is true. | |
| void | walberla::v8::testing::assert_false (bool cond, const std::source_location loc=std::source_location::current()) |
| Check if the given boolean condition is false. | |
| template<typename TException> | |
| void | walberla::v8::testing::throws (const std::function< void() > &func, const std::source_location loc=std::source_location::current()) |
| Check if the given callback function raises an expected exception type. | |
| template<std::equality_comparable T> | |
| void | walberla::v8::testing::assert_equal (const T &actual, const T &desired, const std::source_location loc=std::source_location::current()) |
| Check if two values are equal. | |
| template<std::equality_comparable T> | |
| void | walberla::v8::testing::assert_inequal (const T &left, const T &right, const std::source_location loc=std::source_location::current()) |
| Check if two values are inequal. | |
| template<std::totally_ordered T> | |
| void | walberla::v8::testing::assert_less (const T &left, const T &right, const std::source_location loc=std::source_location::current()) |
| Check if one value is less than another. | |
| template<std::totally_ordered T> | |
| void | walberla::v8::testing::assert_greater (const T &left, const T &right, const std::source_location loc=std::source_location::current()) |
| Check if one value is greater than another. | |
| template<std::totally_ordered T> | |
| void | walberla::v8::testing::assert_less_equal (const T &left, const T &right, const std::source_location loc=std::source_location::current()) |
| Check if one value is less or equal to another. | |
| template<std::totally_ordered T> | |
| void | walberla::v8::testing::assert_greater_equal (const T &left, const T &right, const std::source_location loc=std::source_location::current()) |
| Check if one value is greater or equal to another. | |
| template<std::ranges::range R1, std::ranges::range R2> | |
| void | walberla::v8::testing::assert_range_equal (const R1 &actual, const R2 &desired, const std::source_location loc=std::source_location::current()) |
| Check if two ranges have identical elements. | |
| template<std::ranges::range R1> | |
| void | walberla::v8::testing::assert_range_equal (const R1 &actual, const std::ranges::range_value_t< R1 > &desired, const std::source_location loc=std::source_location::current()) |
| Check if all elements of a range are equal to a desired value. | |
| void walberla::v8::testing::assert_equal | ( | const T & | actual, |
| const T & | desired, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if two values are equal.
|
inline |
Check if the given boolean condition is false.
| void walberla::v8::testing::assert_greater | ( | const T & | left, |
| const T & | right, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if one value is greater than another.
| void walberla::v8::testing::assert_greater_equal | ( | const T & | left, |
| const T & | right, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if one value is greater or equal to another.
| void walberla::v8::testing::assert_inequal | ( | const T & | left, |
| const T & | right, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if two values are inequal.
| void walberla::v8::testing::assert_less | ( | const T & | left, |
| const T & | right, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if one value is less than another.
| void walberla::v8::testing::assert_less_equal | ( | const T & | left, |
| const T & | right, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if one value is less or equal to another.
| void walberla::v8::testing::assert_range_equal | ( | const R1 & | actual, |
| const R2 & | desired, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if two ranges have identical elements.
| void walberla::v8::testing::assert_range_equal | ( | const R1 & | actual, |
| const std::ranges::range_value_t< R1 > & | desired, | ||
| const std::source_location | loc = std::source_location::current() ) |
Check if all elements of a range are equal to a desired value.
|
inline |
Check if the given boolean condition is true.
| void walberla::v8::testing::throws | ( | const std::function< void() > & | func, |
| const std::source_location | loc = std::source_location::current() ) |
Check if the given callback function raises an expected exception type.
Example:
|
inline |
Create and obtain a unique temporary directory.