Fix broken test #7227

This commit is contained in:
kifir 2025-02-07 18:27:49 +02:00 committed by kifir23917
parent 4db94ab60b
commit e65688b784
1 changed files with 10 additions and 5 deletions

View File

@ -10,6 +10,7 @@
namespace {
class BitLoggerFieldTest : public ::testing::Test {
static constexpr uint8_t COIL_STATE_12_BIT_NUMBER = 11;
protected:
void SetUp() override;
@ -28,12 +29,13 @@ class BitLoggerFieldTest : public ::testing::Test {
reinterpret_cast<const char*>(&m_testOutputChannels->outputRequestPeriod)
- reinterpret_cast<const char*>(m_testOutputChannels.get())
) - sizeof(uint32_t);
ASSERT_EQ(
m_logField = std::make_unique<LogField>(
*m_testOutputChannels,
testCoilStateBlockOffset,
660
) << "`output_channels_generated.h` header was modified significantly. "
<< "Please check that coil state bits block precedes `outputRequestPeriod` field.";
m_logField = std::make_unique<LogField>(*m_testOutputChannels, testCoilStateBlockOffset, 11, "coilState12", "");
COIL_STATE_12_BIT_NUMBER,
"coilState12",
""
);
m_buffer.fill(0xAA);
ASSERT_THAT(m_buffer, ::testing::ElementsAre(0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA));
@ -48,6 +50,9 @@ class BitLoggerFieldTest : public ::testing::Test {
m_testOutputChannels->coilState12 = value;
}
// If the following test fails, at first please check that in `output_channels_generated.h` header:
// 1. bits block with `coilState12` bit precedes `outputRequestPeriod` field
// 2. `coilState12` bit number equals `BitLoggerFieldTest::COIL_STATE_12_BIT_NUMBER` constant
TEST_F(BitLoggerFieldTest, checkBitSwitching) {
checkBitLoggerField(false, "default");