Medical Imaging Interaction Toolkit  2018.4.99-dfa0c14e
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 (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 "mitkPropertyNameHelper.h"
14 #include "mitkStringProperty.h"
15 #include "mitkTestFixture.h"
16 #include "mitkTestingMacros.h"
17 
18 #include <limits>
19 
20 class mitkPropertyNameHelperTestSuite : public mitk::TestFixture
21 {
22  CPPUNIT_TEST_SUITE(mitkPropertyNameHelperTestSuite);
23  // Test the append method
27 
28  CPPUNIT_TEST_SUITE_END();
29 
30 private:
32  std::string oldStudyName;
33  std::string oldSeriesName;
34 
35 public:
36  void setUp() override
37  {
38  _propList = mitk::PropertyList::New();
39  oldSeriesName = "dicom.study.SeriesDescription";
40  oldStudyName = "dicom.study.StudyDescription";
41 
42  _propList->SetStringProperty(oldSeriesName.c_str(), "old_series");
43  _propList->SetStringProperty(mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x103e).c_str(), "new_series");
44 
45  _propList->SetStringProperty(oldStudyName.c_str(), "old_study");
46  }
47 
48  void tearDown() override {}
50  {
51  std::string result = mitk::GeneratePropertyNameForDICOMTag(0x0018, 0x0080);
52  MITK_TEST_CONDITION_REQUIRED(result == "DICOM.0018.0080",
53  "Testing GeneratePropertyNameForDICOMTag(mitk::DICOMTag(0x0018, 0x0080)");
54 
55  result = mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x001a);
56  MITK_TEST_CONDITION_REQUIRED(result == "DICOM.0008.001A",
57  "Testing GeneratePropertyNameForDICOMTag(mitk::DICOMTag(0x0008, 0x001a)");
58  }
59 
61  {
62  std::string result = "";
63  bool check = mitk::GetBackwardsCompatibleDICOMProperty(0x0008, 0x1030, oldStudyName, _propList, result);
64  CPPUNIT_ASSERT_MESSAGE("Testing GetBackwardsCompatibleDICOMProperty. Only deprecated name is existing.", check);
65  CPPUNIT_ASSERT_MESSAGE("Testing returned property value. Only deprecated name is existing.", result == "old_study");
66 
67  check = mitk::GetBackwardsCompatibleDICOMProperty(0x0008, 0x103e, oldSeriesName, _propList, result);
68  CPPUNIT_ASSERT_MESSAGE("Testing GetBackwardsCompatibleDICOMProperty. Only deprecated name does not exist.", check);
69  CPPUNIT_ASSERT_MESSAGE("Testing returned property value. Only deprecated name is existing.",
70  result == "new_series");
71 
72  check = mitk::GetBackwardsCompatibleDICOMProperty(0x0001, 0x0001, "unkown_old_name", _propList, result);
73  CPPUNIT_ASSERT_MESSAGE("Testing GetBackwardsCompatibleDICOMProperty. Only deprecated name does not exist.", !check);
74  }
75 
77 };
78 
79 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 MITKDICOM_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)