Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
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 (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 <mitkSimpleHistogram.h>
14 #include <mitkSurface.h>
15 #include <mitkTestingMacros.h>
16 
17 int mitkSimpleHistogramTest(int /*argc*/, char * /*argv*/ [])
18 {
19  MITK_TEST_BEGIN("mitkSimpleHistogram");
20 
21  auto myTestSimpleImageHistogram = new mitk::SimpleImageHistogram();
22 
23  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram != nullptr, "Testing instanciation.");
24  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram->GetMax() == 1, "Testing GetMax().");
25  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram->GetMin() == 0, "Testing GetMin().");
26  MITK_TEST_CONDITION_REQUIRED(myTestSimpleImageHistogram->GetRelativeBin(1.0, 5.0) == 0, "Testing GetRelativeBin().");
27  bool success = true;
28  try
29  {
30  myTestSimpleImageHistogram->ComputeFromBaseData(nullptr);
31  myTestSimpleImageHistogram->ComputeFromBaseData(mitk::Image::New()); // an empty image
32  myTestSimpleImageHistogram->ComputeFromBaseData(mitk::Surface::New()); // an invalid value
33  }
34  catch (...)
35  {
36  success = false;
37  }
38  MITK_TEST_CONDITION_REQUIRED(success, "Testing ComputeFromBaseData() with invalid input values.");
39  MITK_TEST_CONDITION_REQUIRED(!myTestSimpleImageHistogram->GetValid(),
40  "Testing if histogram is invalid after invalid input.");
41 
42  MITK_TEST_END();
43 }
#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()