Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPropertyNameHelperTest.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 "mitkPropertyNameHelper.h"
18 #include "mitkStringProperty.h"
19 #include "mitkTestFixture.h"
20 #include "mitkTestingMacros.h"
21 
22 #include <limits>
23 
24 class mitkPropertyNameHelperTestSuite : public mitk::TestFixture
25 {
26  CPPUNIT_TEST_SUITE(mitkPropertyNameHelperTestSuite);
27  // Test the append method
31 
32  CPPUNIT_TEST_SUITE_END();
33 
34 private:
36  std::string oldStudyName;
37  std::string oldSeriesName;
38 
39 public:
40  void setUp() override
41  {
42  _propList = mitk::PropertyList::New();
43  oldSeriesName = "dicom.study.SeriesDescription";
44  oldStudyName = "dicom.study.StudyDescription";
45 
46  _propList->SetStringProperty(oldSeriesName.c_str(), "old_series");
47  _propList->SetStringProperty(mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x103e).c_str(), "new_series");
48 
49  _propList->SetStringProperty(oldStudyName.c_str(), "old_study");
50  }
51 
52  void tearDown() override {}
54  {
55  std::string result = mitk::GeneratePropertyNameForDICOMTag(0x0018, 0x0080);
56  MITK_TEST_CONDITION_REQUIRED(result == "DICOM.0018.0080",
57  "Testing GeneratePropertyNameForDICOMTag(mitk::DICOMTag(0x0018, 0x0080)");
58 
59  result = mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x001a);
60  MITK_TEST_CONDITION_REQUIRED(result == "DICOM.0008.001A",
61  "Testing GeneratePropertyNameForDICOMTag(mitk::DICOMTag(0x0008, 0x001a)");
62  }
63 
65  {
66  std::string result = "";
67  bool check = mitk::GetBackwardsCompatibleDICOMProperty(0x0008, 0x1030, oldStudyName, _propList, result);
68  CPPUNIT_ASSERT_MESSAGE("Testing GetBackwardsCompatibleDICOMProperty. Only deprecated name is existing.", check);
69  CPPUNIT_ASSERT_MESSAGE("Testing returned property value. Only deprecated name is existing.", result == "old_study");
70 
71  check = mitk::GetBackwardsCompatibleDICOMProperty(0x0008, 0x103e, oldSeriesName, _propList, result);
72  CPPUNIT_ASSERT_MESSAGE("Testing GetBackwardsCompatibleDICOMProperty. Only deprecated name does not exist.", check);
73  CPPUNIT_ASSERT_MESSAGE("Testing returned property value. Only deprecated name is existing.",
74  result == "new_series");
75 
76  check = mitk::GetBackwardsCompatibleDICOMProperty(0x0001, 0x0001, "unkown_old_name", _propList, result);
77  CPPUNIT_ASSERT_MESSAGE("Testing GetBackwardsCompatibleDICOMProperty. Only deprecated name does not exist.", !check);
78  }
79 
81 };
82 
83 MITK_TEST_SUITE_REGISTRATION(mitkPropertyNameHelper)
static Pointer New()
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
std::string MITKCORE_EXPORT GeneratePropertyNameForDICOMTag(unsigned int group, unsigned int element)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
DICOMTagPathMapType MITKDICOMREADER_EXPORT GetDefaultDICOMTagsOfInterest()
Test fixture for parameterized tests.
bool MITKCORE_EXPORT GetBackwardsCompatibleDICOMProperty(unsigned int group, unsigned int element, std::string const &backwardsCompatiblePropertyName, PropertyList const *propertyList, std::string &propertyValue)