Skip to content

Commit

Permalink
Refs #20543: Instanciate test listener in stack
Browse files Browse the repository at this point in the history
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
  • Loading branch information
JesusPoderoso committed Mar 27, 2024
1 parent 0dc7793 commit af02764
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/unittest/dds/participant/ParticipantTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,19 +597,19 @@ TEST(ParticipantTests, CreateDomainParticipantWithDefaultProfileListener)
// set XML profile as environment variable: "export FASTDDS_DEFAULT_PROFILES_FILE=test_xml_profile.xml"
eprosima::testing::set_environment_variable("FASTDDS_DEFAULT_PROFILES_FILE", "test_xml_profile.xml");

DomainParticipantListener* listener = new DomainParticipantListener();
DomainParticipantListener listener;

//participant using the given profile
DomainParticipant* default_env_participant =
DomainParticipantFactory::get_instance()->create_participant_with_default_profile(listener,
DomainParticipantFactory::get_instance()->create_participant_with_default_profile(&listener,
StatusMask::none());

// unset XML profile environment variable
eprosima::testing::clear_environment_variable("FASTDDS_DEFAULT_PROFILES_FILE");

ASSERT_NE(default_env_participant, nullptr);
ASSERT_EQ(default_env_participant->get_domain_id(), domain_id);
ASSERT_EQ(default_env_participant->get_listener(), listener);
ASSERT_EQ(default_env_participant->get_listener(), &listener);
ASSERT_TRUE(DomainParticipantFactory::get_instance()->delete_participant(
default_env_participant) == ReturnCode_t::RETCODE_OK);
}
Expand All @@ -632,15 +632,15 @@ TEST(ParticipantTests, CreateDomainParticipantWithoutDefaultProfileListener)
{
uint32_t default_domain_id = 0u; // This is the default domain ID

DomainParticipantListener* listener = new DomainParticipantListener();
DomainParticipantListener listener;

//participant using default values
DomainParticipant* default_participant =
DomainParticipantFactory::get_instance()->create_participant_with_default_profile(listener,
DomainParticipantFactory::get_instance()->create_participant_with_default_profile(&listener,
StatusMask::none());
ASSERT_NE(default_participant, nullptr);
ASSERT_EQ(default_participant->get_domain_id(), default_domain_id);
ASSERT_EQ(default_participant->get_listener(), listener);
ASSERT_EQ(default_participant->get_listener(), &listener);
ASSERT_TRUE(DomainParticipantFactory::get_instance()->delete_participant(
default_participant) == ReturnCode_t::RETCODE_OK);
}
Expand Down

0 comments on commit af02764

Please sign in to comment.