Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
#include <mitkDataStorageCompare.h>
Public Types | |
enum | Tests { CMP_Nothing, CMP_Hierarchy, CMP_Data, CMP_Properties, CMP_Mappers, CMP_Interactors, CMP_All } |
Flag describing the aspects of comparing two DataStorages. More... | |
Public Member Functions | |
DataStorageCompare (const DataStorage *reference, const DataStorage *test, Tests flags=CMP_All, double eps=mitk::eps) | |
Constructor taking reference and test DataStorage. More... | |
bool | CompareVerbose () |
Shorthand for Compare(true). More... | |
bool | Compare (bool verbose=false) |
Execute the comparison. More... | |
void | Report () |
Prints a small summary of what tests have been executed and which ones failed or passed. More... | |
Helper class to compare two DataStorages.
This is purposely not a mitk::Equal() function because the main intention is to use this class for I/O testing, and because the definition of equal is really not clear for two DataStorages.
In the context of I/O tests, one could want to verify (given two storages "reference" and "test") that all nodes from reference are in test (identification of nodes is difficult) all nodes from test are in reference all property lists are identical (types and values) all data is identical (types, values) all mappers are identical (types, not state) all interactors are identical (type) ... ?
This class offers a number of flags that describe one of those aspects. These flags can be combined by the OR operator ("|"). The Compare() method will only test those aspects.
Once Compare() has been executed there are a couple of methods to query the results or print a small report.
Finding nodes: Identifying nodes to be compares poses a problem. This is because we don't have node identifiers but only names. Names are not unique and are not even required to exist or to be non-empty.
This class does not solve this problem completely. It identifies nodes by constructing an "identifier" that includes the node name and the BaseData class name of the node itself and all its direct and indirect parents.
This leaves certain cases where two nodes in the hierarchy would get the same identifier. For the use in test cases (
Definition at line 66 of file mitkDataStorageCompare.h.
Flag describing the aspects of comparing two DataStorages.
Flag values can be combined by the "|" operator (bitwise or).
Enumerator | |
---|---|
CMP_Nothing |
No tests. |
CMP_Hierarchy |
Compare hierarchy. |
CMP_Data |
Compare BaseData. |
CMP_Properties |
Compare PropertyLists. |
CMP_Mappers |
Compare Mapper types. |
CMP_Interactors |
Compare interactors. |
CMP_All |
Compare all known aspects. |
Definition at line 74 of file mitkDataStorageCompare.h.
mitk::DataStorageCompare::DataStorageCompare | ( | const DataStorage * | reference, |
const DataStorage * | test, | ||
Tests | flags = CMP_All , |
||
double | eps = mitk::eps |
||
) |
Constructor taking reference and test DataStorage.
reference | Reference DataStorage object. |
test | Test DataStorage object. |
flags | Flags describing the desired test aspects ( |
eps | precision for floating point comparisons. |
Definition at line 27 of file mitkDataStorageCompare.cpp.
References mitk::BaseDataCompare::RegisterCoreEquals().
bool mitk::DataStorageCompare::Compare | ( | bool | verbose = false | ) |
Execute the comparison.
verbose | if true, the comparison will output messages for all differences found and Report() will be called at the end. |
Definition at line 50 of file mitkDataStorageCompare.cpp.
bool mitk::DataStorageCompare::CompareVerbose | ( | ) |
Shorthand for Compare(true).
Definition at line 45 of file mitkDataStorageCompare.cpp.
void mitk::DataStorageCompare::Report | ( | ) |
Prints a small summary of what tests have been executed and which ones failed or passed.
Called automatically by Compare() when that method is called with the verbose flag.
Definition at line 83 of file mitkDataStorageCompare.cpp.
References MITK_INFO.