22 CPPUNIT_TEST_SUITE(mitkPropertyKeyPathTestSuite);
34 CPPUNIT_TEST_SUITE_END();
75 void tearDown()
override {}
77 void AccessFunctions()
79 const auto constEmptyPath = emptyPath;
80 const auto constVerydeepPath = verydeepPath;
89 CPPUNIT_ASSERT_EQUAL_MESSAGE(
90 "Testing GetFirstNode with 'a.[*].*.c.d.[4].e'", std::string(
"a"), verydeepPath.
GetFirstNode().
name);
91 CPPUNIT_ASSERT_EQUAL_MESSAGE(
92 "Testing const GetFirstNode with 'a.[*].*.c.d.[4].e'", std::string(
"a"), constVerydeepPath.GetFirstNode().name);
93 CPPUNIT_ASSERT_EQUAL_MESSAGE(
94 "Testing GetLastNode with 'a.[*].*.c.d.[4].e'", std::string(
"e"), verydeepPath.
GetLastNode().
name);
95 CPPUNIT_ASSERT_EQUAL_MESSAGE(
96 "Testing GetLastNode with 'a.[*].*.c.d.[4].e'", std::string(
"e"), constVerydeepPath.GetLastNode().name);
97 CPPUNIT_ASSERT_EQUAL_MESSAGE(
98 "Testing GetNode(3) with 'a.[*].*.c.d.[4].e'", std::string(
"d"), verydeepPath.
GetNode(3).
name);
99 CPPUNIT_ASSERT_EQUAL_MESSAGE(
100 "Testing GetNode(3) with 'a.[*].*.c.d.[4].e'", std::string(
"d"), constVerydeepPath.GetNode(3).name);
102 CPPUNIT_ASSERT(5 == constVerydeepPath.GetSize());
103 CPPUNIT_ASSERT(0 == emptyPath.
GetSize());
109 CPPUNIT_ASSERT_EQUAL_MESSAGE(
110 "Testing PropertyKeyPathToPropertyRegEx() with 'simple'", std::string(
"simple"), result);
112 CPPUNIT_ASSERT_EQUAL_MESSAGE(
113 "Testing PropertyKeyPathToPropertyRegEx() with 'a.b2.c3'", std::string(
"a\\.b2\\.c3"), result);
115 CPPUNIT_ASSERT_EQUAL_MESSAGE(
116 "Testing PropertyKeyPathToPropertyRegEx() with 'a.*.c3'", std::string(
"a\\.([a-zA-Z0-9- ]+)\\.c3"), result);
118 CPPUNIT_ASSERT_EQUAL_MESSAGE(
119 "Testing PropertyKeyPathToPropertyRegEx() with 'a.b.[*].c'", std::string(
"a\\.b\\.\\[(\\d*)\\]\\.c"), result);
121 CPPUNIT_ASSERT_EQUAL_MESSAGE(
122 "Testing PropertyKeyPathToPropertyRegEx() with 'a.b.[6].c'", std::string(
"a\\.b\\.\\[6\\]\\.c"), result);
124 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyKeyPathToPropertyRegEx() with 'a.[*].*.c.d.[4].e'",
125 std::string(
"a\\.\\[(\\d*)\\]\\.([a-zA-Z0-9- ]+)\\.c\\.d\\.\\[4\\]\\.e"),
132 CPPUNIT_ASSERT_EQUAL_MESSAGE(
133 "Testing PropertyKeyPathToPersistenceKeyRegEx() with 'simple'", std::string(
"simple"), result);
135 CPPUNIT_ASSERT_EQUAL_MESSAGE(
136 "Testing PropertyKeyPathToPersistenceKeyRegEx() with 'a.b2.c3'", std::string(
"a_b2_c3"), result);
138 CPPUNIT_ASSERT_EQUAL_MESSAGE(
139 "Testing PropertyKeyPathToPersistenceKeyRegEx() with 'a.*.c3'", std::string(
"a_([a-zA-Z0-9- ]+)_c3"), result);
141 CPPUNIT_ASSERT_EQUAL_MESSAGE(
142 "Testing PropertyKeyPathToPersistenceKeyRegEx() with 'a.b.[*].c'", std::string(
"a_b_\\[(\\d*)\\]_c"), result);
144 CPPUNIT_ASSERT_EQUAL_MESSAGE(
145 "Testing PropertyKeyPathToPersistenceKeyRegEx() with 'a.b.[6].c'", std::string(
"a_b_\\[6\\]_c"), result);
147 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyKeyPathToPersistenceKeyRegEx() with 'a.[*].*.c.d.[4].e'",
148 std::string(
"a_\\[(\\d*)\\]_([a-zA-Z0-9- ]+)_c_d_\\[4\\]_e"),
155 CPPUNIT_ASSERT_EQUAL_MESSAGE(
156 "Testing PropertyKeyPathToPersistenceKeyTemplate() with 'simple'", std::string(
"simple"), result);
158 CPPUNIT_ASSERT_EQUAL_MESSAGE(
159 "Testing PropertyKeyPathToPersistenceKeyTemplate() with 'a.b2.c3'", std::string(
"a_b2_c3"), result);
161 CPPUNIT_ASSERT_EQUAL_MESSAGE(
162 "Testing PropertyKeyPathToPersistenceKeyTemplate() with 'a.*.c3'", std::string(
"a_$1_c3"), result);
164 CPPUNIT_ASSERT_EQUAL_MESSAGE(
165 "Testing PropertyKeyPathToPersistenceKeyTemplate() with 'a.b.[*].c'", std::string(
"a_b_[$1]_c"), result);
167 CPPUNIT_ASSERT_EQUAL_MESSAGE(
168 "Testing PropertyKeyPathToPersistenceKeyTemplate() with 'a.b.[6].c'", std::string(
"a_b_[6]_c"), result);
170 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyKeyPathToPersistenceKeyTemplate() with 'a.[*].*.c.d.[4].e'",
171 std::string(
"a_[$1]_$2_c_d_[4]_e"),
178 CPPUNIT_ASSERT_EQUAL_MESSAGE(
179 "Testing PropertyKeyPathToPersistenceNameTemplate() with 'simple'", std::string(
"simple"), result);
181 CPPUNIT_ASSERT_EQUAL_MESSAGE(
182 "Testing PropertyKeyPathToPersistenceNameTemplate() with 'a.b2.c3'", std::string(
"a.b2.c3"), result);
184 CPPUNIT_ASSERT_EQUAL_MESSAGE(
185 "Testing PropertyKeyPathToPersistenceNameTemplate() with 'a.*.c3'", std::string(
"a.$1.c3"), result);
187 CPPUNIT_ASSERT_EQUAL_MESSAGE(
188 "Testing PropertyKeyPathToPersistenceNameTemplate() with 'a.b.[*].c'", std::string(
"a.b.[$1].c"), result);
190 CPPUNIT_ASSERT_EQUAL_MESSAGE(
191 "Testing PropertyKeyPathToPersistenceNameTemplate() with 'a.b.[6].c'", std::string(
"a.b.[6].c"), result);
193 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyKeyPathToPersistenceNameTemplate() with 'a.[*].*.c.d.[4].e'",
194 std::string(
"a.[$1].$2.c.d.[4].e"),
201 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyNameToPropertyKeyPath() with 'simple'", simplePath, result);
203 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyNameToPropertyKeyPath() with 'a.b2.c3'", deepPath, result);
205 CPPUNIT_ASSERT_EQUAL_MESSAGE(
206 "Testing PropertyNameToPropertyKeyPath() with 'a.*.c3'", deepPath_withAnyElement, result);
208 CPPUNIT_ASSERT_EQUAL_MESSAGE(
209 "Testing PropertyNameToPropertyKeyPath() with 'a.b.[*].c'", deepPath_withAnySelection, result);
211 CPPUNIT_ASSERT_EQUAL_MESSAGE(
212 "Testing PropertyNameToPropertyKeyPath() with 'a.b.[6].c'", deepPath_withSelection, result);
214 CPPUNIT_ASSERT_EQUAL_MESSAGE(
215 "Testing PropertyNameToPropertyKeyPath() with 'a.[*].*.c.d.[4].e'", verydeepPath, result);
218 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyNameToPropertyKeyPath() with 'AA-11'", simplePath2, result);
221 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyNameToPropertyKeyPath() with wrong path", emptyPath, result);
223 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyNameToPropertyKeyPath() with wrong path", emptyPath, result);
225 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing PropertyNameToPropertyKeyPath() with wrong path", emptyPath, result);
231 CPPUNIT_ASSERT_EQUAL_MESSAGE(
232 "Testing PropertyKeyPathToPropertyName() with 'simple'", result, std::string(
"simple"));
234 CPPUNIT_ASSERT_EQUAL_MESSAGE(
235 "Testing PropertyKeyPathToPropertyName() with 'a.b2.c3'", result, std::string(
"a.b2.c3"));
237 CPPUNIT_ASSERT_EQUAL_MESSAGE(
238 "Testing PropertyKeyPathToPropertyName() with 'a.*.c3'", result, std::string(
"a.*.c3"));
240 CPPUNIT_ASSERT_EQUAL_MESSAGE(
241 "Testing PropertyKeyPathToPropertyName() with 'a.b.[*].c'", result, std::string(
"a.b.[*].c"));
243 CPPUNIT_ASSERT_EQUAL_MESSAGE(
244 "Testing PropertyKeyPathToPropertyName() with 'a.b.[6].c'", result, std::string(
"a.b.[6].c"));
246 CPPUNIT_ASSERT_EQUAL_MESSAGE(
247 "Testing PropertyKeyPathToPropertyName() with 'a.[*].*.c.d.[4].e'", result, std::string(
"a.[*].*.c.d.[4].e"));
255 CPPUNIT_ASSERT(deepPath_noSelection < deepPath);
256 CPPUNIT_ASSERT(deepPath_noSelection < deepPath_withSelection);
257 CPPUNIT_ASSERT(deepPath_withSelection < deepPath);
258 CPPUNIT_ASSERT(deepPath_withSelection < deepPath_withAnySelection);
259 CPPUNIT_ASSERT(deepPath_withAnyElement < deepPath_noSelection);
261 CPPUNIT_ASSERT(!(deepPath_noSelection < deepPath_noSelection));
262 CPPUNIT_ASSERT(!(deepPath_noSelection > deepPath_noSelection));
263 CPPUNIT_ASSERT(deepPath_noSelection <= deepPath_noSelection);
264 CPPUNIT_ASSERT(deepPath_noSelection >= deepPath_noSelection);
267 void ExecutePropertyRegEx()
271 CPPUNIT_ASSERT(std::regex_match(result, regEx));
274 CPPUNIT_ASSERT(std::regex_match(result, regEx));
278 auto position = result.find(
"*");
279 if (std::string::npos != position)
281 result.replace(position, 1,
"ConcreteNode1");
282 CPPUNIT_ASSERT(std::regex_match(result, regEx));
287 position = result.find(
"[*]");
288 if (std::string::npos != position)
290 result.replace(position, 3,
"[10]");
291 CPPUNIT_ASSERT(std::regex_match(result, regEx));
296 CPPUNIT_ASSERT(std::regex_match(result, regEx));
300 position = result.find(
"[*]");
301 if (std::string::npos != position)
303 result.replace(position, 3,
"[1]");
304 position = result.find(
"*");
305 if (std::string::npos != position)
307 result.replace(position, 1,
"ConcreteNode2");
308 CPPUNIT_ASSERT(std::regex_match(result, regEx));
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyName(const PropertyKeyPath &tagPath)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
PathIndexType GetSize() const
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
PropertyKeyPath & AddElement(const ElementNameType &name)
const NodeInfo & GetNode(const PathIndexType &index) const
PropertyKeyPath & AddSelection(const ElementNameType &name, ItemSelectionIndex index)
NodeInfo & GetFirstNode()
Test fixture for parameterized tests.
MITKCORE_EXPORT PropertyKeyPath PropertyNameToPropertyKeyPath(const std::string &propertyName)
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceNameTemplate(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyTemplate(const PropertyKeyPath &tagPath)
PropertyKeyPath & AddAnyElement()
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyRegEx(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyRegEx(const PropertyKeyPath &tagPath)
PropertyKeyPath & AddAnySelection(const ElementNameType &name)