MCPcopy Create free account
hub / github.com/MITK/MITK / mitkEnumerationPropertyTest

Function mitkEnumerationPropertyTest

Modules/Core/test/mitkEnumerationPropertyTest.cpp:18–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <vtkProperty.h>
17
18int mitkEnumerationPropertyTest(int /*argc*/, char * /*argv*/ [])
19{
20 mitk::EnumerationProperty::Pointer enumerationProperty(mitk::EnumerationProperty::New());
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;

Callers

nothing calls this directly

Calls 10

GetValueAsIdMethod · 0.80
NewFunction · 0.50
AddEnumMethod · 0.45
SizeMethod · 0.45
SetValueMethod · 0.45
GetValueAsStringMethod · 0.45
GetVtkInterpolationMethod · 0.45
GetVtkRepresentationMethod · 0.45

Tested by

no test coverage detected