4#include <boost/test/unit_test.hpp>
16namespace bt = boost::unit_test;
18DataID operator"" _dataID(
unsigned long long n);
22using precice::testing::operator
""_rank;
23using precice::testing::operator
""_ranks;
24using precice::testing::operator
""_on;
25using precice::testing::operator
""_dataID;
29#define PRECICE_TEST_SETUP(...) \
30 BOOST_TEST_DECORATOR(*precice::testing::testSetup(__VA_ARGS__))
29#define PRECICE_TEST_SETUP(...) \ …
39#define PRECICE_TEST() \
40 precice::testing::TestContext context{precice::testing::getTestSetup()}; \
41 if (context.invalid) { \
44 BOOST_TEST_MESSAGE(context.describe()); \
45 boost::unit_test::framework::add_context(BOOST_TEST_LAZY_MSG(context.describe()), true);
39#define PRECICE_TEST() \ …
65template <
class DerivedA,
class DerivedB>
66boost::test_tools::predicate_result
equals(
const Eigen::MatrixBase<DerivedA> &A,
67 const Eigen::MatrixBase<DerivedB> &B,
70 auto approx = [tolerance](
double a,
double b) ->
bool {
78 if (!A.binaryExpr(B, approx).all()) {
79 boost::test_tools::predicate_result res(
false);
80 Eigen::IOFormat format;
82 format.rowSeparator =
", ";
83 format.rowPrefix =
" ";
84 format.precision = Eigen::FullPrecision;
87 << A.format(format) <<
" != \n"
88 << B.format(format) <<
'\n'
89 << (A - B).cwiseAbs().format(format) <<
" difference\n"
90 << A.binaryExpr(B, approx).format(format) <<
"in tolerance (" << tolerance <<
')';
66boost::test_tools::predicate_result
equals(
const Eigen::MatrixBase<DerivedA> &A, {
…}
138 void apply(boost::unit_test::test_unit &tu)
override {};
139 boost::unit_test::decorator::base_ptr
clone()
const override
139 boost::unit_test::decorator::base_ptr
clone()
const override {
…}
145template <
typename... ARGS>
165template <
typename... Args>
precice_testsetup_fixture(precice::testing::TestSetup ts)
precice::testing::TestSetup testSetup
void apply(boost::unit_test::test_unit &tu) override
boost::unit_test::decorator::base_ptr clone() const override
constexpr double NUMERICAL_ZERO_DIFFERENCE
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.
void expectFiles(Args... args)
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.
auto testSetup(ARGS... args)
Contains the setup description of a test including participants and requirements.
struct giving access to the impl of a befriended class or struct
static auto impl(T &obj) -> typename std::add_lvalue_reference< decltype(*(obj._impl))>::type