26 std::cout <<
"Testing mitk::PropertyList::New(): ";
28 if (propList.IsNull())
30 std::cout <<
"[FAILED]" << std::endl;
35 std::cout <<
"[PASSED]" << std::endl;
39 std::cout <<
"Testing BoolProperty ==: ";
40 if (!(*boolProp2 == *boolProp))
42 std::cout <<
"[FAILED]" << std::endl;
45 std::cout <<
"[PASSED]" << std::endl;
46 unsigned long tBefore, tAfter;
48 std::cout <<
"Testing SetProperty() with new key value: ";
49 tBefore = propList->GetMTime();
50 propList->SetProperty(
"test", boolProp);
51 tAfter = propList->GetMTime();
52 if (!(tAfter > tBefore))
54 std::cout <<
"[FAILED]" << std::endl;
57 std::cout <<
"[PASSED]" << std::endl;
59 std::cout <<
"Testing SetProperty() with changed property value: ";
60 tBefore = propList->GetMTime();
62 tAfter = propList->GetMTime();
63 if (!(tAfter > tBefore))
65 std::cout <<
"[FAILED]" << std::endl;
68 std::cout <<
"[PASSED]" << std::endl;
70 std::cout <<
"Testing SetProperty() with unchanged property value: ";
71 tBefore = propList->GetMTime();
73 tAfter = propList->GetMTime();
74 if (tBefore != tAfter)
76 std::cout <<
"[FAILED]" << std::endl;
79 std::cout <<
"[PASSED]" << std::endl;
81 std::cout <<
"Testing MTime correctness when changing property value: ";
83 propList->ReplaceProperty(
"test", boolProp);
84 tBefore = propList->GetMTime();
85 boolProp->SetValue(
true);
86 tAfter = propList->GetMTime();
87 boolProp->SetValue(
false);
88 unsigned long tAfterAll = propList->GetMTime();
90 if (tBefore != tAfter || tAfterAll <= tAfter)
92 std::cout <<
"[FAILED]" << std::endl;
95 std::cout <<
"[PASSED]" << std::endl;
97 std::cout <<
"Testing MTime correctness when calling SetProperty twice: ";
99 propList->SetProperty(
"test", boolProp);
100 tBefore = propList->GetMTime();
101 propList->SetProperty(
"test", boolProp);
102 tAfter = propList->GetMTime();
104 if (tBefore != tAfter)
106 std::cout <<
"[FAILED]" << std::endl;
109 std::cout <<
"[PASSED]" << std::endl;
111 std::cout <<
"Testing if existing properties survive SetProperty: ";
112 propList->SetProperty(
"test", boolProp);
114 propList->SetProperty(
"test", boolProp2);
117 if (bpBefore != bpAfter || bpAfter ==
nullptr)
119 std::cout << std::endl;
120 std::cout <<
"[FAILED]" << std::endl;
123 std::cout <<
"[PASSED]" << std::endl;
125 std::cout <<
"Testing if existing properties survive ReplaceProperty: ";
126 propList->SetProperty(
"test", boolProp);
127 bpBefore = propList->GetProperty(
"test");
128 propList->ReplaceProperty(
"test", boolProp2);
129 bpAfter = propList->GetProperty(
"test");
131 if (bpBefore == bpAfter || bpAfter ==
nullptr)
133 std::cout << std::endl;
134 std::cout <<
"[FAILED]" << std::endl;
137 std::cout <<
"[PASSED]" << std::endl;
145 std::cout <<
"Testing GetPropertyValue(bool): ";
147 propList->SetProperty(
"gpvBool", gpvTest);
149 bool getPropertyValueReturnValue = propList->GetPropertyValue<
bool>(
"gpvBool", b);
150 if ((getPropertyValueReturnValue ==
true) && (b == gpvTest->GetValue()))
151 std::cout <<
"[PASSED]" << std::endl;
154 std::cout <<
"Oh, not goot:"
155 "\nWe called propList->GetPropertyValue<bool>('gpvBool', b) and it returned "
156 << getPropertyValueReturnValue <<
"\nThen we compared b [" << b <<
"] and gpvTest->GetValue() ["
157 << gpvTest->GetValue() <<
"]" << std::endl;
158 std::cout <<
"[FAILED]" << std::endl;
162 std::cout <<
"Testing GetPropertyValue(float): ";
164 propList->SetProperty(
"gpvfloat", gpvTest2);
166 if ((propList->GetPropertyValue<
float>(
"gpvfloat", v) ==
true) && (v == gpvTest2->GetValue()))
167 std::cout <<
"[PASSED]" << std::endl;
170 std::cout <<
"[FAILED]" << std::endl;
174 std::cout <<
"Testing GetPropertyValue(BoolLookupTable): ";
183 std::cout <<
"[PASSED]" << std::endl;
186 std::cout <<
"[FAILED]" << std::endl;
192 std::cout <<
"Exception thrown! [FAILED]" << std::endl;
197 std::cout <<
"Testing GetBoolProperty(): ";
199 propList->ReplaceProperty(
"test", prop);
201 if ((propList->GetBoolProperty(
"test", v) ==
true) && (v == prop->GetValue()))
202 std::cout <<
"[PASSED]" << std::endl;
205 std::cout <<
"[FAILED]" << std::endl;
210 std::cout <<
"Testing GetIntProperty(): ";
212 propList->ReplaceProperty(
"test", prop);
214 if ((propList->GetIntProperty(
"test", v) ==
true) && (v == prop->GetValue()))
215 std::cout <<
"[PASSED]" << std::endl;
218 std::cout <<
"[FAILED]" << std::endl;
223 std::cout <<
"Testing GetFloatProperty(): ";
225 propList->ReplaceProperty(
"test", prop);
227 if ((propList->GetFloatProperty(
"test", v) ==
true) && (v == prop->GetValue()))
228 std::cout <<
"[PASSED]" << std::endl;
231 std::cout <<
"[FAILED]" << std::endl;
236 std::cout <<
"Testing GetStringProperty(): ";
238 propList->ReplaceProperty(
"test", prop);
240 if ((propList->GetStringProperty(
"test", v) ==
true) && (v == prop->GetValue()))
241 std::cout <<
"[PASSED]" << std::endl;
244 std::cout <<
"[FAILED]" << std::endl;
249 std::cout <<
"[TEST DONE]" << std::endl;
void SetTableValue(IdentifierType id, ValueType value)
ValueType GetTableValue(IdentifierType id) const
Abstract base class for properties.
int mitkPropertyListTest(int, char *[])
specializations of GenericLookupTable