Skip to content

Commit

Permalink
Removed compiler warning, format
Browse files Browse the repository at this point in the history
  • Loading branch information
aul12 committed Dec 29, 2022
1 parent 73d33b9 commit f01fb29
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 31 deletions.
135 changes: 106 additions & 29 deletions Tests/LowLevel/Application/mode_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ TEST(TEST_NAME, imu_initial_timeout) {
auto errorHandlerHandle = mock::error_handler.getHandle();

imuHandle.overrideFunc<imu_data_available>([]() { return false; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return true; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return true; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand All @@ -40,10 +49,19 @@ TEST(TEST_NAME, imu_initial_nok) {
auto errorHandlerHandle = mock::error_handler.getHandle();

imuHandle.overrideFunc<imu_data_available>([]() { return true; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = false}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = false;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return true; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return true; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand All @@ -69,10 +87,19 @@ TEST(TEST_NAME, imu_timeout) {
frameCounter += 1;
return frameCounter < 2 or frameCounter > 7;
});
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return true; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return true; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand Down Expand Up @@ -130,10 +157,19 @@ TEST(TEST_NAME, remote_initial_timeout) {
auto errorHandlerHandle = mock::error_handler.getHandle();

imuHandle.overrideFunc<imu_data_available>([]() { return true; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return false; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return true; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand All @@ -155,10 +191,19 @@ TEST(TEST_NAME, remote_initial_nok) {
auto errorHandlerHandle = mock::error_handler.getHandle();

imuHandle.overrideFunc<imu_data_available>([]() { return true; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return true; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = false}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = false;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return true; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand All @@ -181,13 +226,22 @@ TEST(TEST_NAME, remote_timeout) {

std::size_t frameCounter = 0;
imuHandle.overrideFunc<imu_data_available>([]() { return true; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([&frameCounter]() {
frameCounter += 1;
return frameCounter < 2 or frameCounter > 7;
});
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return true; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand Down Expand Up @@ -245,10 +299,19 @@ TEST(TEST_NAME, fcp_initial_timeout) {
auto errorHandlerHandle = mock::error_handler.getHandle();

imuHandle.overrideFunc<imu_data_available>([]() { return true; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return true; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([]() { return false; });
flightcomputerHandle.overrideFunc<flightcomputer_get_setpoint>([]() { return flightcomputer_setpoint_t{}; });

Expand All @@ -271,10 +334,19 @@ TEST(TEST_NAME, fcp_timeout) {

std::size_t frameCounter = 0;
imuHandle.overrideFunc<imu_data_available>([]() { return true; });
imuHandle.overrideFunc<imu_get_latest_data>([]() { return imu_data_t{.imu_ok = true}; });
imuHandle.overrideFunc<imu_get_latest_data>([]() {
imu_data_t res{};
res.imu_ok = true;
return res;
});
remoteHandle.overrideFunc<remote_data_available>([]() { return true; });
remoteHandle.overrideFunc<remote_get_data>(
[]() { return remote_data_t{.is_armed = true, .override_active = false, .remote_ok = true}; });
remoteHandle.overrideFunc<remote_get_data>([]() {
remote_data_t res{};
res.is_armed = true;
res.override_active = false;
res.remote_ok = true;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>([&frameCounter]() {
frameCounter += 1;
return frameCounter < 2 or frameCounter > 13;
Expand Down Expand Up @@ -409,12 +481,17 @@ TEST(TEST_NAME, modeselection) {

for (auto [availability_value, expected_mode] : decisionTable) {
mode_handler_init();
imuHandle.overrideFunc<imu_get_latest_data>(
[availability_value]() { return imu_data_t{.imu_ok = availability_value.imu}; });
imuHandle.overrideFunc<imu_get_latest_data>([availability_value]() {
imu_data_t res{};
res.imu_ok = availability_value.imu;
return res;
});
remoteHandle.overrideFunc<remote_get_data>([availability_value]() {
return remote_data_t{.is_armed = availability_value.arm,
.override_active = availability_value.override,
.remote_ok = availability_value.remote};
remote_data_t res{};
res.is_armed = availability_value.arm;
res.override_active = availability_value.override;
res.remote_ok = availability_value.remote;
return res;
});
flightcomputerHandle.overrideFunc<flightcomputer_setpoint_available>(
[availability_value]() { return availability_value.fcp; });
Expand Down
4 changes: 2 additions & 2 deletions Tests/LowLevel/Drivers/sbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ TEST(TEST_NAME, decode_framelost) {
});
uart_callback_t uartCallback = nullptr;
uartHandle.overrideFunc<uart_init>([&uartCallback](uint8_t /*id*/, uint32_t /*baud*/, uart_parity_t /*parity*/,
uint8_t /*stop_bits*/,
uart_callback_t rx_callback) { uartCallback = rx_callback; });
uint8_t /*stop_bits*/,
uart_callback_t rx_callback) { uartCallback = rx_callback; });
sbus_init();
EXPECT_TRUE(uartHandle.functionGotCalled<uart_init>());

Expand Down

0 comments on commit f01fb29

Please sign in to comment.