Skip to content

Commit

Permalink
#45: Test structure for error and mode handler, tests for controller
Browse files Browse the repository at this point in the history
  • Loading branch information
aul12 committed Dec 28, 2022
1 parent 67e1ea5 commit 1a23005
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
56 changes: 50 additions & 6 deletions Tests/LowLevel/Application/controller.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
/**
* @file controller.cpp
* @author paul
* @date 05.12.22
* Description here TODO
*/
#include <gtest/gtest.h>

extern "C" {
#include <Application/controller.h>
}

TEST(TEST_NAME, no_error) {
imu_data_t imuData{};
imuData.roll_mul_16 = 37 * 16;
imuData.pitch_mul_16 = -49 * 16;
auto controllerCmd = controller_update(&imuData, 37, -49);
EXPECT_EQ(controllerCmd.elevon_right, 0);
EXPECT_EQ(controllerCmd.elevon_left, 0);
}

TEST(TEST_NAME, need_roll_right) {
imu_data_t imuData{};
imuData.roll_mul_16 = -90 * 16;
imuData.pitch_mul_16 = -49 * 16;
auto controllerCmd = controller_update(&imuData, 90, -49);
EXPECT_EQ(controllerCmd.elevon_right, 500);
EXPECT_EQ(controllerCmd.elevon_left, -500);
}

TEST(TEST_NAME, need_roll_left) {
imu_data_t imuData{};
imuData.roll_mul_16 = 90 * 16;
imuData.pitch_mul_16 = -49 * 16;
auto controllerCmd = controller_update(&imuData, -90, -49);
EXPECT_EQ(controllerCmd.elevon_right, -500);
EXPECT_EQ(controllerCmd.elevon_left, 500);
}

TEST(TEST_NAME, need_pitch_up) {
imu_data_t imuData{};
imuData.roll_mul_16 = 37 * 16;
imuData.pitch_mul_16 = 90 * 16;
auto controllerCmd = controller_update(&imuData, 37, -90);
EXPECT_EQ(controllerCmd.elevon_right, 500);
EXPECT_EQ(controllerCmd.elevon_left, 500);
}

TEST(TEST_NAME, need_pitch_down) {
imu_data_t imuData{};
imuData.roll_mul_16 = 37 * 16;
imuData.pitch_mul_16 = -90 * 16;
auto controllerCmd = controller_update(&imuData, 37, 90);
EXPECT_EQ(controllerCmd.elevon_right, -500);
EXPECT_EQ(controllerCmd.elevon_left, -500);
}
15 changes: 9 additions & 6 deletions Tests/LowLevel/Application/error_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/**
* @file error_handler.cpp
* @author paul
* @date 05.12.22
* Description here TODO
*/
#include <gtest/gtest.h>

extern "C" {
#include <Application/error_handler.h>
}

TEST(TEST_NAME, init) {

}
14 changes: 8 additions & 6 deletions Tests/LowLevel/Application/mode_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* @file mode_handler.cpp
* @author Paul Nykiel
* @date 21.12.22
* @brief Description here TODO
*/
#include <gtest/gtest.h>

extern "C" {
#include <Application/mode_handler.h>
}

TEST(TEST_NAME, init) {
}

0 comments on commit 1a23005

Please sign in to comment.