Skip to content

Commit

Permalink
Correctly initialize MatchingFailureMask constants to be used with …
Browse files Browse the repository at this point in the history
…the `std::bitset` API (#4922)

* Refs #21165: Add regression test

Signed-off-by: eduponz <[email protected]>

* Refs #21165: Init MatchingFailureMask constants as normal uints

Signed-off-by: eduponz <[email protected]>

* Refs #21165: Apply Ricardo's suggestions

Signed-off-by: eduponz <[email protected]>

---------

Signed-off-by: eduponz <[email protected]>
(cherry picked from commit 5e1f1dd)

# Conflicts:
#	include/fastdds/rtps/builtin/discovery/endpoint/EDP.h
#	test/unittest/rtps/discovery/EdpTests.cpp
  • Loading branch information
EduPonz committed Jun 17, 2024
1 parent 15a93a0 commit 525c36d
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
13 changes: 10 additions & 3 deletions include/fastdds/rtps/builtin/discovery/endpoint/EDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,23 @@ 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
<<<<<<< HEAD:include/fastdds/rtps/builtin/discovery/endpoint/EDP.h
static const uint32_t partitions = (0x00000001 << 3u);
=======
static const uint32_t partitions = 3u;

//! Bit index for matching failing due to incompatible TypeInformation
static const uint32_t different_typeinfo = 4u;
>>>>>>> 5e1f1dd22 (Correctly initialize `MatchingFailureMask` constants to be used with the `std::bitset` API (#4922)):src/cpp/rtps/builtin/discovery/endpoint/EDP.h
};

/**
Expand Down
69 changes: 69 additions & 0 deletions test/unittest/rtps/discovery/EdpTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,75 @@ TEST_F(EdpTests, CheckPositiveAckCompatibility)
}
}

<<<<<<< HEAD
=======
TEST_F(EdpTests, CheckDataRepresentationCompatibility)
{
using DataRepresentationQosVector = std::vector<fastdds::dds::DataRepresentationId>;
std::vector<QosTestingCase<DataRepresentationQosVector>> testing_cases{
{ {}, {}, fastdds::dds::INVALID_QOS_POLICY_ID},
{ {}, {fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION}, fastdds::dds::INVALID_QOS_POLICY_ID},
{ {},
{fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
fastdds::dds::INVALID_QOS_POLICY_ID},
{ {}, {fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
fastdds::dds::DATAREPRESENTATION_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION}, {}, fastdds::dds::INVALID_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION},
{fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION},
fastdds::dds::INVALID_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION},
{fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
fastdds::dds::INVALID_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION},
{fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
fastdds::dds::DATAREPRESENTATION_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION}, {},
fastdds::dds::DATAREPRESENTATION_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
{fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION},
fastdds::dds::DATAREPRESENTATION_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
{fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
fastdds::dds::INVALID_QOS_POLICY_ID},
{ {fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
{fastdds::dds::DataRepresentationId::XCDR2_DATA_REPRESENTATION},
fastdds::dds::INVALID_QOS_POLICY_ID}
};

for (auto testing_case : testing_cases)
{
wdata->m_qos.representation.m_value = testing_case.offered_qos;
rdata->m_qos.representation.m_value = testing_case.requested_qos;
check_expectations(testing_case.failed_qos);
}
}

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));

mask.set(EDP::MatchingFailureMask::different_typeinfo);
EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::different_typeinfo));
}


>>>>>>> 5e1f1dd22 (Correctly initialize `MatchingFailureMask` constants to be used with the `std::bitset` API (#4922))
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
Expand Down

0 comments on commit 525c36d

Please sign in to comment.