Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkPointSet.h"
18 #include "mitkTestFixture.h"
19 #include "mitkTestingMacros.h"
20 
25 class mitkPointSetEqualTestSuite : public mitk::TestFixture
26 {
27  CPPUNIT_TEST_SUITE(mitkPointSetEqualTestSuite);
28  MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue);
29  MITK_TEST(Equal_DifferentGeometries_ReturnsFalse);
30  MITK_TEST(Equal_DifferentNumberOfPoints_ReturnsFalse);
31  MITK_TEST(Equal_DifferentPoints_ReturnsFalse);
32  CPPUNIT_TEST_SUITE_END();
33 
34 private:
36  mitk::PointSet::Pointer m_PointSet;
37  mitk::PointSet::Pointer m_AnotherPointSet;
38 
39 public:
44  void setUp() override
45  {
46  m_PointSet = mitk::PointSet::New();
47  m_AnotherPointSet = m_PointSet->Clone();
48  }
49 
50  void tearDown() override
51  {
52  m_PointSet = nullptr;
53  m_AnotherPointSet = nullptr;
54  }
55 
56  void Equal_CloneAndOriginal_ReturnsTrue()
57  {
59  MITK_ASSERT_EQUAL(newPointSet, newPointSet->Clone(), "A clone should be equal to its original.");
60  }
61 
62  void Equal_DifferentGeometries_ReturnsFalse()
63  {
64  mitk::Point3D origin;
65  origin[0] = 0.0;
66  origin[1] = 0.0;
67  origin[2] = 1.0 + 2 * mitk::eps;
68  m_AnotherPointSet->GetGeometry()->SetOrigin(origin);
69 
70  MITK_ASSERT_NOT_EQUAL(m_PointSet, m_AnotherPointSet, "Origin was modified. Result should be false.");
71  }
72 
73  void Equal_DifferentNumberOfPoints_ReturnsFalse()
74  {
75  mitk::Point3D tmpPoint;
76  tmpPoint[0] = 1.0;
77  tmpPoint[1] = 1.0;
78  tmpPoint[2] = 1.0;
79 
80  m_PointSet->InsertPoint(1, tmpPoint);
81  m_PointSet->InsertPoint(2, tmpPoint);
82 
83  m_AnotherPointSet->InsertPoint(1, tmpPoint);
84 
86  m_PointSet, m_AnotherPointSet, "One pointset has two points the other has one. Result should be false.");
87  }
88 
89  void Equal_DifferentPoints_ReturnsFalse()
90  {
91  mitk::Point3D tmpPoint;
92  tmpPoint[0] = 1.0;
93  tmpPoint[1] = 1.0;
94  tmpPoint[2] = 1.0;
95 
96  m_PointSet->InsertPoint(1, tmpPoint);
97 
98  tmpPoint[0] = 1.0 + 2 * mitk::eps;
99  m_AnotherPointSet->InsertPoint(1, tmpPoint);
100 
102  m_PointSet, m_AnotherPointSet, "Two pointsets with different points. Result should be false.");
103  }
104 };
105 
106 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