Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
aul12 committed Jan 1, 2023
1 parent 9856449 commit 81571a0
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 92 deletions.
151 changes: 74 additions & 77 deletions Tests/LowLevel/Components/imu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Mock/error_handler.hpp>
#include <Mock/bno055.hpp>
#include <Mock/delay.hpp>
#include <Mock/error_handler.hpp>
#include <gtest/gtest.h>

extern "C" {
Expand Down Expand Up @@ -45,11 +45,11 @@ TEST(TEST_NAME, init__self_test_error) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_fail);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_fail);
});

imu_init();
Expand All @@ -69,11 +69,11 @@ TEST(TEST_NAME, init__self_test_mcu_fail) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = false;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = false;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});

imu_init();
Expand All @@ -93,11 +93,11 @@ TEST(TEST_NAME, init__self_test_acc_fail) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = false;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = false;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});

imu_init();
Expand All @@ -117,11 +117,11 @@ TEST(TEST_NAME, init__self_test_gyr_fail) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = false;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = false;
out->mag_passed = true;
callback(read_success);
});

imu_init();
Expand All @@ -141,11 +141,11 @@ TEST(TEST_NAME, init__self_test_mag_fail) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = false;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = false;
callback(read_success);
});

imu_init();
Expand Down Expand Up @@ -183,11 +183,11 @@ TEST(TEST_NAME, init__unit_sel_error) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand All @@ -213,11 +213,11 @@ TEST(TEST_NAME, init__unit_sel_timeout) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});

imu_init();
Expand All @@ -239,11 +239,11 @@ TEST(TEST_NAME, init__remap_error) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand Down Expand Up @@ -273,11 +273,11 @@ TEST(TEST_NAME, init__remap_timeout) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand Down Expand Up @@ -305,11 +305,11 @@ TEST(TEST_NAME, init__remap_sign_error) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand Down Expand Up @@ -342,11 +342,11 @@ TEST(TEST_NAME, init__remap_sign_timeout) {
bnoHandle.overrideFunc<bno055_write_opr_mode>(
[](auto /*op_mode*/, bno055_callback_t callback) { callback(write_success); });
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand Down Expand Up @@ -375,18 +375,18 @@ TEST(TEST_NAME, init__ndof_error) {
auto errorHandlerHandle = mock::error_handler.getHandle();

bnoHandle.overrideFunc<bno055_write_opr_mode>([](bno055_opr_mode_t opr_mode, bno055_callback_t callback) {
if (opr_mode == ndof_fmc_off) {
callback(write_fail);
} else {
callback(write_success);
}
if (opr_mode == ndof_fmc_off) {
callback(write_fail);
} else {
callback(write_success);
}
});
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand Down Expand Up @@ -419,16 +419,16 @@ TEST(TEST_NAME, init__ndof_timeout) {
auto errorHandlerHandle = mock::error_handler.getHandle();

bnoHandle.overrideFunc<bno055_write_opr_mode>([](bno055_opr_mode_t opr_mode, bno055_callback_t callback) {
if (opr_mode != ndof_fmc_off) {
callback(write_success);
}
if (opr_mode != ndof_fmc_off) {
callback(write_success);
}
});
bnoHandle.overrideFunc<bno055_read_self_test>([](bno055_self_test_result_t *out, bno055_callback_t callback) {
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
out->mcu_passed = true;
out->acc_passed = true;
out->gyr_passed = true;
out->mag_passed = true;
callback(read_success);
});
bnoHandle.overrideFunc<bno055_write_unit_selection>(
[](bno055_unit_sel_acc /*acc_unit*/, bno055_unit_sel_angular_rate /*angular_rate_unit*/,
Expand Down Expand Up @@ -500,9 +500,6 @@ TEST(TEST_NAME, init__success) {
}





TEST(TEST_NAME, read__full_read) {
GTEST_SKIP_("Non requirement compliant workaround for non datasheet compliant sensor!");
auto bnoHandle = mock::bno055.getHandle();
Expand Down
18 changes: 5 additions & 13 deletions Tests/LowLevel/Components/system.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Mock/error_handler.hpp>
#include <Mock/timer8bit.hpp>
#include <Mock/interrupt.hpp>
#include <Mock/io.hpp>
#include <Mock/timer8bit.hpp>
#include <Mock/wdt.hpp>
#include <gtest/gtest.h>

Expand Down Expand Up @@ -78,9 +78,7 @@ TEST(TEST_NAME, timer_runtime_0) {
timer_8bit_callback_t internalCallback = nullptr;
timerHandle.overrideFunc<timer_8bit_init>(
[&internalCallback](timer_8bit_clock_option_t /*clock_option*/,
system_timer_16_384ms_callback timerCallback) {
internalCallback = timerCallback;
});
system_timer_16_384ms_callback timerCallback) { internalCallback = timerCallback; });
timerHandle.overrideFunc<timer_8bit_get_count>([]() { return 0; });

system_pre_init(timer_callback);
Expand All @@ -106,9 +104,7 @@ TEST(TEST_NAME, timer_runtime_max) {
timer_8bit_callback_t internalCallback = nullptr;
timerHandle.overrideFunc<timer_8bit_init>(
[&internalCallback](timer_8bit_clock_option_t /*clock_option*/,
system_timer_16_384ms_callback timerCallback) {
internalCallback = timerCallback;
});
system_timer_16_384ms_callback timerCallback) { internalCallback = timerCallback; });
timerHandle.overrideFunc<timer_8bit_get_count>([]() { return 255; });

system_pre_init(timer_callback);
Expand All @@ -134,9 +130,7 @@ TEST(TEST_NAME, timer_runtime_under_limit) {
timer_8bit_callback_t internalCallback = nullptr;
timerHandle.overrideFunc<timer_8bit_init>(
[&internalCallback](timer_8bit_clock_option_t /*clock_option*/,
system_timer_16_384ms_callback timerCallback) {
internalCallback = timerCallback;
});
system_timer_16_384ms_callback timerCallback) { internalCallback = timerCallback; });
// 12/16,384*255=186.767578125
timerHandle.overrideFunc<timer_8bit_get_count>([]() { return 186; });

Expand All @@ -163,9 +157,7 @@ TEST(TEST_NAME, timer_runtime_over_limit) {
timer_8bit_callback_t internalCallback = nullptr;
timerHandle.overrideFunc<timer_8bit_init>(
[&internalCallback](timer_8bit_clock_option_t /*clock_option*/,
system_timer_16_384ms_callback timerCallback) {
internalCallback = timerCallback;
});
system_timer_16_384ms_callback timerCallback) { internalCallback = timerCallback; });
// 12/16,384*255=186.767578125
timerHandle.overrideFunc<timer_8bit_get_count>([]() { return 187; });

Expand Down
4 changes: 2 additions & 2 deletions Tests/LowLevel/Drivers/protobuf.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Mock/ring_buffer.hpp>
#include <Mock/uart.hpp>
#include <Mock/MessageDecoding.hpp>
#include <Mock/MessageEncoding.hpp>
#include <Mock/ring_buffer.hpp>
#include <Mock/uart.hpp>
#include <gtest/gtest.h>
#include <queue>

Expand Down

0 comments on commit 81571a0

Please sign in to comment.