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
mitkOrganTypePropertyTest.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 
17 #include "mitkCoreObjectFactory.h"
18 #include "mitkOrganTypeProperty.h"
19 
21 int mitkOrganTypePropertyTest(int /*argc*/, char * /*argv*/ [])
22 {
23  const char *NEW_ORGAN =
24  "Der Knopf von der Eingangstuer von der Siebenschlaeferbehausung ist aus Messing damit es nicht so schnell rostet";
25 
26  // one big variable to tell if anything went wrong
27  unsigned int numberFailed(0);
28 
29  std::cout << "Instantiation" << std::endl;
30 
31  // instantiation
33  if (prop1.IsNotNull())
34  {
35  std::cout << " (II) Instantiation works." << std::endl;
36  }
37  else
38  {
39  ++numberFailed;
40  std::cout << numberFailed << " test failed, and it's the ugliest one!" << std::endl;
41  return EXIT_FAILURE;
42  }
43 
45  if (prop1.IsNotNull())
46  {
47  std::cout << " (II) Instantiation still works." << std::endl;
48  }
49  else
50  {
51  ++numberFailed;
52  std::cout << numberFailed << " test failed, and it's the ugliest one!" << std::endl;
53  return EXIT_FAILURE;
54  }
55 
56  // add an allowed value to prop1, test if it is now valid for prop2, too
57  prop1->AddEnum(NEW_ORGAN, prop1->Size());
58 
59  if (!prop1->IsValidEnumerationValue(NEW_ORGAN))
60  {
61  ++numberFailed;
62  std::cout << " (EE) New organ is not a valid enumeration type after adding calling AddEnum()." << std::endl;
63  }
64  else
65  {
66  std::cout << " (II) AddEnum() works." << std::endl;
67  }
68 
69  if (!prop2->IsValidEnumerationValue(NEW_ORGAN))
70  {
71  ++numberFailed;
72  std::cout << " (EE) New organ type did not propagate to a second instance of OrganTypeProperty." << std::endl;
73  }
74 
75  std::cout << "Object destruction" << std::endl;
76 
77  // freeing
78  prop1 = NULL;
79  std::cout << " (II) Freeing works for first property." << std::endl;
80  prop2 = NULL;
81 
82  std::cout << " (II) Freeing works for both properties." << std::endl;
83 
84  if (numberFailed > 0)
85  {
86  std::cout << numberFailed << " tests failed." << std::endl;
87  return EXIT_FAILURE;
88  }
89  else
90  {
91  std::cout << "PASSED all tests." << std::endl;
92  return EXIT_SUCCESS;
93  }
94 }
int mitkOrganTypePropertyTest(int, char *[])
ctest entry point
static Pointer New()