Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkActionTest.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 <mitkAction.h>
14 #include <mitkProperties.h>
15 
16 #include <fstream>
17 int mitkActionTest(int /*argc*/, char * /*argv*/ [])
18 {
19  int actionId = 10;
20  // Create Action
21  mitk::Action::Pointer action = mitk::Action::New(actionId);
22 
23  // check ActionID
24  std::cout << "check ActionId";
25  if (action->GetActionId() != actionId)
26  {
27  std::cout << "[FAILED]" << std::endl;
28  return EXIT_FAILURE;
29  }
30  std::cout << "[PASSED]" << std::endl;
31 
32  // check properties
33  action->AddProperty("boolproperty", mitk::BoolProperty::New(true));
34  action->AddProperty("intproperty", mitk::IntProperty::New(10));
35  action->AddProperty("floatproperty", mitk::FloatProperty::New(10.05));
36 
37  std::cout << "try adding property BOOL and read them: ";
38  bool boolproperty = dynamic_cast<mitk::BoolProperty *>(action->GetProperty("boolproperty"))->GetValue();
39  if (boolproperty != true)
40  {
41  std::cout << "[FAILED]" << std::endl;
42  return EXIT_FAILURE;
43  }
44  std::cout << "[PASSED]" << std::endl;
45 
46  std::cout << "try adding property INT and read them: ";
47  int intproperty = 0;
48  intproperty = dynamic_cast<mitk::IntProperty *>(action->GetProperty("intproperty"))->GetValue();
49  if (intproperty != 10)
50  {
51  std::cout << "[FAILED]" << std::endl;
52  return EXIT_FAILURE;
53  }
54  std::cout << "[PASSED]" << std::endl;
55 
56  std::cout << "try adding property FLOAT and read them: ";
57  float floatproperty = dynamic_cast<mitk::FloatProperty *>(action->GetProperty("floatproperty"))->GetValue();
58  if (floatproperty != 10.05f)
59  {
60  std::cout << "[FAILED]" << std::endl;
61  return EXIT_FAILURE;
62  }
63  std::cout << "[PASSED]" << std::endl;
64 
65  // delete the action
66  // action->Delete();
67 
68  // well done!!! Passed!
69  std::cout << "[EVERYTHING PASSED]" << std::endl;
70 
71  std::cout << "[TEST DONE]" << std::endl;
72  return EXIT_SUCCESS;
73 }
int mitkActionTest(int, char *[])
static Pointer New(int _arg)
static New method to use SmartPointer
Definition: mitkAction.h:35
static Pointer New()
static Pointer New()
static Pointer New()