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