RTXI  2.4
The Real-Time eXperiment Interface Documentation
core_plugins_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 <typeinfo>
21 #include <numeric>
22 #include <cmath>
23 #include <core_plugins_tests.h>
24 
26 {
27  // TODO: decouple PerformanceMeasurement::Plugin loading from QT gui framework
28 
29  Plugin::Object *testobj = new Plugin::Object();
30  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
31  delete testobj;
32 }
33 
35 {
36  // TODO: decouple PerformanceMeasurement::Plugin class from qt gui framework.
37  // TODO: change PerformanceMeasurement::Plugin::getInstance function to virutal for late linkage
38  //auto testplugin = reinterpret_cast<PerformanceMeasurement::Plugin *>(plugin);
39  //ASSERT_EQ(testplugin, PerformanceMeasurement::Plugin::getInstance());
40  //ASSERT_EQ(testplugin, testplugin->getInstance());
41 }
42 
44 {
45  ASSERT_EQ(statobj->numValues(), 0);
46 }
47 
49 {
50  for(int i=0; i<5; ++i)
51  {
52  statobj->push(i);
53  ASSERT_EQ(statobj->numValues(), i+1);
54  }
55 }
56 
58 {
59  for(auto iter=randnums.begin(); iter!=randnums.end(); ++iter)
60  statobj->push(*iter);
61  double init=0.0;
62  ASSERT_DOUBLE_EQ(std::accumulate(randnums.begin(), randnums.end(), init)/100.0, statobj->mean());
63 }
64 
66 {
67  double squares = 0.0;
68  double init = 0.0;
69  double mean = std::accumulate(randnums.begin(), randnums.end(), init)/100.0;
70  for(auto iter=randnums.begin(); iter!=randnums.end(); ++iter)
71  {
72  statobj->push(*iter);
73  squares += pow(*iter - mean, 2);
74  }
75  ASSERT_DOUBLE_EQ(squares/(100.0), statobj->var());
76 }
77 
79 {
80  double squares = 0.0;
81  double init = 0.0;
82  double mean = std::accumulate(randnums.begin(), randnums.end(), init)/100.0;
83  for(auto iter=randnums.begin(); iter!=randnums.end(); ++iter)
84  {
85  statobj->push(*iter);
86  squares += pow(*iter - mean, 2);
87  }
88  ASSERT_DOUBLE_EQ(sqrt(squares/100.0), statobj->std());
89 }
90 
92 {
93  for(auto iter=randnums.begin(); iter!=randnums.end(); ++iter)
94  {
95  statobj->push(*iter);
96  }
97  ASSERT_EQ(100, statobj->numValues());
98  statobj->clear();
99  ASSERT_EQ(0, statobj->numValues());
100 }
101 
103 {
104  // TODO: decouple plugin loading from QT gui framework for unit testing
105 
106  Plugin::Object *testobj = new Plugin::Object();
107  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
108  delete testobj;
109 }
110 
112 {
113  // TODO: decouple getInstance function from QT gui framework for unit testing
114  // TODO: change Connector::Plugin::getInstance to virtual for late linkage
115 }
116 
118 {
119  // TODO: decouple plugin loading from QT gui framework for unit testing
120 
121  Plugin::Object *testobj = new Plugin::Object();
122  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
123  delete testobj;
124 }
125 
127 {
128  // TODO: decouple plugin loading from QT gui framework for unit testing
129 
130  Plugin::Object *testobj = new Plugin::Object();
131  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
132  delete testobj;
133 }
134 
136 {
137  // TODO: decouple plugin loading from QT gui framework for unit testing
138 
139  Plugin::Object *testobj = new Plugin::Object();
140  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
141  delete testobj;
142 }
143 
145 {
146  // TODO: decouple plugin loading from QT gui framework for unit testing
147 
148  Plugin::Object *testobj = new Plugin::Object();
149  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
150  delete testobj;
151 }
152 
154 {
155  // TODO: decouple plugin loading from QT gui framework for unit testing
156 
157  Plugin::Object *testobj = new Plugin::Object();
158  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
159  delete testobj;
160 }
161 
163 {
164  // TODO: decouple plugin loading from QT gui framework for unit testing
165 
166  Plugin::Object *testobj = new Plugin::Object();
167  ASSERT_EQ(typeid(plugin).name(), typeid(testobj).name());
168  delete testobj;
169 }
170 
171 
RunningStatTests
Definition: core_plugins_tests.h:45
PerformanceMeasurementPluginTests
Definition: core_plugins_tests.h:30
TEST_F
TEST_F(PerformanceMeasurementPluginTests, pluginLoad)
Definition: core_plugins_tests.cpp:25
UserPreferencesPluginTests
Definition: core_plugins_tests.h:160
Plugin::Object
Definition: plugin.h:145
core_plugins_tests.h
ModuleInstallerPluginTests
Definition: core_plugins_tests.h:112
ConnectorPluginTests
Definition: core_plugins_tests.h:64
OscilloscopePluginTests
Definition: core_plugins_tests.h:128
SystemControlPluginTests
Definition: core_plugins_tests.h:144
ModelLoaderPluginTests
Definition: core_plugins_tests.h:95
DataRecorderPluginTests
Definition: core_plugins_tests.h:79