Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkModelFitUIDHelperTest.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 
13 #include <iostream>
14 #include "mitkTestingMacros.h"
15 #include "mitkDataNode.h"
16 #include "mitkImage.h"
18 
19 #include "mitkModelFitUIDHelper.h"
20 
21 int mitkModelFitUIDHelperTest(int /*argc*/, char*[] /*argv[]*/)
22 {
23  MITK_TEST_BEGIN("mitkModelFitUIDHelperTest")
24 
26  node1->SetData(mitk::Image::New());
28  node2->SetData(mitk::Image::New());
29 
30  mitk::DataNode* nullNode = nullptr;
31  mitk::BaseData* nullData = nullptr;
32 
34  MITK_TEST_CONDITION_REQUIRED(mitk::CheckModelFitUID(nullNode,"testUID") == false,
35  "Testing if CheckModelFitUID fails of null pointer is passed.");
37  MITK_TEST_CONDITION_REQUIRED(mitk::CheckModelFitUID(nullData, "testUID") == false,
38  "Testing if CheckModelFitUID fails of null pointer is passed.");
39 
41 
42  MITK_TEST_CONDITION_REQUIRED(mitk::CheckModelFitUID(node1,"testUID") == false,
43  "Testing if CheckModelFitUID fails of wrong UID is passed.");
45  "Testing if CheckModelFitUID succeeds if correct UID is passed.");
46 
47  mitk::NodeUIDType uid2ndCall = mitk::EnsureModelFitUID(node1);
48 
49  MITK_TEST_CONDITION_REQUIRED(uid == uid2ndCall,
50  "Testing if EnsureModelFitUID does not create new UIDs on multiple calls.");
51 
53 
54  MITK_TEST_CONDITION_REQUIRED(uid != uid2,
55  "Testing if EnsureModelFitUID does create different UIDs for different nodes.");
56 
58  storage->Add(node1);
59  storage->Add(node2);
60 
62  "Testing if GetNodeByModelFitUID finds node 1.");
63 
65  "Testing if GetNodeByModelFitUID finds node 2.");
66 
67  MITK_TEST_CONDITION_REQUIRED(GetNodeByModelFitUID(storage,"unkown_uid").IsNull(),
68  "Testing if GetNodeByModelFitUID returns NULL for unkown UID.");
69 
71 }
bool MITKMODELFIT_EXPORT CheckModelFitUID(const mitk::BaseData *data, const NodeUIDType &uid)
Base of all data objects.
Definition: mitkBaseData.h:37
DataNode::Pointer MITKMODELFIT_EXPORT GetNodeByModelFitUID(const mitk::DataStorage *storage, const NodeUIDType &uid)
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_FOR_EXCEPTION(EXCEPTIONCLASS, STATEMENT)
Simplified version of MITK_TEST_FOR_EXCEPTION_BEGIN / END for a single statement. ...
static Pointer New()
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
NodeUIDType MITKMODELFIT_EXPORT EnsureModelFitUID(mitk::BaseData *data)
static Pointer New()
std::string NodeUIDType
Definition: mitkUIDHelper.h:26
and MITK_TEST_END()
int mitkModelFitUIDHelperTest(int, char *[])
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64