41 CPPUNIT_TEST_SUITE(mitkVectorPropertySerializerTestSuite);
46 CPPUNIT_TEST_SUITE_END();
49 void setUp()
override {}
50 void tearDown()
override {}
51 template <
typename DATATYPE>
55 std::vector<DATATYPE> data;
56 data.push_back(static_cast<DATATYPE>(-918273674.6172838));
58 data.push_back(static_cast<DATATYPE>(+6172838.918273674));
59 data.push_back(sqrt(2));
60 if (std::numeric_limits<DATATYPE>::has_infinity)
62 data.push_back(std::numeric_limits<DATATYPE>::infinity());
63 data.push_back(-std::numeric_limits<DATATYPE>::infinity());
68 vectorProperty->SetValue(data);
70 return vectorProperty;
75 std::string serializername = std::string(property->GetNameOfClass()) +
"Serializer";
77 std::list<itk::LightObject::Pointer> allSerializers =
78 itk::ObjectFactoryBase::CreateAllInstance(serializername.c_str());
79 CPPUNIT_ASSERT_EQUAL(
size_t(1), allSerializers.size());
83 CPPUNIT_ASSERT(serializer !=
nullptr);
87 serializer->SetProperty(property);
88 TiXmlElement *serialization(
nullptr);
91 serialization = serializer->Serialize();
96 CPPUNIT_ASSERT(serialization !=
nullptr);
101 CPPUNIT_ASSERT(restoredProperty.IsNotNull());
102 return restoredProperty;
105 template <
typename DATATYPE>
108 auto property = MakeExampleProperty<DATATYPE>();
113 CPPUNIT_ASSERT(restored_vector_property.IsNotNull());
115 auto orig_vector =
property->
GetValue();
116 auto restored_vector = restored_vector_property->GetValue();
118 CPPUNIT_ASSERT_EQUAL(orig_vector.size(), restored_vector.size());
119 for (
unsigned int i = 0; i < orig_vector.size(); ++i)
122 CPPUNIT_ASSERT_MESSAGE(std::string(
"Verifying element ") + boost::lexical_cast<std::string>(i),
127 void TestSerializeIntTypedef()
130 TestSerialize(intVectorProperty.GetPointer());
133 void TestSerializeDoubleTypedef()
136 TestSerialize(doubleVectorProperty.GetPointer());
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
virtual const VectorType & GetValue() const
returns a const reference to the contained vector
Abstract base class for properties.
Test fixture for parameterized tests.
Base class for objects that serialize BaseProperty types.
Providing a std::vector as property.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.