Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkPhotoacousticVesselMeanderStrategyTest.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 <mitkTestFixture.h>
14 #include <mitkTestingMacros.h>
15 
16 #include <mitkImageReadAccessor.h>
17 
19 #include "mitkPATissueGenerator.h"
21 
22 class mitkPhotoacousticVesselMeanderStrategyTestSuite : public mitk::TestFixture
23 {
24  CPPUNIT_TEST_SUITE(mitkPhotoacousticVesselMeanderStrategyTestSuite);
25  MITK_TEST(TestCalculateNewPositionInStraightLine);
26 
27  CPPUNIT_TEST_SUITE_END();
28 
29 private:
30  mitk::pa::VesselMeanderStrategy::Pointer m_TestStrategy;
31  mitk::pa::Vector::Pointer m_TestDirection;
32 
33 public:
34 
35  void setUp() override
36  {
37  m_TestStrategy = mitk::pa::VesselMeanderStrategy::New();
38  m_TestDirection = mitk::pa::Vector::New();
39  }
40 
41  void TestCalculateNewPositionInStraightLine()
42  {
43  int d = 3;
44  int e = 4;
45  int f = 5;
46 
47  for (int i = -2; i <= 2; i++)
48  {
49  if (i == 0)
50  {
51  i++;
52  }
53 
54  for (int j = -2; j <= 2; j++)
55  {
56  if (j == 0)
57  {
58  j++;
59  }
60 
61  m_TestDirection->SetElement(0, d*j);
62  m_TestDirection->SetElement(1, e*j);
63  m_TestDirection->SetElement(2, f*j);
64 
65  mitk::pa::Vector::Pointer directionBefore = m_TestDirection->Clone();
66  m_TestStrategy->CalculateNewDirectionVectorInStraightLine(m_TestDirection, 0, nullptr);
67  CPPUNIT_ASSERT(mitk::pa::Equal(directionBefore, m_TestDirection, 1e-6, false));
68  }
69  }
70  }
71 
72  void tearDown() override
73  {
74  m_TestStrategy = nullptr;
75  m_TestDirection = nullptr;
76  }
77 };
78 
79 MITK_TEST_SUITE_REGISTRATION(mitkPhotoacousticVesselMeanderStrategy)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
MITKPHOTOACOUSTICSLIB_EXPORT bool Equal(const MonteCarloThreadHandler::Pointer leftHandSide, const MonteCarloThreadHandler::Pointer rightHandSide, double eps, bool verbose)
Equal A function comparing two thread handlers for beeing equal.
Test fixture for parameterized tests.
static Pointer New()