Gromacs  2016.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
gmx::test::AnalysisDataTestFixture Class Reference

#include <gromacs/analysisdata/tests/datatest.h>

Inherits Test.

+ Collaboration diagram for gmx::test::AnalysisDataTestFixture:

Description

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.

Todo:
Support for arbitrary AnalysisDataValues (errors and missing values).
See Also
AnalysisDataTestInput

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...
 

Member Function Documentation

void gmx::test::AnalysisDataTestFixture::addReferenceCheckerModule ( const TestReferenceChecker checker,
const char *  id,
AbstractAnalysisData source,
const FloatingPointTolerance tolerance 
)
static

Adds a mock module that verifies output against reference data.

Parameters
[in]checkerReference data checker to use for comparison.
[in]idIdentifier for reference data compound to use.
sourceData object to verify.
[in]toleranceTolerance 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.

See Also
TestReferenceData
void gmx::test::AnalysisDataTestFixture::addReferenceCheckerModule ( const char *  id,
AbstractAnalysisData source 
)

Adds a mock module that verifies output against reference data.

Parameters
[in]idIdentifier for reference data compound to use.
sourceData 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.

void gmx::test::AnalysisDataTestFixture::addStaticCheckerModule ( const AnalysisDataTestInput data,
AbstractAnalysisData source 
)
static

Adds a mock module that verifies output against AnalysisDataTestInput.

Parameters
[in]dataData to compare against.
sourceData 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.

See Also
AbstractAnalysisData::addModule()
void gmx::test::AnalysisDataTestFixture::addStaticColumnCheckerModule ( const AnalysisDataTestInput data,
int  firstcol,
int  n,
AbstractAnalysisData source 
)
static

Adds a column mock module that verifies output against AnalysisDataTestInput.

Parameters
[in]dataData to compare against.
[in]firstcolFirst column to check.
[in]nNumber of columns to check.
sourceData 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.

See Also
AbstractAnalysisData::addColumnModule()
void gmx::test::AnalysisDataTestFixture::addStaticParallelCheckerModule ( const AnalysisDataTestInput data,
AbstractAnalysisData source 
)
static

Adds a mock module that verifies parallel output against AnalysisDataTestInput.

Parameters
[in]dataData to compare against.
sourceData 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.

See Also
AbstractAnalysisData::addModule()
void gmx::test::AnalysisDataTestFixture::addStaticStorageCheckerModule ( const AnalysisDataTestInput data,
int  storageCount,
AbstractAnalysisData source 
)
static

Adds a mock module that verifies output and storage against AnalysisDataTestInput.

Parameters
[in]dataData to compare against.
[in]storageCountNumber of previous frames to check (-1 = all).
sourceData 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.

template<class ArrayData >
void gmx::test::AnalysisDataTestFixture::setupArrayData ( const AnalysisDataTestInput input,
ArrayData *  data 
)
static

Initializes an array data object from AnalysisDataTestInput.

Template Parameters
ArrayDataClass 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.

void gmx::test::AnalysisDataTestFixture::setupDataObject ( const AnalysisDataTestInput input,
AnalysisData data 
)
static

Initializes an AnalysisData object from input data.

Sets the column count and other properties based on the input data.

Member Data Documentation

gmx::test::TestReferenceData gmx::test::AnalysisDataTestFixture::data_
protected

Reference data object used for the reference checker modules.

Tests can use the data object also for their own purposes if needed.


The documentation for this class was generated from the following files: