Gromacs
2018.1
|
#include <gromacs/analysisdata/tests/datatest.h>
Inherits Test.
Test fixture for AbstractAnalysisData testing.
This test fixture is designed to help writing tests for objects that derive from the AbstractAnalysisData class. Typical flow in such tests is that first the test creates the required data objects, then call static methods in this class to add mock modules (using AbstractAnalysisData::addModule()) to the data objects to check that they produce the correct data, and then invokes methods in the data object to produce the data to be checked. Static methods are also provided for pushing data from an AnalysisDataTestInput object to some generic types derived from AbstractAnalysisData.
Methods addStaticCheckerModule(), addStaticColumnCheckerModule() and addStaticStorageCheckerModule() create and add mock modules that check the data against a given AnalysisDataTestInput instance.
Method addReferenceCheckerModule() creates and adds a mock module that checks the output against reference data produced by a previous test execution (see TestReferenceData). Two versions are provided, a static method to be used with any TestReferenceChecker, and a non-static method that uses the protected data_
member.
presentAllData() and presentDataFrame() are provided to push data from an AnalysisDataTestInput into an AnalysisData object. In typical tests, most checks are done during these methods, by the added mock modules. setupArrayData() performs the same function for classes derived from AbstractAnalysisArrayData. In that case, the test should separately ensure that AbstractAnalysisArrayData::valuesReady() gets called.
Public Member Functions | |
void | addReferenceCheckerModule (const char *id, AbstractAnalysisData *source) |
Adds a mock module that verifies output against reference data. More... | |
Static Public Member Functions | |
static void | setupDataObject (const AnalysisDataTestInput &input, AnalysisData *data) |
Initializes an AnalysisData object from input data. More... | |
static void | presentAllData (const AnalysisDataTestInput &input, AnalysisData *data) |
Adds all data from AnalysisDataTestInput into an AnalysisData. | |
static void | presentDataFrame (const AnalysisDataTestInput &input, int row, AnalysisDataHandle handle) |
Adds a single frame from AnalysisDataTestInput into an AnalysisData. | |
template<class ArrayData > | |
static void | setupArrayData (const AnalysisDataTestInput &input, ArrayData *data) |
Initializes an array data object from AnalysisDataTestInput. More... | |
static void | addStaticCheckerModule (const AnalysisDataTestInput &data, AbstractAnalysisData *source) |
Adds a mock module that verifies output against AnalysisDataTestInput. More... | |
static void | addStaticParallelCheckerModule (const AnalysisDataTestInput &data, AbstractAnalysisData *source) |
Adds a mock module that verifies parallel output against AnalysisDataTestInput. More... | |
static void | addStaticColumnCheckerModule (const AnalysisDataTestInput &data, int firstcol, int n, AbstractAnalysisData *source) |
Adds a column mock module that verifies output against AnalysisDataTestInput. More... | |
static void | addStaticStorageCheckerModule (const AnalysisDataTestInput &data, int storageCount, AbstractAnalysisData *source) |
Adds a mock module that verifies output and storage against AnalysisDataTestInput. More... | |
static void | addReferenceCheckerModule (const TestReferenceChecker &checker, const char *id, AbstractAnalysisData *source, const FloatingPointTolerance &tolerance) |
Adds a mock module that verifies output against reference data. More... | |
Protected Attributes | |
gmx::test::TestReferenceData | data_ |
Reference data object used for the reference checker modules. More... | |
|
static |
Adds a mock module that verifies output against reference data.
[in] | checker | Reference data checker to use for comparison. |
[in] | id | Identifier for reference data compound to use. |
source | Data object to verify. | |
[in] | tolerance | Tolerance to use for comparison. |
Creates a mock module that verifies that the IAnalysisDataModule methods are called correctly by source
. Parameters for the calls are verified against reference data using a child compound id
of checker
. Adds the created module to source
using data->addModule()
. Any exceptions from the called functions should be caught by the caller.
void gmx::test::AnalysisDataTestFixture::addReferenceCheckerModule | ( | const char * | id, |
AbstractAnalysisData * | source | ||
) |
Adds a mock module that verifies output against reference data.
[in] | id | Identifier for reference data compound to use. |
source | Data object to verify. |
Creates a reference checker module using a compound checker with id id
at the root level of data_
.
See the static overload for other details.
|
static |
Adds a mock module that verifies output against AnalysisDataTestInput.
[in] | data | Data to compare against. |
source | Data object to verify. |
Creates a mock module that verifies that the IAnalysisDataModule methods are called correctly by source
. Parameters for the calls are verified against data
. Adds the created module to source
using data->addModule()
. Any exceptions from the called functions should be caught by the caller.
|
static |
Adds a column mock module that verifies output against AnalysisDataTestInput.
[in] | data | Data to compare against. |
[in] | firstcol | First column to check. |
[in] | n | Number of columns to check. |
source | Data object to verify. |
Creates a mock module that verifies that the IAnalysisDataModule methods are called correctly by source
. Parameters for the calls are verified against data
. Adds the created module to source
using data->addColumnModule()
. Any exceptions from the called functions should be caught by the caller.
|
static |
Adds a mock module that verifies parallel output against AnalysisDataTestInput.
[in] | data | Data to compare against. |
source | Data object to verify. |
Creates a parallel mock module that verifies that the IAnalysisDataModule methods are called correctly by source
. Parameters for the calls are verified against data
. Adds the created module to source
using data->addModule()
. Any exceptions from the called functions should be caught by the caller.
Differs from addStaticCheckerModule() in that the created mock module reports that it accepts parallel input data, and accepts and verifies notification calls following the parallel pattern.
|
static |
Adds a mock module that verifies output and storage against AnalysisDataTestInput.
[in] | data | Data to compare against. |
[in] | storageCount | Number of previous frames to check (-1 = all). |
source | Data object to verify. |
Works like addStaticCheckerModule(), except that in addition, for each frame, the mock module also checks that previous frames can be accessed using AbstractAnalysisData::getDataFrame(). In the IAnalysisDataModule::dataStarted() callback, the mock module calls AbstractAnalysisData::requestStorage() with storageCount
as the parameter.
|
static |
Initializes an array data object from AnalysisDataTestInput.
ArrayData | Class derived from AbstractAnalysisArrayData. |
The ArrayData class should expose the setter methods (setColumnCount(), setRowCount(), allocateValues(), setValue()) publicly or declare the fixture class as a friend. The X axis in data
must be configured to match input
before calling this method.
Does not call AbstractAnalysisArrayData::valuesReady(). The test must ensure that this method gets called, otherwise the mock modules never get called.
|
static |
Initializes an AnalysisData object from input data.
Sets the column count and other properties based on the input data.
|
protected |
Reference data object used for the reference checker modules.
Tests can use the data object also for their own purposes if needed.