RTXI  2.4
The Real-Time eXperiment Interface Documentation
io_tests.h
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 #ifndef IO_TESTS_H
21 #define IO_TESTS_H
22 
23 #include <gtest/gtest.h>
24 #include <gmock/gmock.h>
25 #include <io.h>
26 #include <string>
27 #include <vector>
28 
29 class IOBlockTest : public ::testing::Test
30 {
31 public:
32  std::string defaultBlockName;
33  std::string defaultInputChannelName = "CHANNEL INPUT";
34  std::string defaultInputChannelDescription = "DEFAULT INPUT CHANNEL DESCRIPTION";
35  std::string defaultOutputChannelName = "CHANNEL OUTPUT";
36  std::string defaultOutputChannelDescription = "DEFAULT OUTPUT CHANNEL DESCRIPTION";
38 
39 protected:
41  {
42  // Generates a default block with single input and output channel
43  defaultBlockName = "DEFAULT:BLOCK:NAME";
44  IO::channel_t defaultInputChannel_t = {
47  IO::INPUT
48  };
49  IO::channel_t defaultOutputChannel_t = {
52  IO::OUTPUT
53  };
55  defaultChannelList[0] = defaultInputChannel_t;
56  defaultChannelList[1] = defaultOutputChannel_t;
58  }
60  delete block;
61  }
62 
64 };
65 
66 class MockIOBlock : public IO::Block
67 {
68 public:
69  MockIOBlock(std::string n, IO::channel_t * l, size_t c) : IO::Block(n, l, c) { }
71 
72  MOCK_METHOD(std::string, getName, (), (const));
73  MOCK_METHOD(size_t, getCount, (IO::flags_t), (const, override));
74  MOCK_METHOD(std::string, getName, (IO::flags_t, size_t), (const, override));
75  MOCK_METHOD(std::string, getDescription, (IO::flags_t, size_t), (const, override));
76  MOCK_METHOD(double, getValue, (IO::flags_t, size_t), (const, override));
77  MOCK_METHOD(double, input, (size_t), (const));
78  MOCK_METHOD(double, output, (size_t), (const));
79  void changeOutput(double val) { IO::Block::output((size_t) 0) = val; }
80 };
81 
82 class IOConnectorTest : public ::testing::Test
83 {
84 protected:
87  }
89 
92 };
93 
94 
95 #endif
MockIOBlock::MockIOBlock
MockIOBlock(std::string n, IO::channel_t *l, size_t c)
Definition: io_tests.h:69
IO::Connector
Definition: io.h:71
IO::flags_t
unsigned long flags_t
Definition: io.h:40
IO::Connector::getInstance
static Connector * getInstance(void)
Definition: io.cpp:421
MockIOBlock
Definition: io_tests.h:66
IOBlockTest::defaultOutputChannelDescription
std::string defaultOutputChannelDescription
Definition: io_tests.h:36
MockIOBlock::~MockIOBlock
~MockIOBlock()
Definition: io_tests.h:70
IO
Connection Oriented Classes.
Definition: io.h:34
IO::Block::getValue
virtual double getValue(flags_t type, size_t index) const
Definition: io.cpp:109
IO::Block::getCount
virtual size_t getCount(flags_t type) const
Definition: io.cpp:82
IOBlockTest::~IOBlockTest
~IOBlockTest()
Definition: io_tests.h:59
IOConnectorTest
Definition: io_tests.h:82
MockIOBlock::changeOutput
void changeOutput(double val)
Definition: io_tests.h:79
IOConnectorTest::IOConnectorTest
IOConnectorTest()
Definition: io_tests.h:85
IOBlockTest::defaultInputChannelDescription
std::string defaultInputChannelDescription
Definition: io_tests.h:34
IO::Block::getName
std::string getName(void) const
Definition: io.h:215
MockIOBlock::MOCK_METHOD
MOCK_METHOD(std::string, getName,(),(const))
IOBlockTest::block
IO::Block * block
Definition: io_tests.h:63
IO::Block::Block
Block(std::string name, channel_t *channels, size_t size)
Definition: io.cpp:30
IO::Block::output
double output(size_t index) const
Definition: io.cpp:129
IO::Block
Definition: io.h:188
IO::channel_t
Definition: io.h:56
IOConnectorTest::defaultChannelList
IO::channel_t * defaultChannelList
Definition: io_tests.h:90
IOBlockTest
Definition: io_tests.h:29
IO::Block::input
double input(size_t index) const
Definition: io.cpp:118
IOConnectorTest::~IOConnectorTest
~IOConnectorTest()
Definition: io_tests.h:88
IOBlockTest::defaultBlockName
std::string defaultBlockName
Definition: io_tests.h:32
IO::Block::getDescription
virtual std::string getDescription(flags_t type, size_t index) const
Definition: io.cpp:100
IOBlockTest::defaultChannelList
IO::channel_t * defaultChannelList
Definition: io_tests.h:37
io.h
IOBlockTest::IOBlockTest
IOBlockTest()
Definition: io_tests.h:40
IOConnectorTest::connector
IO::Connector * connector
Definition: io_tests.h:91
IOBlockTest::defaultOutputChannelName
std::string defaultOutputChannelName
Definition: io_tests.h:35
IOBlockTest::defaultInputChannelName
std::string defaultInputChannelName
Definition: io_tests.h:33