24 std::cout <<
"Testing mitk::PropertyList::New(): ";
26 if (propList.IsNull())
28 std::cout <<
"[FAILED]" << std::endl;
33 std::cout <<
"[PASSED]" << std::endl;
37 std::cout <<
"Testing BoolProperty ==: ";
38 if (!(*boolProp2 == *boolProp))
40 std::cout <<
"[FAILED]" << std::endl;
43 std::cout <<
"[PASSED]" << std::endl;
44 unsigned long tBefore, tAfter;
46 std::cout <<
"Testing SetProperty() with new key value: ";
47 tBefore = propList->GetMTime();
48 propList->SetProperty(
"test", boolProp);
49 tAfter = propList->GetMTime();
50 if (!(tAfter > tBefore))
52 std::cout <<
"[FAILED]" << std::endl;
55 std::cout <<
"[PASSED]" << std::endl;
57 std::cout <<
"Testing SetProperty() with changed property value: ";
58 tBefore = propList->GetMTime();
60 tAfter = propList->GetMTime();
61 if (!(tAfter > tBefore))
63 std::cout <<
"[FAILED]" << std::endl;
66 std::cout <<
"[PASSED]" << std::endl;
68 std::cout <<
"Testing SetProperty() with unchanged property value: ";
69 tBefore = propList->GetMTime();
71 tAfter = propList->GetMTime();
72 if (tBefore != tAfter)
74 std::cout <<
"[FAILED]" << std::endl;
77 std::cout <<
"[PASSED]" << std::endl;
79 std::cout <<
"Testing MTime correctness when changing property value: ";
81 propList->ReplaceProperty(
"test", boolProp);
82 tBefore = propList->GetMTime();
83 boolProp->SetValue(
true);
84 tAfter = propList->GetMTime();
85 boolProp->SetValue(
false);
86 unsigned long tAfterAll = propList->GetMTime();
88 if (tBefore != tAfter || tAfterAll <= tAfter)
90 std::cout <<
"[FAILED]" << std::endl;
93 std::cout <<
"[PASSED]" << std::endl;
95 std::cout <<
"Testing MTime correctness when calling SetProperty twice: ";
97 propList->SetProperty(
"test", boolProp);
98 tBefore = propList->GetMTime();
99 propList->SetProperty(
"test", boolProp);
100 tAfter = propList->GetMTime();
102 if (tBefore != tAfter)
104 std::cout <<
"[FAILED]" << std::endl;
107 std::cout <<
"[PASSED]" << std::endl;
109 std::cout <<
"Testing if existing properties survive SetProperty: ";
110 propList->SetProperty(
"test", boolProp);
112 propList->SetProperty(
"test", boolProp2);
115 if (bpBefore != bpAfter || bpAfter ==
nullptr)
117 std::cout << std::endl;
118 std::cout <<
"[FAILED]" << std::endl;
121 std::cout <<
"[PASSED]" << std::endl;
123 std::cout <<
"Testing if existing properties survive ReplaceProperty: ";
124 propList->SetProperty(
"test", boolProp);
125 bpBefore = propList->GetProperty(
"test");
126 propList->ReplaceProperty(
"test", boolProp2);
127 bpAfter = propList->GetProperty(
"test");
129 if (bpBefore == bpAfter || bpAfter ==
nullptr)
131 std::cout << std::endl;
132 std::cout <<
"[FAILED]" << std::endl;
135 std::cout <<
"[PASSED]" << std::endl;
143 std::cout <<
"Testing GetPropertyValue(bool): ";
145 propList->SetProperty(
"gpvBool", gpvTest);
147 bool getPropertyValueReturnValue = propList->GetPropertyValue<
bool>(
"gpvBool", b);
148 if ((getPropertyValueReturnValue ==
true) && (b == gpvTest->GetValue()))
149 std::cout <<
"[PASSED]" << std::endl;
152 std::cout <<
"Oh, not goot:" 153 "\nWe called propList->GetPropertyValue<bool>('gpvBool', b) and it returned " 154 << getPropertyValueReturnValue <<
"\nThen we compared b [" << b <<
"] and gpvTest->GetValue() [" 155 << gpvTest->GetValue() <<
"]" << std::endl;
156 std::cout <<
"[FAILED]" << std::endl;
160 std::cout <<
"Testing GetPropertyValue(float): ";
162 propList->SetProperty(
"gpvfloat", gpvTest2);
164 if ((propList->GetPropertyValue<
float>(
"gpvfloat", v) ==
true) && (v == gpvTest2->GetValue()))
165 std::cout <<
"[PASSED]" << std::endl;
168 std::cout <<
"[FAILED]" << std::endl;
172 std::cout <<
"Testing GetPropertyValue(BoolLookupTable): ";
181 std::cout <<
"[PASSED]" << std::endl;
184 std::cout <<
"[FAILED]" << std::endl;
190 std::cout <<
"Exception thrown! [FAILED]" << std::endl;
195 std::cout <<
"Testing GetBoolProperty(): ";
197 propList->ReplaceProperty(
"test", prop);
199 if ((propList->GetBoolProperty(
"test", v) ==
true) && (v == prop->GetValue()))
200 std::cout <<
"[PASSED]" << std::endl;
203 std::cout <<
"[FAILED]" << std::endl;
208 std::cout <<
"Testing GetIntProperty(): ";
210 propList->ReplaceProperty(
"test", prop);
212 if ((propList->GetIntProperty(
"test", v) ==
true) && (v == prop->GetValue()))
213 std::cout <<
"[PASSED]" << std::endl;
216 std::cout <<
"[FAILED]" << std::endl;
221 std::cout <<
"Testing GetFloatProperty(): ";
223 propList->ReplaceProperty(
"test", prop);
225 if ((propList->GetFloatProperty(
"test", v) ==
true) && (v == prop->GetValue()))
226 std::cout <<
"[PASSED]" << std::endl;
229 std::cout <<
"[FAILED]" << std::endl;
234 std::cout <<
"Testing GetStringProperty(): ";
236 propList->ReplaceProperty(
"test", prop);
238 if ((propList->GetStringProperty(
"test", v) ==
true) && (v == prop->GetValue()))
239 std::cout <<
"[PASSED]" << std::endl;
242 std::cout <<
"[FAILED]" << std::endl;
248 std::cout <<
"Testing RemoveProperty(): ";
249 propList->RemoveProperty(
"test");
250 if (propList->GetProperty(
"test")!=
nullptr)
252 std::cout <<
"[FAILED]" << std::endl;
255 std::cout <<
"[PASSED]" << std::endl;
258 std::cout <<
"Testing SetProperty() with no property (nullptr): ";
259 tBefore = propList->GetMTime();
260 propList->SetProperty(
"nullprop",
nullptr);
261 tAfter = propList->GetMTime();
262 if (!(tAfter == tBefore))
264 std::cout <<
"[FAILED]" << std::endl;
267 std::cout <<
"[PASSED]" << std::endl;
269 std::cout <<
"Testing SetProperty() with invalid (empty) name: ";
272 propList->SetProperty(
"", boolProp);
273 std::cout <<
"[FAILED]" << std::endl;
278 std::cout <<
"[PASSED]" << std::endl;
282 std::cout <<
"[FAILED]" << std::endl;
286 std::cout <<
"[TEST DONE]" << std::endl;
void SetTableValue(IdentifierType id, ValueType value)
Abstract base class for properties.
ValueType GetTableValue(IdentifierType id) const
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
int mitkPropertyListTest(int, char *[])
specializations of GenericLookupTable