Skip to content

Commit

Permalink
Unit Tests: fix compiler warning & ARM compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
adbancroft committed Jan 9, 2025
1 parent 2fd2cf1 commit ef2bb3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
32 changes: 16 additions & 16 deletions test/test_math/test_low_pass_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@

static void test_U16_min(void) {
// Passing zero for the filter value should return the input value
TEST_ASSERT_EQUAL_UINT16(0, LOW_PASS_FILTER(0U, 0U, 0U));
TEST_ASSERT_EQUAL_UINT16(1234U, LOW_PASS_FILTER(1234U, 0U, 0U));
TEST_ASSERT_EQUAL_UINT16(1234U, LOW_PASS_FILTER(1234U, 0U, 9999U));
TEST_ASSERT_EQUAL_UINT16(0, LOW_PASS_FILTER((uint16_t)0, UINT8_C(0), (uint16_t)0));
TEST_ASSERT_EQUAL_UINT16(1234U, LOW_PASS_FILTER((uint16_t)1234, UINT8_C(0), (uint16_t)0));
TEST_ASSERT_EQUAL_UINT16(1234U, LOW_PASS_FILTER((uint16_t)1234, UINT8_C(0), (uint16_t)9999));
}

static void test_U16_max(void) {
// Passing UINT8_MAX for the filter value should make the input close to the previous value
TEST_ASSERT_EQUAL_UINT16(0, LOW_PASS_FILTER(0U, UINT8_MAX, 0U));
TEST_ASSERT_EQUAL_UINT16(4U, LOW_PASS_FILTER(1234U, UINT8_MAX, 0U));
TEST_ASSERT_EQUAL_UINT16(9964U, LOW_PASS_FILTER(1234U, UINT8_MAX, 9999U));
TEST_ASSERT_EQUAL_UINT16(0, LOW_PASS_FILTER((uint16_t)0, UINT8_MAX, (uint16_t)0));
TEST_ASSERT_EQUAL_UINT16(4U, LOW_PASS_FILTER((uint16_t)1234, UINT8_MAX, (uint16_t)0));
TEST_ASSERT_EQUAL_UINT16(9964U, LOW_PASS_FILTER((uint16_t)1234, UINT8_MAX, (uint16_t)9999));
}

static void test_S16_min(void) {
// Passing zero for the filter value should return the input value
TEST_ASSERT_EQUAL_INT16(0, LOW_PASS_FILTER(0, 0U, 0));
TEST_ASSERT_EQUAL_INT16(1234, LOW_PASS_FILTER(1234, 0U, 0));
TEST_ASSERT_EQUAL_INT16(-1234, LOW_PASS_FILTER(-1234, 0U, 0));
TEST_ASSERT_EQUAL_INT16(1234, LOW_PASS_FILTER(1234, 0U, 9999));
TEST_ASSERT_EQUAL_INT16(-1234, LOW_PASS_FILTER(-1234, 0U, 9999));
TEST_ASSERT_EQUAL_INT16(0, LOW_PASS_FILTER((int16_t)0, UINT8_C(0), (int16_t)0));
TEST_ASSERT_EQUAL_INT16(1234, LOW_PASS_FILTER((int16_t)1234, UINT8_C(0), (int16_t)0));
TEST_ASSERT_EQUAL_INT16(-1234, LOW_PASS_FILTER((int16_t)-1234, UINT8_C(0), (int16_t)0));
TEST_ASSERT_EQUAL_INT16(1234, LOW_PASS_FILTER((int16_t)1234, UINT8_C(0), (int16_t)9999));
TEST_ASSERT_EQUAL_INT16(-1234, LOW_PASS_FILTER((int16_t)-1234, UINT8_C(0), (int16_t)9999));
}

static void test_S16_max(void) {
// Passing UINT8_MAX for the filter value should make the input close to the previous value
TEST_ASSERT_EQUAL_INT16(0, LOW_PASS_FILTER(0, UINT8_MAX, 0));
TEST_ASSERT_EQUAL_INT16(4, LOW_PASS_FILTER(1234, UINT8_MAX, 0));
TEST_ASSERT_EQUAL_INT16(-4, LOW_PASS_FILTER(-1234, UINT8_MAX, 0));
TEST_ASSERT_EQUAL_INT16(9964, LOW_PASS_FILTER(1234, UINT8_MAX, 9999));
TEST_ASSERT_EQUAL_INT16(-9964, LOW_PASS_FILTER(-1234, UINT8_MAX, -9999));
TEST_ASSERT_EQUAL_INT16(0, LOW_PASS_FILTER((int16_t)0, UINT8_MAX, (int16_t)0));
TEST_ASSERT_EQUAL_INT16(4, LOW_PASS_FILTER((int16_t)1234, UINT8_MAX, (int16_t)0));
TEST_ASSERT_EQUAL_INT16(-4, LOW_PASS_FILTER((int16_t)-1234, UINT8_MAX, (int16_t)0));
TEST_ASSERT_EQUAL_INT16(9964, LOW_PASS_FILTER((int16_t)1234, UINT8_MAX, (int16_t)9999));
TEST_ASSERT_EQUAL_INT16(-9964, LOW_PASS_FILTER((int16_t)-1234, UINT8_MAX, (int16_t)-9999));
}

void test_LOW_PASS_FILTER(void) {
Expand Down
2 changes: 0 additions & 2 deletions test/test_schedule_calcs/test_ign_calcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ struct ign_test_parameters
int16_t expectedEndAngle; // Expected end angle
};

static void nullIgnCallback(void) { }

void test_calc_ign_timeout(const ign_test_parameters &test_params)
{
char msg[150];
Expand Down

0 comments on commit ef2bb3b

Please sign in to comment.