Skip to content

Commit

Permalink
Fix ParameterPropertyList increment operators (#3739)
Browse files Browse the repository at this point in the history
* Refs #19208: regression test

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19208: fix issue 1530

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

---------

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
  • Loading branch information
JLBuenoLopez committed Sep 18, 2023
1 parent ad49587 commit 14689a0
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/fastdds/dds/core/policy/ParameterTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,16 +1127,16 @@ class ParameterPropertyList_t : public Parameter_t

self_type operator ++()
{
self_type i = *this;
advance();
return i;
return *this;
}

self_type operator ++(
int)
{
self_type i = *this;
advance();
return *this;
return i;
}

reference operator *()
Expand Down Expand Up @@ -1215,16 +1215,16 @@ class ParameterPropertyList_t : public Parameter_t

self_type operator ++()
{
self_type i = *this;
advance();
return i;
return *this;
}

self_type operator ++(
int)
{
self_type i = *this;
advance();
return *this;
return i;
}

reference operator *()
Expand Down
1 change: 1 addition & 0 deletions test/unittest/dds/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@

add_subdirectory(condition)
add_subdirectory(entity)
add_subdirectory(policy)
34 changes: 34 additions & 0 deletions test/unittest/dds/core/policy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0601)
endif()

set(PARAMETER_PROPERTY_LIST_TESTS
ParameterPropertyList.cpp)

add_executable(ParameterPropertyListTests ${PARAMETER_PROPERTY_LIST_TESTS})
target_compile_definitions(ParameterPropertyListTests PRIVATE FASTRTPS_NO_LIB
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated.
)
target_include_directories(ParameterPropertyListTests PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include
${PROJECT_SOURCE_DIR}/src/cpp
)
target_link_libraries(ParameterPropertyListTests GTest::gtest fastcdr fastrtps)
add_gtest(ParameterPropertyListTests SOURCES ${PARAMETER_PROPERTY_LIST_TESTS})

45 changes: 45 additions & 0 deletions test/unittest/dds/core/policy/ParameterPropertyList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>

#include <fastdds/dds/core/policy/ParameterTypes.hpp>

using namespace eprosima::fastdds::dds;

TEST(ParameterPropertyList, increment_operator)
{
ParameterPropertyList_t property_list;
property_list.push_back("first", "first_value");
property_list.push_back("second", "second_value");

ParameterPropertyList_t::iterator it = property_list.begin();

EXPECT_EQ(it++, property_list.begin());
EXPECT_EQ(++it, property_list.end());

const ParameterPropertyList_t const_property_list = property_list;
ParameterPropertyList_t::const_iterator const_it = const_property_list.begin();

EXPECT_EQ(const_it++, const_property_list.begin());
EXPECT_EQ(++const_it, const_property_list.end());
}

int main(
int argc,
char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 14689a0

Please sign in to comment.