Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkExampleDataStructureTest.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 // Testing
14 #include "mitkTestFixture.h"
15 #include "mitkTestingMacros.h"
16 
17 // std includes
18 #include <string>
19 
20 // MITK includes
22 
23 // VTK includes
24 #include <vtkDebugLeaks.h>
25 
26 class mitkExampleDataStructureTestSuite : public mitk::TestFixture
27 {
28  CPPUNIT_TEST_SUITE(mitkExampleDataStructureTestSuite);
29 
30  // Test the append method
31  MITK_TEST(Append_ExampleString_AddsExampleStringToData);
32  CPPUNIT_TEST_SUITE_END();
33 
34 private:
36  std::string m_DefaultDataString;
37 
38 public:
43  void setUp() override
44  {
45  m_DefaultDataString = "This is the example data content\nAnd a second line\n";
47  m_Data->SetData(m_DefaultDataString);
48  }
49 
50  void tearDown() override
51  {
52  m_DefaultDataString = "";
53  m_Data = nullptr;
54  }
55 
56  void Append_ExampleString_AddsExampleStringToData()
57  {
58  std::string appendedString = "And a third line\n";
59  std::string wholeString = m_DefaultDataString + appendedString;
60  m_Data->AppendAString(appendedString);
61 
62  CPPUNIT_ASSERT_MESSAGE("Checking whether string was correctly appended.", m_Data->GetData() == wholeString);
63  }
64 };
65 
66 MITK_TEST_SUITE_REGISTRATION(mitkExampleDataStructure)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
Test fixture for parameterized tests.