Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
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 // Testing
18 #include "mitkTestFixture.h"
19 #include "mitkTestingMacros.h"
20 
21 // std includes
22 #include <string>
23 
24 // MITK includes
26 
27 // VTK includes
28 #include <vtkDebugLeaks.h>
29 
30 class mitkExampleDataStructureTestSuite : public mitk::TestFixture
31 {
32  CPPUNIT_TEST_SUITE(mitkExampleDataStructureTestSuite);
33 
34  // Test the append method
35  MITK_TEST(Append_ExampleString_AddsExampleStringToData);
36  CPPUNIT_TEST_SUITE_END();
37 
38 private:
40  std::string m_DefaultDataString;
41 
42 public:
47  void setUp() override
48  {
49  m_DefaultDataString = "This is the example data content\nAnd a second line\n";
51  m_Data->SetData(m_DefaultDataString);
52  }
53 
54  void tearDown() override
55  {
56  m_DefaultDataString = "";
57  m_Data = nullptr;
58  }
59 
60  void Append_ExampleString_AddsExampleStringToData()
61  {
62  std::string appendedString = "And a third line\n";
63  std::string wholeString = m_DefaultDataString + appendedString;
64  m_Data->AppendAString(appendedString);
65 
66  CPPUNIT_ASSERT_MESSAGE("Checking whether string was correctly appended.", m_Data->GetData() == wholeString);
67  }
68 };
69 
70 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.