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
mitkEnumerationPropertyTest.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 
20 #include <vtkProperty.h>
21 
22 int mitkEnumerationPropertyTest(int /*argc*/, char * /*argv*/ [])
23 {
25 
26  std::cout << "Testing mitk::EnumerationProperty::AddEnum(...): ";
27  bool success = true;
28  success = success && enumerationProperty->AddEnum("first", 1);
29  success = success && enumerationProperty->AddEnum("second", 2);
30  success = success && enumerationProperty->AddEnum("third", 3);
31  if (!success)
32  {
33  std::cout << "[FAILED]" << std::endl;
34  return EXIT_FAILURE;
35  }
36  else
37  {
38  std::cout << "[PASSED]" << std::endl;
39  }
40 
41  std::cout << "Testing mitk::EnumerationProperty::Size(): ";
42  if (enumerationProperty->Size() != 3)
43  {
44  std::cout << "[FAILED]" << std::endl;
45  return EXIT_FAILURE;
46  }
47  else
48  {
49  std::cout << "[PASSED]" << std::endl;
50  }
51 
52  std::cout << "Testing mitk::EnumerationProperty::AddEnum() with invalid entries: ";
53  if (enumerationProperty->AddEnum("first", 0))
54  {
55  std::cout << "[FAILED]" << std::endl;
56  return EXIT_FAILURE;
57  }
58  else
59  {
60  std::cout << "[PASSED]" << std::endl;
61  }
62 
63  std::cout << "Testing mitk::EnumerationProperty::SetValue(id): ";
64  if (!enumerationProperty->SetValue(2))
65  {
66  std::cout << "[FAILED]" << std::endl;
67  return EXIT_FAILURE;
68  }
69  if (enumerationProperty->GetValueAsId() != 2)
70  {
71  std::cout << "[FAILED]" << std::endl;
72  return EXIT_FAILURE;
73  }
74  if (enumerationProperty->GetValueAsString() != "second")
75  {
76  std::cout << "[FAILED]" << std::endl;
77  return EXIT_FAILURE;
78  }
79  std::cout << "[PASSED]" << std::endl;
80 
81  std::cout << "Testing mitk::EnumerationProperty::SetValue(name): ";
82  if (!enumerationProperty->SetValue("third"))
83  {
84  std::cout << "[FAILED]" << std::endl;
85  return EXIT_FAILURE;
86  }
87  if (enumerationProperty->GetValueAsId() != 3)
88  {
89  std::cout << "[FAILED]" << std::endl;
90  return EXIT_FAILURE;
91  }
92  if (enumerationProperty->GetValueAsString() != "third")
93  {
94  std::cout << "[FAILED]" << std::endl;
95  return EXIT_FAILURE;
96  }
97  std::cout << "[PASSED]" << std::endl;
98 
99  std::cout << "Testing mitk::EnumerationProperty::SetValue(invalid id): ";
100  if (enumerationProperty->SetValue(100))
101  {
102  std::cout << "[FAILED]" << std::endl;
103  return EXIT_FAILURE;
104  }
105  std::cout << "[PASSED]" << std::endl;
106 
107  std::cout << "Testing mitk::EnumerationProperty::SetValue(invalid name): ";
108  if (enumerationProperty->SetValue("madmax"))
109  {
110  std::cout << "[FAILED]" << std::endl;
111  return EXIT_FAILURE;
112  }
113  std::cout << "[PASSED]" << std::endl;
114 
115  std::cout << "Testing mitk::VtkInterpolationType::SetInterpolationToPhong(): ";
117  ;
118  vtkInterpolationProperty->SetInterpolationToPhong();
119  if (vtkInterpolationProperty->GetValueAsString() != "Phong")
120  {
121  std::cout << "[FAILED]" << std::endl;
122  return EXIT_FAILURE;
123  }
124  if (vtkInterpolationProperty->GetValueAsId() != 2)
125  {
126  std::cout << "[FAILED]" << std::endl;
127  return EXIT_FAILURE;
128  }
129  if (vtkInterpolationProperty->GetVtkInterpolation() != VTK_PHONG)
130  {
131  std::cout << "[FAILED]" << std::endl;
132  return EXIT_FAILURE;
133  }
134  std::cout << "[PASSED]" << std::endl;
135 
136  std::cout << "Testing mitk::VtkRepresentationType::SetRepresentationToWireframe(): ";
138  vtkRepresentationProperty->SetRepresentationToWireframe();
139  if (vtkRepresentationProperty->GetValueAsString() != "Wireframe")
140  {
141  std::cout << "[FAILED]" << std::endl;
142  return EXIT_FAILURE;
143  }
144  if (vtkRepresentationProperty->GetValueAsId() != 1)
145  {
146  std::cout << "[FAILED]" << std::endl;
147  return EXIT_FAILURE;
148  }
149  if (vtkRepresentationProperty->GetVtkRepresentation() != VTK_WIREFRAME)
150  {
151  std::cout << "[FAILED]" << std::endl;
152  return EXIT_FAILURE;
153  }
154  std::cout << "[PASSED]" << std::endl;
155 
156  std::cout << "[TEST DONE]" << std::endl;
157  return EXIT_SUCCESS;
158 }
int mitkEnumerationPropertyTest(int, char *[])
static Pointer New()