Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
15 #include "mitkTestingMacros.h"
16 
17 int mitkNodePredicateSourceTest(int /* argc */, char * /*argv*/ [])
18 {
19  MITK_TEST_BEGIN("Testing nodePredicateSource")
20 
21  // Create a DataStorage
23  mitk::DataNode::Pointer godfather, grandMother, mother, daughter;
24  godfather = mitk::DataNode::New();
25  grandMother = mitk::DataNode::New();
26  mother = mitk::DataNode::New();
27  daughter = mitk::DataNode::New();
28 
29  myDataStorage->Add(godfather);
30  myDataStorage->Add(grandMother);
31  myDataStorage->Add(mother, grandMother);
32  myDataStorage->Add(daughter, mother);
33  mitk::NodePredicateSource::Pointer testPredicate = mitk::NodePredicateSource::New(grandMother, false, myDataStorage);
34  ;
35 
36  MITK_TEST_CONDITION_REQUIRED(true, "Testing instantiation");
37  MITK_TEST_CONDITION_REQUIRED(testPredicate->CheckNode(mother), "Node is derivative");
38  MITK_TEST_CONDITION_REQUIRED(!testPredicate->CheckNode(godfather), "Node is not derivative");
39  MITK_TEST_CONDITION_REQUIRED(!testPredicate->CheckNode(daughter),
40  "Node is derivative but only direct derivatives are wanted");
41 
42  testPredicate = mitk::NodePredicateSource::New(grandMother, true, myDataStorage);
43  MITK_TEST_CONDITION_REQUIRED(testPredicate->CheckNode(daughter),
44  "Node is not direct derivative and all derivatives are wanted ");
45  MITK_TEST_CONDITION_REQUIRED(!testPredicate->CheckNode(grandMother), "Self is not a derivative!");
46 
47  MITK_TEST_END();
48 }
#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()