Skip to content

Commit

Permalink
Conversions tests for QX7 only on QX7
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Oct 27, 2022
1 parent 409e26b commit 7a11771
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions radio/src/tests/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,19 @@ TEST(Conversions, ConversionXLiteFrom23)
}
#endif

#if defined(PCBX7) && (STORAGE_CONVERSIONS <= 219)
#if defined(RADIO_X7) && (STORAGE_CONVERSIONS <= 219)

static swarnstate_t get_configured_switch_warn_mask()
{
swarnstate_t mask = 0;
for (uint8_t i=0; i<NUM_SWITCHES; i++) {
if (SWITCH_CONFIG(i) != 0)
mask |= 7 << (3 * i);
}

return mask;
}

TEST(Conversions, ConversionX7From23)
{
#if defined(SDCARD_YAML)
Expand Down Expand Up @@ -256,11 +268,11 @@ TEST(Conversions, ConversionX7From23)
(0x02) | // SA middle
(0x01 << (3 * 1)) | // SB up
(0x03 << (3 * 2)) | // SC down
(0x03 << (3 * 4)); // SF down

swarnstate_t sw_mask = (1 << (NUM_SWITCHES * 3)) - 1;
(0x03 << (3 * 4)) | // SF down
(0x01 << (3 * 5)); // SH up

// check only the "allowed switches"
// check only configured switches (as the code does)
swarnstate_t sw_mask = get_configured_switch_warn_mask();
EXPECT_EQ(state & sw_mask, g_model.switchWarningState & sw_mask);

EXPECT_STRNEQ("Test", g_model.header.name);
Expand Down

0 comments on commit 7a11771

Please sign in to comment.