Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/mock-mbed-digitalout' into develop
Browse files Browse the repository at this point in the history
* ladislas/feature/mock-mbed-digitalout:
  🤡 (mbed): Mock mbed::interface::DigitalOut
  🔧 (mbed): Add EXPERIMENTAL_API to target's features
  • Loading branch information
ladislas committed May 31, 2021
2 parents 4552ace + 395a1b9 commit 833b0e3
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"sd.SPI_MISO": "SD_SPI_MISO",
"sd.SPI_MOSI": "SD_SPI_MOSI",
"sd.SPI_CLK": "SD_SPI_SCK",
"target.printf_lib": "std"
"target.printf_lib": "std",
"target.features_add": [
"EXPERIMENTAL_API"
]
},
"LEKA_DISCO": {
"target_name": "\"LEKA_DISCO\""
Expand Down
1 change: 1 addition & 0 deletions tests/unit/mbed-os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_library(mbed-os INTERFACE)
target_include_directories(mbed-os
INTERFACE
${UNITTESTS_DIR}/mbed-os
${UNITTESTS_DIR}/mbed-os/mocks
${UNITTESTS_DIR}/mbed-os/stubs
${UNITTESTS_DIR}/mbed-os/include

Expand Down
1 change: 1 addition & 0 deletions tests/unit/mbed-os/include/mbed_target_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@
#define __CORTEX_M7 1
#define __FPU_PRESENT 1
#define __MBED_CMSIS_RTOS_CM 1
#define FEATURE_EXPERIMENTAL_API 1
26 changes: 26 additions & 0 deletions tests/unit/mbed-os/mocks/mock_DigitalOut.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Leka - LekaOS
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#ifndef _LEKA_OS_MBED_MOCK_DIGITAL_OUT_H_
#define _LEKA_OS_MBED_MOCK_DIGITAL_OUT_H_

#include "PinNames.h"

#include "drivers/interfaces/InterfaceDigitalOut.h"

#include "gmock/gmock.h"

namespace mbed::mock {

class DigitalOut : public mbed::interface::DigitalOut
{
public:
MOCK_METHOD(void, write, (int value), (override));
MOCK_METHOD(int, read, (), (override));
MOCK_METHOD(int, is_connected, (), (override));
};

} // namespace mbed::mock

#endif // _LEKA_OS_MBED_MOCK_DIGITAL_OUT_H_
10 changes: 10 additions & 0 deletions tests/unit/mbed-os/stubs/stub_gpio_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ void gpio_write(gpio_t *gpio, int value)
{
return;
}

auto gpio_read(gpio_t *obj) -> int
{
return 0;
}

auto gpio_is_connected(const gpio_t *obj) -> int
{
return 1;
}

0 comments on commit 833b0e3

Please sign in to comment.