RTXI  2.4
The Real-Time eXperiment Interface Documentation
settings_tests.cpp
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  */
19 
20 #include <settings_tests.h>
21 #include <typeinfo>
22 
24 {
25  object = new Settings::Object();
26  Settings::Object *objectList = new Settings::Object[5];
27  for(int i = 0; i < 5; ++i)
28  {
29  ASSERT_EQ(object->getID(), object->getID());
30  ASSERT_EQ(objectList[i].getID(), objectList[i].getID());
31  ASSERT_NE(object->getID(), objectList[i].getID());
32  }
33 }
34 
36 {
37  // the Save Object is defined inside the Settings class, and without it being
38  // exposed to the user it doesn't make sense to test too much of it.
39  // TODO: Perhaps move the save object to a public namespace? If so test and document it
40  object = new Settings::Object();
41  auto saveObject = object->save();
42  ASSERT_EQ(typeid(saveObject), typeid(Settings::Object::State));
43 }
44 
46 {
47  // Unfortunately the Settings::Object class is tightly coupled with Settings::Manager, which
48  // means that it is not possible (in my view) to test these two classes individually without
49  // changing the classes.
50  // TODO: Uncouple Settings::Object and Settings::Manager (remove friend keyword, build messages,
51  // etc.)
52 
53  // // Define default values to save in settings state
54  // double testdouble = 100.0;
55  // std::string teststring = "teststring";
56  // int testint = 100;
57 
58  // // Test the save and load of state information
59  // object = new Settings::Object();
60  // auto state = object->save();
61  // state.saveDouble("testdouble", testdouble);
62  // state.saveInteger("testinteger", testint);
63  // state.saveString("teststring", teststring);
64  // object->load(state);
65  // auto retstate = object->save();
66  // EXPECT_DOUBLE_EQ(retstate.loadDouble("testdouble"), testdouble);
67  // EXPECT_EQ(retstate.loadInteger("testinteger"), testint);
68  // EXPECT_EQ(retstate.loadString("string"), teststring);
69 }
70 
72 {
73  // NOTE: See the load test for SettingsObjectTest
74 }
75 
77 {
79  ASSERT_EQ(manager, Settings::Manager::getInstance());
80  ASSERT_EQ(manager, manager->getInstance());
81 }
82 
84 {
86  // Objects are automatically registered to manager on creation
87  MockSettingsObject *objectList = new MockSettingsObject[5];
88  for(int i = 0; i < 5; ++i)
89  {
90  ASSERT_EQ(objectList[i].getID(), manager->getObject(objectList[i].getID())->getID());
91  }
92  delete[] objectList;
93 }
94 
96 {
97  // TODO: Should test this with mock plugins
98 }
99 
101 {
102  // TODO: should test this with mock plugins
103 }
104 
106 {
107  // TODO: should test this with settings plugin
108 }
109 
Settings::Manager::getInstance
static Manager * getInstance(void)
Definition: settings.cpp:534
SettingsManagerTest
Definition: settings_tests.h:27
SettingsObjectTest
Definition: settings_tests.h:36
TEST_F
TEST_F(SettingsObjectTest, getID)
Definition: settings_tests.cpp:23
Settings::Object
Definition: settings.h:43
Settings::Object::State
Definition: settings.h:62
MockSettingsObject
Definition: settings_tests.h:45
Settings::Object::getID
ID getID(void) const
Definition: settings.h:131
settings_tests.h