iodrivers_base
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
FixtureGTest.hpp
Go to the documentation of this file.
1
#ifndef IODRIVERS_BASE_GTEST_HPP
2
#define IODRIVERS_BASE_GTEST_HPP
3
4
#include <gtest/gtest.h>
5
#include <iodrivers_base/Fixture.hpp>
6
7
#define IODRIVERS_BASE_MOCK() iodrivers_base::Fixture<fixture_driver_t>::GTestMockContext __context(this);
8
9
namespace
iodrivers_base {
10
template
<
typename
Driver>
11
class
Fixture
<
Driver
>::
GTestMockContext
12
{
13
public
:
14
Fixture
*
fixture
;
15
GTestMockContext
(
Fixture
* fixture): fixture(fixture)
16
{
17
fixture->
setMockMode
(
true
);
18
}
27
void
tearDown
()
28
{
29
try
30
{
31
fixture->validateExpectationsAreEmpty();
32
}
33
catch
(
TestEndsWithExpectationsLeftException
e)
34
{
35
ADD_FAILURE() <<
"IODRIVERS_BASE_MOCK Error: Test reached its end without satisfying all expecations."
;
36
}
37
}
38
39
~GTestMockContext
()
40
{
41
fixture->setMockMode(
false
);
42
fixture->clearExpectations();
43
tearDown();
44
}
45
46
};
47
}
48
49
#endif
iodrivers_base::Fixture::GTestMockContext::fixture
Fixture * fixture
Definition:
FixtureGTest.hpp:14
iodrivers_base::Fixture::GTestMockContext::GTestMockContext
GTestMockContext(Fixture *fixture)
Definition:
FixtureGTest.hpp:15
iodrivers_base::Driver
Definition:
Driver.hpp:69
iodrivers_base::Fixture::setMockMode
void setMockMode(bool mode)
Definition:
Fixture.hpp:182
iodrivers_base::Fixture::GTestMockContext::~GTestMockContext
~GTestMockContext()
Definition:
FixtureGTest.hpp:39
iodrivers_base::Fixture
Definition:
Fixture.hpp:76
iodrivers_base::Fixture::GTestMockContext::tearDown
void tearDown()
Definition:
FixtureGTest.hpp:27
iodrivers_base::Fixture::GTestMockContext
Definition:
FixtureGTest.hpp:11
TestEndsWithExpectationsLeftException
Definition:
Exceptions.hpp:44
Generated on Tue Oct 9 2018 10:56:16 for iodrivers_base by
1.8.6