From e65688b784e1c38b224d8fbfd48fe4ed9d0ece4c Mon Sep 17 00:00:00 2001 From: kifir Date: Fri, 7 Feb 2025 18:27:49 +0200 Subject: [PATCH] Fix broken test #7227 --- .../tests/binary_log/test_bit_logger_field.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/unit_tests/tests/binary_log/test_bit_logger_field.cpp b/unit_tests/tests/binary_log/test_bit_logger_field.cpp index adecf6931c..5ef72acbca 100644 --- a/unit_tests/tests/binary_log/test_bit_logger_field.cpp +++ b/unit_tests/tests/binary_log/test_bit_logger_field.cpp @@ -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(&m_testOutputChannels->outputRequestPeriod) - reinterpret_cast(m_testOutputChannels.get()) ) - sizeof(uint32_t); - ASSERT_EQ( + m_logField = std::make_unique( + *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(*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");