RTXI  2.4
The Real-Time eXperiment Interface Documentation
workspace_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 <workspace_tests.h>
21 
23 {
24  for(int i = 0; i < 6; ++i)
25  {
26  ASSERT_EQ(instance->getCount(flagsList[i]), 1);
27  }
28  ASSERT_EQ(instance->getCount(flagsList[5]<<1), 0);
29 }
30 
32 {
33  ASSERT_EQ(instance->getName(Workspace::INPUT, (size_t) 0), defaultInputChannelName);
34  ASSERT_EQ(instance->getName(Workspace::OUTPUT, (size_t) 0), defaultOutputChannelName);
35  ASSERT_EQ(instance->getName(Workspace::PARAMETER, (size_t) 0), defaultParameterChannelName);
36  ASSERT_EQ(instance->getName(Workspace::STATE, (size_t) 0), defaultStateChannelName);
37  ASSERT_EQ(instance->getName(Workspace::EVENT, (size_t) 0), defaultEventChannelName);
38  ASSERT_EQ(instance->getName(Workspace::COMMENT, (size_t) 0), defaultCommentChannelName);
39 }
40 
41 TEST_F(WorkspaceInstanceTest, getDescription)
42 {
43  ASSERT_EQ(instance->getDescription(Workspace::PARAMETER, (size_t) 0), defaultParameterChannelDescription);
44  ASSERT_EQ(instance->getDescription(Workspace::STATE, (size_t) 0), defaultStateChannelDescription);
45  ASSERT_EQ(instance->getDescription(Workspace::EVENT, (size_t) 0), defaultEventChannelDescription);
46 }
47 
49 {
50  EXPECT_NEAR(instance->getValue(Workspace::EVENT, (size_t) 0), 0.0, 0.001);
51  EXPECT_NEAR(instance->getValue(Workspace::PARAMETER, (size_t) 0), 0.0, 0.001);
52  EXPECT_NEAR(instance->getValue(Workspace::STATE, (size_t) 0), 0.0, 0.001);
53 }
54 
56 {
57  double temp = 10.0;
58  ASSERT_DOUBLE_EQ(instance->getValue(Workspace::PARAMETER, (size_t) 0), 0.0);
59  for(int i = 0; i < 3; ++i)
60  {
61  instance->setValue(0, temp*i);
62  ASSERT_DOUBLE_EQ(instance->getValue(Workspace::PARAMETER, (size_t) 0), temp*i);
63  }
64 }
65 
66 TEST_F(WorkspaceInstanceTest, getValueString)
67 {
68  ASSERT_EQ(instance->getValueString(Workspace::EVENT, (size_t) 0), "");
69  // getValueString function can sometimes give nonzero, alebeit extemely low, values. This
70  // following line can sometimes but not always fail. Not worth testing.
71  //ASSERT_EQ(instance->getValueString(Workspace::PARAMETER, (size_t) 0), std::to_string(0));
72  ASSERT_EQ(instance->getValueString(Workspace::STATE, (size_t) 0), "");
73 }
74 
76 {
77  instance->setComment((size_t) 0, "test");
78  ASSERT_EQ(instance->getValueString(Workspace::COMMENT, (size_t) 0), "test");
79 }
80 
82 {
84  ASSERT_EQ(manager, Workspace::Manager::getInstance());
85  ASSERT_EQ(manager, manager->getInstance());
86 }
87 
88 // This function is never used. Test creation delayed until completion of other tasks.
89 // TODO: Create tests for foreachWorkspace function
90 TEST_F(WorkspaceManagerTest, foreachWorkspace)
91 {
92 }
TEST_F
TEST_F(WorkspaceInstanceTest, getCount)
Definition: workspace_tests.cpp:22
workspace_tests.h
WorkspaceInstanceTest
Definition: workspace_tests.h:27
Workspace::Manager::getInstance
static Manager * getInstance(void)
Definition: workspace.cpp:323
WorkspaceManagerTest
Definition: workspace_tests.h:95