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