Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkPointSetEqualTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkPointSet.h"
14 #include "mitkTestFixture.h"
15 #include "mitkTestingMacros.h"
16 
21 class mitkPointSetEqualTestSuite : public mitk::TestFixture
22 {
23  CPPUNIT_TEST_SUITE(mitkPointSetEqualTestSuite);
24  MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue);
25  MITK_TEST(Equal_DifferentGeometries_ReturnsFalse);
26  MITK_TEST(Equal_DifferentNumberOfPoints_ReturnsFalse);
27  MITK_TEST(Equal_DifferentPoints_ReturnsFalse);
28  CPPUNIT_TEST_SUITE_END();
29 
30 private:
32  mitk::PointSet::Pointer m_PointSet;
33  mitk::PointSet::Pointer m_AnotherPointSet;
34 
35 public:
40  void setUp() override
41  {
42  m_PointSet = mitk::PointSet::New();
43  m_AnotherPointSet = m_PointSet->Clone();
44  }
45 
46  void tearDown() override
47  {
48  m_PointSet = nullptr;
49  m_AnotherPointSet = nullptr;
50  }
51 
52  void Equal_CloneAndOriginal_ReturnsTrue()
53  {
55  MITK_ASSERT_EQUAL(newPointSet, newPointSet->Clone(), "A clone should be equal to its original.");
56  }
57 
58  void Equal_DifferentGeometries_ReturnsFalse()
59  {
60  mitk::Point3D origin;
61  origin[0] = 0.0;
62  origin[1] = 0.0;
63  origin[2] = 1.0 + 2 * mitk::eps;
64  m_AnotherPointSet->GetGeometry()->SetOrigin(origin);
65 
66  MITK_ASSERT_NOT_EQUAL(m_PointSet, m_AnotherPointSet, "Origin was modified. Result should be false.");
67  }
68 
69  void Equal_DifferentNumberOfPoints_ReturnsFalse()
70  {
71  mitk::Point3D tmpPoint;
72  tmpPoint[0] = 1.0;
73  tmpPoint[1] = 1.0;
74  tmpPoint[2] = 1.0;
75 
76  m_PointSet->InsertPoint(1, tmpPoint);
77  m_PointSet->InsertPoint(2, tmpPoint);
78 
79  m_AnotherPointSet->InsertPoint(1, tmpPoint);
80 
82  m_PointSet, m_AnotherPointSet, "One pointset has two points the other has one. Result should be false.");
83  }
84 
85  void Equal_DifferentPoints_ReturnsFalse()
86  {
87  mitk::Point3D tmpPoint;
88  tmpPoint[0] = 1.0;
89  tmpPoint[1] = 1.0;
90  tmpPoint[2] = 1.0;
91 
92  m_PointSet->InsertPoint(1, tmpPoint);
93 
94  tmpPoint[0] = 1.0 + 2 * mitk::eps;
95  m_AnotherPointSet->InsertPoint(1, tmpPoint);
96 
98  m_PointSet, m_AnotherPointSet, "Two pointsets with different points. Result should be false.");
99  }
100 };
101 
102 MITK_TEST_SUITE_REGISTRATION(mitkPointSetEqual)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
static Pointer New()
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
#define MITK_ASSERT_NOT_EQUAL(OBJ1, OBJ2, MSG)
Testing macro to test if two objects are not equal.
Test fixture for parameterized tests.
#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG)
Testing macro to test if two objects are equal.
MITKCORE_EXPORT const ScalarType eps