27 return "testSerialize";
33 return result.GetPointer();
38 CPPUNIT_TEST_SUITE(mitkPropertyPersistenceInfoTestSuite);
53 CPPUNIT_TEST_SUITE_END();
57 std::string refSerialization;
59 std::string refSerialization_testFunction;
63 std::string nameRegEx;
65 std::string nameTemplate;
66 std::string keyTemplate;
71 refSerialization =
"my_shiny_test_value";
74 refSerialization_testFunction =
"testSerialize";
77 nameRegEx =
"name(\\d*)";
78 nameTemplate =
"$1_name";
79 keyRegEx =
"key(\\d*)";
80 keyTemplate =
"newkey_[$1]";
83 regexInfo->UseRegEx(nameRegEx, nameTemplate, keyRegEx, keyTemplate);
86 void tearDown()
override {}
87 void CheckDefaultInfo()
89 CPPUNIT_ASSERT_MESSAGE(
90 "Testing PropertyPersistenceInfo::ANY_MIMETYPE_NAME()",
92 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::GetName()", info->GetName() ==
"");
93 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::GetKey()", info->GetKey() ==
"");
94 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::GetMimeTypeName()",
96 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::IsRegEx()", !info->IsRegEx());
98 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::IsRegEx()", regexInfo->IsRegEx());
101 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::GetDeserializationFunction() producing a StringProperty",
102 dynamic_cast<mitk::StringProperty *>(prop.GetPointer()));
103 CPPUNIT_ASSERT_MESSAGE(
104 "Testing PropertyPersistenceInfo::GetDeserializationFunction() producing a StringProperty with correct value",
105 prop->GetValueAsString() == refSerialization);
107 std::string value = info->GetSerializationFunction()(refProp);
108 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::GetSerializationFunction()", value == refSerialization);
113 info->SetName(
"MyName");
114 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::SetKey() changed name", info->GetName() ==
"MyName");
115 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::SetKey() changed key", info->GetKey() ==
"MyName");
118 regexInfo->SetName(
"MyName");
119 CPPUNIT_ASSERT_MESSAGE(
"Testing regex reset when using SetName()", !regexInfo->IsRegEx());
124 info->SetNameAndKey(
"MyName",
"MyKey");
125 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::SetNameAndKey() changed name",
126 info->GetName() ==
"MyName");
127 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::SetNameAndKey() changed key", info->GetKey() ==
"MyKey");
130 regexInfo->SetNameAndKey(
"MyName",
"MyKey");
131 CPPUNIT_ASSERT_MESSAGE(
"Testing regex reset when using SetNameAndKey()", !regexInfo->IsRegEx());
134 void SetMimeTypeName()
136 info->SetMimeTypeName(
"newMime");
137 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::SetMimeTypeName()", info->GetMimeTypeName() ==
"newMime");
142 info->UseRegEx(nameRegEx, nameTemplate);
143 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::IsRegEx()", info->IsRegEx());
144 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed name", info->GetName() == nameRegEx);
145 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed key", info->GetKey() == nameRegEx);
146 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed name template",
147 info->GetNameTemplate() == nameTemplate);
148 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed key template",
149 info->GetKeyTemplate() == nameTemplate);
154 info->UseRegEx(nameRegEx, nameTemplate, keyRegEx, keyTemplate);
155 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::IsRegEx()", info->IsRegEx());
156 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed name", info->GetName() == nameRegEx);
157 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed key", info->GetKey() == keyRegEx);
158 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed name template",
159 info->GetNameTemplate() == nameTemplate);
160 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::UseRegEx() changed key template",
161 info->GetKeyTemplate() == keyTemplate);
167 CPPUNIT_ASSERT_MESSAGE(
"Testing IsRegEx() of \"unreg\"ed regexInfo", !newInfo->IsRegEx());
168 CPPUNIT_ASSERT_MESSAGE(
"Testing GetName() of \"unreg\"ed regexInfo", newInfo->GetName() ==
"name42");
169 CPPUNIT_ASSERT_MESSAGE(
"Testing GetKey() of \"unreg\"ed regexInfo", newInfo->GetKey() ==
"newkey_[42]");
171 newInfo = info->UnRegExByName(
"name42");
172 CPPUNIT_ASSERT_MESSAGE(
"Testing IsRegEx() of \"unreg\"ed info", !newInfo->IsRegEx());
173 CPPUNIT_ASSERT_MESSAGE(
"Testing GetName() of \"unreg\"ed info", newInfo->GetName() == info->GetName());
174 CPPUNIT_ASSERT_MESSAGE(
"Testing GetKey() of \"unreg\"ed info", newInfo->GetKey() == info->GetKey());
180 CPPUNIT_ASSERT_MESSAGE(
"Testing IsRegEx() of \"unreg\"ed regexInfo", !newInfo->IsRegEx());
181 CPPUNIT_ASSERT_MESSAGE(
"Testing GetName() of \"unreg\"ed regexInfo", newInfo->GetName() ==
"42_name");
182 CPPUNIT_ASSERT_MESSAGE(
"Testing GetKey() of \"unreg\"ed regexInfo", newInfo->GetKey() ==
"key42");
184 newInfo = info->UnRegExByKey(
"key42");
185 CPPUNIT_ASSERT_MESSAGE(
"Testing IsRegEx() of \"unreg\"ed info", !newInfo->IsRegEx());
186 CPPUNIT_ASSERT_MESSAGE(
"Testing GetName() of \"unreg\"ed info", newInfo->GetName() == info->GetName());
187 CPPUNIT_ASSERT_MESSAGE(
"Testing GetKey() of \"unreg\"ed info", newInfo->GetKey() == info->GetKey());
190 void SetDeserializationFunction()
194 CPPUNIT_ASSERT_MESSAGE(
195 "Testing PropertyPersistenceInfo::SetDeserializationFunction() producing a StringProperty with correct value",
196 prop->GetValueAsString() == refSerialization_testFunction);
199 void SetSerializationFunction()
202 std::string value = info->GetSerializationFunction()(refProp);
203 CPPUNIT_ASSERT_MESSAGE(
"Testing PropertyPersistenceInfo::SetSerializationFunction()",
204 value == refSerialization_testFunction);
210 CPPUNIT_ASSERT_MESSAGE(
"Testing serializeByGetValueAsString()", value == refSerialization);
217 CPPUNIT_ASSERT_MESSAGE(
"Testing deserializeToStringProperty() producing a StringProperty",
218 dynamic_cast<mitk::StringProperty *>(prop.GetPointer()));
219 CPPUNIT_ASSERT_MESSAGE(
"Testing deserializeToStringProperty() producing a StringProperty with correct value",
220 prop->GetValueAsString() == refSerialization);
static MimeTypeNameType ANY_MIMETYPE_NAME()
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeToStringProperty(const std::string &value)
static void info(const char *fmt,...)
Abstract base class for properties.
static std::string DEFAULT_BASE_NAME()
mitk::BaseProperty::Pointer testDeserializeFunction(const std::string &)
Test fixture for parameterized tests.
::std::string testSerializeFunction(const mitk::BaseProperty *)