2#include <boost/test/framework.hpp>
3#include <boost/test/tree/test_unit.hpp>
14#include "testing/SourceLocation.hpp"
21DataID operator"" _dataID(
unsigned long long n)
24 return static_cast<DataID>(n);
21DataID operator"" _dataID(
unsigned long long n) {
…}
30 return precice::testing::SourceLocation;
45 const auto &cspan = boost::unit_test::framework::current_test_case().p_file_name;
46 return {cspan.
begin(), cspan.end()};
51 std::string name = boost::unit_test::framework::current_test_case().p_name;
56 auto parent = boost::unit_test::framework::current_test_case().p_parent_id;
57 return boost::unit_test::framework::get<boost::unit_test::test_suite>(parent).p_name;
62 return boost::unit_test::framework::current_test_case().full_name();
67 if (
auto setup =
getTestSetupFor(boost::unit_test::framework::current_test_case());
71 throw std::runtime_error{
"Use PRECICE_TEST_SETUP(...) to define the setup directly before the BOOST_[AUTO_]TEST_CASE."};
76 const auto &list = tu.p_decorators.get();
77 for (
const auto &iter : list) {
98 Eigen::MatrixXd MatrixA(VectorA.
size(), 1);
100 Eigen::MatrixXd MatrixB(VectorB.
size(), 1);
102 return equals(MatrixA, MatrixB, tolerance);
110 Eigen::MatrixXd MatrixA(VectorA.
size(), 1);
112 Eigen::MatrixXd MatrixB(VectorB.
size(), 1);
114 return equals(MatrixA, MatrixB, tolerance);
117boost::test_tools::predicate_result
equals(
float a,
float b,
float tolerance)
120 boost::test_tools::predicate_result res(
false);
121 res.message() <<
"Not equal: " << a <<
"!=" << b;
117boost::test_tools::predicate_result
equals(
float a,
float b,
float tolerance) {
…}
127boost::test_tools::predicate_result
equals(
double a,
double b,
double tolerance)
130 boost::test_tools::predicate_result res(
false);
131 res.message() <<
"Not equal: " << a <<
"!=" << b;
127boost::test_tools::predicate_result
equals(
double a,
double b,
double tolerance) {
…}
144 return [substring](const ::precice::Error &e) ->
bool {
146 return msg.
find(substring) != std::string::npos;
152 return [regex =
std::regex(pattern)](const ::precice::Error &e) ->
bool {
#define PRECICE_ASSERT(...)
This class provides a lightweight logger.
precice::testing::TestSetup testSetup
Manages a set of unique IDs.
T is_regular_file(T... args)
constexpr bool equals(const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares two Eigen::MatrixBase for equality up to tolerance.
contains the testing framework.
ErrorPredicate errorMatches(std::string pattern)
Checks if the message of a given precice::Error matches a regex.
boost::test_tools::predicate_result equals(const std::vector< float > &VectorA, const std::vector< float > &VectorB, float tolerance)
equals to be used in tests. Compares two std::vectors using a given tolerance. Prints both operands o...
std::string getFullTestName()
Return the full name of the current test as seen in boost assertions.
std::string getPathToRepository()
Returns the base path of the repo.
std::optional< TestSetup > getTestSetupFor(const boost::unit_test::test_unit &tu)
Returns the registered TestSetup for a test if available.
std::string getTestPath()
Returns the full path to the file containing the current test.
void expectFile(std::string_view name)
std::string getTestName()
Returns the name of the current test.
TestSetup getTestSetup()
Returns the registered TestSetup for the test.
std::string getPathToTests()
Returns the base path to the integration tests.
std::string getPathToSources()
Returns the base path to the sources.
ErrorPredicate errorContains(std::string_view substring)
Checks if the message of a given precice::Error contains a substring.
static precice::logging::Logger _log("precicec")
T regex_search(T... args)
Contains the setup description of a test including participants and requirements.