Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkRTPlanReaderTest.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 "mitkTestingMacros.h"
14 #include "mitkTestFixture.h"
15 
16 #include "mitkRTPlanReader.h"
17 #include "mitkImage.h"
19 #include "mitkBaseProperty.h"
20 
21 class mitkRTPlanReaderTestSuite : public mitk::TestFixture
22 {
23  CPPUNIT_TEST_SUITE(mitkRTPlanReaderTestSuite);
24  MITK_TEST(TestProperties);
25  CPPUNIT_TEST_SUITE_END();
26 
27 private:
29 
30 public:
31 
32  void setUp() override
33  {
34  auto rtPlanReader = mitk::RTPlanReader();
35  rtPlanReader.SetInput(GetTestDataFilePath("RT/Plan/rtplan.dcm"));
36  auto readerOutput = rtPlanReader.Read();
37  CPPUNIT_ASSERT_EQUAL_MESSAGE("reader output should have one entry.", static_cast<unsigned int>(1), static_cast<unsigned int>(readerOutput.size()));
38 
39  m_image = dynamic_cast<mitk::Image*>(readerOutput.at(0).GetPointer());
40  CPPUNIT_ASSERT_EQUAL(m_image.IsNotNull(), true);
41  }
42 
43  void TestProperties()
44  {
45  CheckStringProperty("DICOM.300A.0010.[0].300A.0013", "1.2.246.352.72.11.320687012.17740.20090508173031");
46  CheckStringProperty("DICOM.300A.0010.[1].300A.0013", "1.2.246.352.72.11.320687012.17741.20090508173031");
47  CheckStringProperty("DICOM.300A.0010.[0].300A.0016", "Breast");
48  CheckStringProperty("DICOM.300A.0010.[1].300A.0016", "CALC POINT");
49  CheckStringProperty("DICOM.300A.0010.[0].300A.0026", "14");
50  CheckStringProperty("DICOM.300A.0010.[1].300A.0026", "11.3113869239676");
51 
52  CheckStringProperty("DICOM.300A.0070.[0].300A.0078", "7");
53  CheckStringProperty("DICOM.300A.0070.[0].300A.0080", "4");
54 
55  CheckStringProperty("DICOM.300A.00B0.[0].300A.00C6", "PHOTON");
56  CheckStringProperty("DICOM.300A.00B0.[1].300A.00C6", "PHOTON");
57  CheckStringProperty("DICOM.300A.00B0.[2].300A.00C6", "PHOTON");
58  CheckStringProperty("DICOM.300A.00B0.[3].300A.00C6", "PHOTON");
59 
60  CheckStringProperty("DICOM.300C.0060.[0].0008.1155", "1.2.246.352.71.4.320687012.3190.20090511122144");
61  }
62 
63  void CheckStringProperty(std::string propertyName, std::string expectedPropertyValue)
64  {
65  auto actualProperty = m_image->GetProperty(propertyName.c_str());
66  CPPUNIT_ASSERT_EQUAL_MESSAGE("Property not found: " + propertyName, actualProperty.IsNotNull(), true);
67  auto actualTemporoSpatialStringProperty = dynamic_cast<mitk::TemporoSpatialStringProperty*>(actualProperty.GetPointer());
68  CPPUNIT_ASSERT_EQUAL_MESSAGE("Property has not type string: " + propertyName, actualTemporoSpatialStringProperty != nullptr, true);
69  std::string actualStringProperty = actualTemporoSpatialStringProperty->GetValue();
70  CPPUNIT_ASSERT_EQUAL_MESSAGE(propertyName + " is not as expected", actualStringProperty, expectedPropertyValue);
71  }
72 
73 
74 };
75 
76 MITK_TEST_SUITE_REGISTRATION(mitkRTPlanReader)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static std::string GetTestDataFilePath(const std::string &testData)
Get the absolute path for test data.
Image class for storing images.
Definition: mitkImage.h:72
Test fixture for parameterized tests.
Property for time and space resolved string values.