Skip to content

Commit

Permalink
Merge branch 'feature/17' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
suikan4github committed Oct 16, 2024
2 parents 108ebe2 + d94b61f commit e945ce8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The issue #16 changes its public member function. But it is referred internally
### Removed
### Fixed
- [Issue #11](https://github.com/suikan4github/rpp_driver/issues/11) Fails to compile in MSVC.
- [Issue #17](https://github.com/suikan4github/rpp_driver/issues/17) The mock of the GpioBasic has the wrong definition.
### Security
### Known Issue

Expand Down
4 changes: 3 additions & 1 deletion src/gpio/gpiobasic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ class GpioBasic {
};
#if __has_include(<gmock/gmock.h>)
// GCOVR_EXCL_START
class MockGpioBasic : public SdkWrapper {
class MockGpioBasic : public GpioBasic {
public:
MockGpioBasic(SdkWrapper &sdk)
: GpioBasic(sdk, 0) {}; // 0 is dummy. We don't care.
MOCK_METHOD1(SetDir, void(bool));
MOCK_METHOD1(SetInputEnabled, void(bool));
MOCK_METHOD1(Put, void(bool));
Expand Down
26 changes: 26 additions & 0 deletions test/test_mockgpiobasic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Test the MockGpioBasic class.
* Only constructor is tested.
*/

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "gpiobasic.hpp"
#include "sdkwrapper.hpp"

class MockGpioBasicTest : public ::testing::Test {
protected:
virtual void SetUp() { gpio = new rpp_driver::MockGpioBasic(sdk_); }

virtual void TearDown() { delete gpio; }

::rpp_driver::MockSdkWrapper sdk_;
::rpp_driver::MockGpioBasic *gpio;
};

/*
* In this test case, we test teh MockGpioBasic is surely able to compile.
* So, none of the other methods are tested.
*/
TEST_F(MockGpioBasicTest, constructor) {}

0 comments on commit e945ce8

Please sign in to comment.