preCICE
Loading...
Searching...
No Matches
precice::testing Namespace Reference

contains the testing framework. More...

Namespaces

namespace  com
namespace  inject

Classes

class  DataContextFixture
struct  ParallelCouplingSchemeFixture
struct  QuickTest
struct  SerialCouplingSchemeFixture
struct  Ranks
struct  ParticipantState
 Represents a ParticipantState in a test. More...
struct  TestSetup
 Contains the setup description of a test including participants and requirements. More...
struct  ConnectionOptions
class  TestContext
struct  WhiteboxAccessor
 struct giving access to the impl of a befriended class or struct More...
class  precice_testsetup_fixture

Typedefs

using Par = utils::Parallel
using ErrorPredicate = std::function<bool(::precice::Error)>

Enumerations

enum class  Require { PETSc , Events , Ginkgo }
enum struct  ConnectionType { GatherScatter , PointToPoint }

Functions

cplscheme::PtrCouplingData makeCouplingData (mesh::PtrData data, mesh::PtrMesh mesh, bool exchangeSubsteps)
cplscheme::PtrCouplingData makeCouplingData (mesh::PtrData data, mesh::PtrMesh mesh)
void setupTestLogging ()
void addDummyVertices (size_t nVertices, mesh::Mesh &mesh)
auto makeDummy2DMesh (size_t nVertices)
auto makeDummy3DMesh (size_t nVertices)
QuickTest::Mesh operator""_mesh (const char *name, std::size_t)
QuickTest::ReadData operator""_read (const char *name, std::size_t)
QuickTest::WriteData operator""_write (const char *name, std::size_t)
constexpr Ranks operator""_ranks (unsigned long long value)
constexpr Ranks operator""_rank (unsigned long long value)
constexpr ParticipantState operator""_on (const char *name, std::size_t)
 User-defined literal allowing to create a serial ParticipantState from a given string.
DataID operator""_dataID (unsigned long long n)
std::string getPathToRepository ()
 Returns the base path of the repo.
std::string getPathToSources ()
 Returns the base path to the sources.
std::string getPathToTests ()
 Returns the base path to the integration tests.
std::string getTestPath ()
 Returns the full path to the file containing the current test.
std::string getTestName ()
 Returns the name of the current test.
std::string getFullTestName ()
 Return the full name of the current test as seen in boost assertions.
TestSetup getTestSetup ()
 Returns the registered TestSetup for the test.
std::optional< TestSetupgetTestSetupFor (const boost::unit_test::test_unit &tu)
 Returns the registered TestSetup for a test if available.
int nextMeshID ()
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 on failure
boost::test_tools::predicate_result equals (const std::vector< double > &VectorA, const std::vector< double > &VectorB, double tolerance)
boost::test_tools::predicate_result equals (float a, float b, float tolerance=math::NUMERICAL_ZERO_DIFFERENCE)
 equals to be used in tests. Compares two scalar numbers using a given tolerance. Prints both operands on failure
boost::test_tools::predicate_result equals (double a, double b, double tolerance)
void expectFile (std::string_view name)
void expectDirectoryContent (std::string_view dir, std::vector< std::string > filenames)
void expectNoDirectory (std::string_view dir)
void removeDirectory (std::string_view name)
ErrorPredicate errorContains (std::string_view substring)
 Checks if the message of a given precice::Error contains a substring.
ErrorPredicate errorMatches (std::string regex)
 Checks if the message of a given precice::Error matches a regex.
template<class DerivedA, class DerivedB>
boost::test_tools::predicate_result equals (const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=math::NUMERICAL_ZERO_DIFFERENCE)
 equals to be used in tests. Compares two matrices using a given tolerance. Prints both operands on failure.
template<typename... ARGS>
auto testSetup (ARGS... args)
template<typename... Args>
void expectFiles (Args... args)

Detailed Description

contains the testing framework.

Typedef Documentation

◆ ErrorPredicate

using precice::testing::ErrorPredicate = std::function<bool(::precice::Error)>

Definition at line 177 of file Testing.hpp.

◆ Par

Definition at line 32 of file TestContext.cpp.

Enumeration Type Documentation

◆ ConnectionType

A type of distributed connection

See also
ConnectionOptions
Enumerator
GatherScatter 
PointToPoint 

Definition at line 151 of file TestContext.hpp.

◆ Require

enum class precice::testing::Require
strong

Defines requirements for a test setup

Note
These are used for unit-tests. Integration tests calling the Participant initialize required components themselves.
Enumerator
PETSc 

Require to initialize PETSc. This implies the initialization of Events.

Events 

Require to initialize Event.

Ginkgo 

Ginkgo initialization.

Definition at line 99 of file TestContext.hpp.

Function Documentation

◆ addDummyVertices()

void precice::testing::addDummyVertices ( size_t nVertices,
mesh::Mesh & mesh )
inline

Definition at line 10 of file Meshes.hpp.

◆ equals() [1/5]

template<class DerivedA, class DerivedB>
boost::test_tools::predicate_result precice::testing::equals ( const Eigen::MatrixBase< DerivedA > & A,
const Eigen::MatrixBase< DerivedB > & B,
double tolerance = math::NUMERICAL_ZERO_DIFFERENCE )

equals to be used in tests. Compares two matrices using a given tolerance. Prints both operands on failure.

Definition at line 66 of file Testing.hpp.

◆ equals() [2/5]

boost::test_tools::predicate_result precice::testing::equals ( const std::vector< double > & VectorA,
const std::vector< double > & VectorB,
double tolerance )

Definition at line 106 of file Testing.cpp.

Here is the call graph for this function:

◆ equals() [3/5]

boost::test_tools::predicate_result precice::testing::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 on failure

Definition at line 94 of file Testing.cpp.

Here is the call graph for this function:

◆ equals() [4/5]

boost::test_tools::predicate_result precice::testing::equals ( double a,
double b,
double tolerance )

Definition at line 128 of file Testing.cpp.

Here is the call graph for this function:

◆ equals() [5/5]

boost::test_tools::predicate_result precice::testing::equals ( float a,
float b,
float tolerance )

equals to be used in tests. Compares two scalar numbers using a given tolerance. Prints both operands on failure

Definition at line 118 of file Testing.cpp.

Here is the call graph for this function:

◆ errorContains()

ErrorPredicate precice::testing::errorContains ( std::string_view substring)

Checks if the message of a given precice::Error contains a substring.

Definition at line 177 of file Testing.cpp.

◆ errorMatches()

ErrorPredicate precice::testing::errorMatches ( std::string pattern)

Checks if the message of a given precice::Error matches a regex.

Definition at line 185 of file Testing.cpp.

◆ expectDirectoryContent()

void precice::testing::expectDirectoryContent ( std::string_view dir,
std::vector< std::string > filenames )

Definition at line 143 of file Testing.cpp.

◆ expectFile()

void precice::testing::expectFile ( std::string_view name)

Definition at line 138 of file Testing.cpp.

◆ expectFiles()

template<typename... Args>
void precice::testing::expectFiles ( Args... args)

Definition at line 166 of file Testing.hpp.

Here is the call graph for this function:

◆ expectNoDirectory()

void precice::testing::expectNoDirectory ( std::string_view dir)

Definition at line 167 of file Testing.cpp.

◆ getFullTestName()

std::string precice::testing::getFullTestName ( )

Return the full name of the current test as seen in boost assertions.

Definition at line 61 of file Testing.cpp.

◆ getPathToRepository()

std::string precice::testing::getPathToRepository ( )

Returns the base path of the repo.

Definition at line 28 of file Testing.cpp.

◆ getPathToSources()

std::string precice::testing::getPathToSources ( )

Returns the base path to the sources.

Definition at line 34 of file Testing.cpp.

Here is the call graph for this function:

◆ getPathToTests()

std::string precice::testing::getPathToTests ( )

Returns the base path to the integration tests.

Definition at line 39 of file Testing.cpp.

Here is the call graph for this function:

◆ getTestName()

std::string precice::testing::getTestName ( )

Returns the name of the current test.

Definition at line 50 of file Testing.cpp.

◆ getTestPath()

std::string precice::testing::getTestPath ( )

Returns the full path to the file containing the current test.

Definition at line 44 of file Testing.cpp.

◆ getTestSetup()

TestSetup precice::testing::getTestSetup ( )

Returns the registered TestSetup for the test.

Definition at line 66 of file Testing.cpp.

Here is the call graph for this function:

◆ getTestSetupFor()

std::optional< TestSetup > precice::testing::getTestSetupFor ( const boost::unit_test::test_unit & tu)

Returns the registered TestSetup for a test if available.

Definition at line 75 of file Testing.cpp.

◆ makeCouplingData() [1/2]

cplscheme::PtrCouplingData precice::testing::makeCouplingData ( mesh::PtrData data,
mesh::PtrMesh mesh )
inline

Definition at line 10 of file helper.hpp.

◆ makeCouplingData() [2/2]

cplscheme::PtrCouplingData precice::testing::makeCouplingData ( mesh::PtrData data,
mesh::PtrMesh mesh,
bool exchangeSubsteps )
inline

Definition at line 10 of file helper.hpp.

◆ makeDummy2DMesh()

auto precice::testing::makeDummy2DMesh ( size_t nVertices)
inline

Definition at line 21 of file Meshes.hpp.

Here is the call graph for this function:

◆ makeDummy3DMesh()

auto precice::testing::makeDummy3DMesh ( size_t nVertices)
inline

Definition at line 28 of file Meshes.hpp.

Here is the call graph for this function:

◆ nextMeshID()

int precice::testing::nextMeshID ( )

Generates a new mesh id for use in tests.

Returns
a new unique mesh ID

Definition at line 87 of file Testing.cpp.

Here is the call graph for this function:

◆ operator""_dataID()

DataID precice::testing::operator""_dataID ( unsigned long long n)

Definition at line 22 of file Testing.cpp.

◆ operator""_mesh()

QuickTest::Mesh precice::testing::operator""_mesh ( const char * name,
std::size_t  )
inline

Definition at line 153 of file QuickTest.hpp.

◆ operator""_on()

ParticipantState precice::testing::operator""_on ( const char * name,
std::size_t  )
inlineconstexpr

User-defined literal allowing to create a serial ParticipantState from a given string.

Definition at line 86 of file TestContext.hpp.

◆ operator""_rank()

Ranks precice::testing::operator""_rank ( unsigned long long value)
inlineconstexpr

User-defined literal for expressively defining a single rank

Parameters
[in]valuethe amount of ranks which has to be 1
Returns
a strong typed count of 1 rank

Definition at line 40 of file TestContext.hpp.

◆ operator""_ranks()

Ranks precice::testing::operator""_ranks ( unsigned long long value)
inlineconstexpr

User-defined literal for expressively defining multiple ranks

Parameters
[in]valuethe amount of ranks <= 1
Returns
a strong typed count of ranks

Definition at line 29 of file TestContext.hpp.

◆ operator""_read()

QuickTest::ReadData precice::testing::operator""_read ( const char * name,
std::size_t  )
inline

Definition at line 158 of file QuickTest.hpp.

◆ operator""_write()

QuickTest::WriteData precice::testing::operator""_write ( const char * name,
std::size_t  )
inline

Definition at line 163 of file QuickTest.hpp.

◆ removeDirectory()

void precice::testing::removeDirectory ( std::string_view name)

Definition at line 172 of file Testing.cpp.

◆ setupTestLogging()

void precice::testing::setupTestLogging ( )

Definition at line 12 of file GlobalFixtures.cpp.

Here is the call graph for this function:

◆ testSetup()

template<typename... ARGS>
auto precice::testing::testSetup ( ARGS... args)

Definition at line 146 of file Testing.hpp.