From 63561b8bf84a599eda6ec6a452c7750a20b7f8a7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 08:07:23 +0200 Subject: [PATCH] Correctly initialize `MatchingFailureMask` constants to be used with the `std::bitset` API (#4922) (#4928) * Correctly initialize `MatchingFailureMask` constants to be used with the `std::bitset` API (#4922) * Refs #21165: Add regression test Signed-off-by: eduponz * Refs #21165: Init MatchingFailureMask constants as normal uints Signed-off-by: eduponz * Refs #21165: Apply Ricardo's suggestions Signed-off-by: eduponz --------- Signed-off-by: eduponz (cherry picked from commit 5e1f1dd22afb2dd50abfbeb0726a06907e01209c) # Conflicts: # include/fastdds/rtps/builtin/discovery/endpoint/EDP.h # test/unittest/rtps/discovery/EdpTests.cpp * Solve conflicts Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Dominguez Co-authored-by: Eduardo Ponz Segrelles Co-authored-by: Mario Dominguez --- .../rtps/builtin/discovery/endpoint/EDP.h | 8 ++++---- test/unittest/rtps/discovery/EdpTests.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h b/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h index bcdc927919a..4a1174a15b7 100644 --- a/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h +++ b/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h @@ -71,16 +71,16 @@ class EDP public: //! Bit index for matching failing due to different topic - static const uint32_t different_topic = (0x00000001 << 0u); + static const uint32_t different_topic = 0u; //! Bit index for matching failing due to inconsistent topic (same topic name but different characteristics) - static const uint32_t inconsistent_topic = (0x00000001 << 1u); + static const uint32_t inconsistent_topic = 1u; //! Bit index for matching failing due to incompatible QoS - static const uint32_t incompatible_qos = (0x00000001 << 2u); + static const uint32_t incompatible_qos = 2u; //! Bit index for matching failing due to inconsistent partitions - static const uint32_t partitions = (0x00000001 << 3u); + static const uint32_t partitions = 3u; }; /** diff --git a/test/unittest/rtps/discovery/EdpTests.cpp b/test/unittest/rtps/discovery/EdpTests.cpp index 9381ea8722d..fc6e4704d95 100644 --- a/test/unittest/rtps/discovery/EdpTests.cpp +++ b/test/unittest/rtps/discovery/EdpTests.cpp @@ -399,6 +399,23 @@ TEST_F(EdpTests, CheckPositiveAckCompatibility) } } +TEST(MatchingFailureMask, matching_failure_mask_overflow) +{ + EDP::MatchingFailureMask mask; + + mask.set(EDP::MatchingFailureMask::different_topic); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::different_topic)); + + mask.set(EDP::MatchingFailureMask::inconsistent_topic); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::inconsistent_topic)); + + mask.set(EDP::MatchingFailureMask::incompatible_qos); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::incompatible_qos)); + + mask.set(EDP::MatchingFailureMask::partitions); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::partitions)); +} + } // namespace rtps } // namespace fastrtps } // namespace eprosima