23 template <
typename DATA>
24 struct assertion_traits<
std::vector<DATA>>
26 static bool equal(
const std::vector<DATA> &x,
const std::vector<DATA> &y) {
return x == y; }
27 static std::string toString(
const std::vector<DATA> &values)
31 ost <<
"'" << v <<
"' ";
39 template <
typename DATA>
40 struct assertion_traits<
mitk::VectorProperty<DATA>>
57 CPPUNIT_TEST_SUITE(mitkVectorPropertyTestSuite);
62 CPPUNIT_TEST_SUITE_END();
74 void tearDown()
override 76 m_DoubleData =
nullptr;
83 std::vector<T> MakeSimpleList()
98 std::vector<T> data = MakeSimpleList<T>();
101 std::vector<T> stored = prop.
GetValue();
103 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Result of GetValue() should equal parameter of SetValue(data)", data, stored);
108 TestSetGet(*m_DoubleData);
109 TestSetGet(*m_IntData);
113 template <
typename T>
116 std::vector<T> data = MakeSimpleList<T>();
119 std::vector<T> modifiedData(data);
120 modifiedData.back() = -modifiedData.back();
122 modifiedProperty->SetValue(modifiedData);
124 CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE(
"Modified list shall be recognized by IsEqual()",
125 CPPUNIT_ASSERT_EQUAL(*modifiedProperty, prop));
127 modifiedData.pop_back();
128 modifiedProperty->SetValue(modifiedData);
129 CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE(
"Removed element shall be recognized by IsEqual()",
130 CPPUNIT_ASSERT_EQUAL(*modifiedProperty, prop));
135 TestIsEqual(*m_DoubleData);
136 TestIsEqual(*m_IntData);
140 template <
typename T>
143 std::vector<T> data = MakeSimpleList<T>();
147 CPPUNIT_ASSERT(clone.IsNotNull());
148 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Result of Clone() shall equal original property", *clone, prop);
150 std::vector<T> origData = prop.
GetValue();
151 std::vector<T> cloneData = clone->GetValue();
153 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Clone shall have a copy of original data", cloneData, origData);
158 TestClone(*m_DoubleData);
159 TestClone(*m_IntData);
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
virtual void SetValue(const VectorType ¶meter_vector)
sets the content vector
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
DataCollection - Class to facilitate loading/accessing structured data.
std::string GetValueAsString() const override
virtual const VectorType & GetValue() const
returns a const reference to the contained vector
static void clone(T *&dst, S *src, int n)
Test fixture for parameterized tests.
Providing a std::vector as property.