Skip to content

Commit 689e06f

Browse files
committed
Issue #17 : The mock of the GpioBasic has the wrong definition.
The MOckGpioBasic had wrong definition. It was inheriting the SdkWrapper incorrectly. This was fixed. To confirm this fix is Ok, we added new test case MockGpioBasicTest.constructor. This Test case is correctly compiled and run.
1 parent 108ebe2 commit 689e06f

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/gpio/gpiobasic.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ class GpioBasic {
101101
};
102102
#if __has_include(<gmock/gmock.h>)
103103
// GCOVR_EXCL_START
104-
class MockGpioBasic : public SdkWrapper {
104+
class MockGpioBasic : public GpioBasic {
105105
public:
106+
MockGpioBasic(SdkWrapper &sdk)
107+
: GpioBasic(sdk, 0) {}; // 0 is dummy. We don't care.
106108
MOCK_METHOD1(SetDir, void(bool));
107109
MOCK_METHOD1(SetInputEnabled, void(bool));
108110
MOCK_METHOD1(Put, void(bool));

test/test_mockgpiobasic.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Test the MockGpioBasic class.
3+
* Only constructor is tested.
4+
*/
5+
6+
#include <gmock/gmock.h>
7+
#include <gtest/gtest.h>
8+
9+
#include "gpiobasic.hpp"
10+
#include "sdkwrapper.hpp"
11+
12+
class MockGpioBasicTest : public ::testing::Test {
13+
protected:
14+
virtual void SetUp() { gpio = new rpp_driver::MockGpioBasic(sdk_); }
15+
16+
virtual void TearDown() { delete gpio; }
17+
18+
::rpp_driver::MockSdkWrapper sdk_;
19+
::rpp_driver::MockGpioBasic *gpio;
20+
};
21+
22+
/*
23+
* In this test case, we test teh MockGpioBasic is surely able to compile.
24+
* So, none of the other methods are tested.
25+
*/
26+
TEST_F(MockGpioBasicTest, constructor) {}

0 commit comments

Comments
 (0)