diff --git a/include/fastdds/dds/core/policy/ParameterTypes.hpp b/include/fastdds/dds/core/policy/ParameterTypes.hpp index 4cb0fe5a038..a9614d2c5d5 100644 --- a/include/fastdds/dds/core/policy/ParameterTypes.hpp +++ b/include/fastdds/dds/core/policy/ParameterTypes.hpp @@ -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 *() @@ -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 *() diff --git a/test/unittest/dds/core/CMakeLists.txt b/test/unittest/dds/core/CMakeLists.txt index 65a05eebe72..627b2cacde7 100644 --- a/test/unittest/dds/core/CMakeLists.txt +++ b/test/unittest/dds/core/CMakeLists.txt @@ -14,3 +14,4 @@ add_subdirectory(condition) add_subdirectory(entity) +add_subdirectory(policy) diff --git a/test/unittest/dds/core/policy/CMakeLists.txt b/test/unittest/dds/core/policy/CMakeLists.txt new file mode 100644 index 00000000000..30492ea7888 --- /dev/null +++ b/test/unittest/dds/core/policy/CMakeLists.txt @@ -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 + $<$>,$>:__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}) + diff --git a/test/unittest/dds/core/policy/ParameterPropertyList.cpp b/test/unittest/dds/core/policy/ParameterPropertyList.cpp new file mode 100644 index 00000000000..1f84536515b --- /dev/null +++ b/test/unittest/dds/core/policy/ParameterPropertyList.cpp @@ -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 + +#include + +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(); +}