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
mitkSimpleHistogramTest.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 <mitkSimpleHistogram.h>
18 #include <mitkSurface.h>
19 #include <mitkTestingMacros.h>
20 
21 int mitkSimpleHistogramTest(int /*argc*/, char * /*argv*/ [])
22 {
23  MITK_TEST_BEGIN("mitkSimpleHistogram");
24 
25  auto myTestSimpleImageHistogram = new mitk::SimpleImageHistogram();
26 
27  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram != nullptr, "Testing instanciation.");
28  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram->GetMax() == 1, "Testing GetMax().");
29  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram->GetMin() == 0, "Testing GetMin().");
30  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram->GetRelativeBin(1.0, 5.0) == 0, "Testing GetRelativeBin().");
31  bool success = true;
32  try
33  {
34  myTestSimpleImageHistogram->ComputeFromBaseData(nullptr);
35  myTestSimpleImageHistogram->ComputeFromBaseData(mitk::Image::New()); // an empty image
36  myTestSimpleImageHistogram->ComputeFromBaseData(mitk::Surface::New()); // an invalid value
37  }
38  catch (...)
39  {
40  success = false;
41  }
42  MITK_TEST_CONDITION_REQUIRED(success, "Testing ComputeFromBaseData() with invalid input values.");
43  MITK_TEST_CONDITION_REQUIRED(!myTestSimpleImageHistogram->GetValid(),
44  "Testing if histogram is invalid after invalid input.");
45 
46  MITK_TEST_END();
47 }
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
int mitkSimpleHistogramTest(int, char *[])
static Pointer New()
and MITK_TEST_END()
static Pointer New()