Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkNodePredicateSourceTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
19 #include "mitkTestingMacros.h"
20 
21 int mitkNodePredicateSourceTest(int /* argc */, char * /*argv*/ [])
22 {
23  MITK_TEST_BEGIN("Testing nodePredicateSource")
24 
25  // Create a DataStorage
27  mitk::DataNode::Pointer godfather, grandMother, mother, daughter;
28  godfather = mitk::DataNode::New();
29  grandMother = mitk::DataNode::New();
30  mother = mitk::DataNode::New();
31  daughter = mitk::DataNode::New();
32 
33  myDataStorage->Add(godfather);
34  myDataStorage->Add(grandMother);
35  myDataStorage->Add(mother, grandMother);
36  myDataStorage->Add(daughter, mother);
37  mitk::NodePredicateSource::Pointer testPredicate = mitk::NodePredicateSource::New(grandMother, false, myDataStorage);
38  ;
39 
40  MITK_TEST_CONDITION_REQUIRED(true, "Testing instantiation");
41  MITK_TEST_CONDITION_REQUIRED(testPredicate->CheckNode(mother), "Node is derivative");
42  MITK_TEST_CONDITION_REQUIRED(!testPredicate->CheckNode(godfather), "Node is not derivative");
43  MITK_TEST_CONDITION_REQUIRED(!testPredicate->CheckNode(daughter),
44  "Node is derivative but only direct derivatives are wanted");
45 
46  testPredicate = mitk::NodePredicateSource::New(grandMother, true, myDataStorage);
47  MITK_TEST_CONDITION_REQUIRED(testPredicate->CheckNode(daughter),
48  "Node is not direct derivative and all derivatives are wanted ");
49  MITK_TEST_CONDITION_REQUIRED(!testPredicate->CheckNode(grandMother), "Self is not a derivative!");
50 
51  MITK_TEST_END();
52 }
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
int mitkNodePredicateSourceTest(int, char *[])
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
static Pointer New(mitk::DataNode *_arga, bool _argb, mitk::DataStorage *_argc)
static Pointer New()
and MITK_TEST_END()