From ff5a619e9495850a5d33cd1d830daa0a8a611364 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sun, 15 Oct 2023 20:29:55 +0200 Subject: [PATCH 1/4] iox-#2041 Move 'CTorTest' to 'iox::testing::CTorAndAssignmentOperatorTestClass' --- .../moduletests/test_container_vector.cpp | 240 ++++++------------ ...tor_and_assignment_operator_test_class.hpp | 134 ++++++++++ 2 files changed, 210 insertions(+), 164 deletions(-) create mode 100644 iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp diff --git a/iceoryx_hoofs/test/moduletests/test_container_vector.cpp b/iceoryx_hoofs/test/moduletests/test_container_vector.cpp index b8bbe3c2ef..1981c60c90 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_vector.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_vector.cpp @@ -16,6 +16,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_hoofs/error_handling/error_handling.hpp" +#include "iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" #include "iox/vector.hpp" #include "test.hpp" @@ -31,108 +32,19 @@ using namespace iox::testing; class vector_test : public Test { public: - static uint64_t cTor; - static uint64_t customCTor; - static uint64_t copyCTor; - static uint64_t moveCTor; - static uint64_t moveAssignment; - static uint64_t copyAssignment; - static uint64_t dTor; - static uint64_t classValue; - - static std::vector dtorOrder; - - class CTorTest - { - public: - CTorTest() - { - cTor++; - classValue = value; - } - - explicit CTorTest(const uint64_t value) - : value(value) - { - customCTor++; - classValue = value; - } - - CTorTest(const CTorTest& rhs) - : value(rhs.value) - { - copyCTor++; - classValue = value; - } - - CTorTest(CTorTest&& rhs) noexcept - : value(rhs.value) - { - moveCTor++; - classValue = value; - } - - CTorTest& operator=(const CTorTest& rhs) - { - if (this != &rhs) - { - copyAssignment++; - value = rhs.value; - classValue = value; - } - return *this; - } - - CTorTest& operator=(CTorTest&& rhs) noexcept - { - moveAssignment++; - value = rhs.value; - classValue = value; - return *this; - } - - bool operator==(const CTorTest& rhs) const - { - return value == rhs.value; - } - - ~CTorTest() - { - dTor++; - classValue = value; - dtorOrder.emplace_back(value); - } - - uint64_t value = 0; - }; + using CTorTest = CTorAndAssignmentOperatorTestClass<>; void SetUp() override { - cTor = 0U; - customCTor = 0U; - copyCTor = 0U; - moveCTor = 0U; - moveAssignment = 0U; - copyAssignment = 0U; - dTor = 0U; - classValue = 0U; - dtorOrder.clear(); + stats.reset(); } + CTorTest::Statistics& stats = CTorTest::stats; + static constexpr uint64_t VECTOR_CAPACITY{10}; vector sut; }; -uint64_t vector_test::cTor; -uint64_t vector_test::customCTor; -uint64_t vector_test::copyCTor; -uint64_t vector_test::moveCTor; -uint64_t vector_test::moveAssignment; -uint64_t vector_test::copyAssignment; -uint64_t vector_test::dTor; -uint64_t vector_test::classValue; -std::vector vector_test::dtorOrder; - TEST_F(vector_test, NewlyCreatedVectorIsEmpty) { ::testing::Test::RecordProperty("TEST_ID", "8ebb8b11-d044-459e-b9a1-4a3076c8d49c"); @@ -268,10 +180,10 @@ TEST_F(vector_test, PopBackNonEmptyVector) vector sut; sut.emplace_back(101U); ASSERT_THAT(sut.size(), Eq(1U)); - dTor = 0; + stats.dTor = 0; sut.pop_back(); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(dTor, Eq(1)); + ASSERT_THAT(stats.dTor, Eq(1)); } TEST_F(vector_test, SizeIncreasesWhenElementIsAdded) @@ -333,7 +245,7 @@ TEST_F(vector_test, CopyConstructor) sut1.emplace_back(102U); vector sut2(sut1); - EXPECT_THAT(copyCTor, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(2U)); EXPECT_THAT(sut2.at(0).value, Eq(101U)); EXPECT_THAT(sut2.at(1).value, Eq(102U)); EXPECT_THAT(sut2.empty(), Eq(false)); @@ -347,7 +259,7 @@ TEST_F(vector_test, CopyConstructorWithEmptyVector) // NOLINTJUSTIFICATION Testing empty copy // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) vector sut2(sut1); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut2.size(), Eq(0U)); EXPECT_THAT(sut2.empty(), Eq(true)); } @@ -367,7 +279,7 @@ TEST_F(vector_test, CopyConstructorWithFullVector) EXPECT_THAT(sut2.at(i).value, Eq(i)); } - EXPECT_THAT(copyCTor, Eq(10U)); + EXPECT_THAT(stats.copyCTor, Eq(10U)); EXPECT_THAT(sut2.size(), Eq(10U)); EXPECT_THAT(sut2.empty(), Eq(false)); } @@ -381,7 +293,7 @@ TEST_F(vector_test, MoveConstructor) vector sut2(std::move(sut1)); - EXPECT_THAT(moveCTor, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(2U)); EXPECT_THAT(sut2.at(0).value, Eq(8101U)); EXPECT_THAT(sut2.at(1).value, Eq(8102U)); EXPECT_THAT(sut2.empty(), Eq(false)); @@ -395,7 +307,7 @@ TEST_F(vector_test, MoveConstructorWithEmptyVector) vector sut2(std::move(sut1)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut2.size(), Eq(0U)); EXPECT_THAT(sut2.empty(), Eq(true)); } @@ -416,7 +328,7 @@ TEST_F(vector_test, MoveConstructorWithFullVector) EXPECT_THAT(sut2.at(i).value, Eq(i)); } - EXPECT_THAT(moveCTor, Eq(10U)); + EXPECT_THAT(stats.moveCTor, Eq(10U)); EXPECT_THAT(sut2.size(), Eq(10U)); EXPECT_THAT(sut2.empty(), Eq(false)); } @@ -427,7 +339,7 @@ TEST_F(vector_test, DestructorWithEmptyVector) { vector sut1; } - EXPECT_THAT(dTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(0U)); } TEST_F(vector_test, DestructorSomeElements) @@ -439,7 +351,7 @@ TEST_F(vector_test, DestructorSomeElements) sut1.emplace_back(9191U); sut1.emplace_back(1U); } - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); } TEST_F(vector_test, DestructorWithFullVector) @@ -454,7 +366,7 @@ TEST_F(vector_test, DestructorWithFullVector) } } - EXPECT_THAT(dTor, Eq(CAPACITY)); + EXPECT_THAT(stats.dTor, Eq(CAPACITY)); } TEST_F(vector_test, EmplacingElementInTheMiddleCallsDTor) @@ -470,17 +382,17 @@ TEST_F(vector_test, EmplacingElementInTheMiddleCallsDTor) sut.emplace_back(1234U); } - EXPECT_THAT(customCTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS - 1U)); + EXPECT_THAT(stats.customCTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS - 1U)); EXPECT_TRUE(sut.emplace(EMPLACE_POSITION, 42U)); - EXPECT_THAT(customCTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS)); - EXPECT_THAT(moveCTor, Eq(1U)); - EXPECT_THAT(moveAssignment, Eq(CAPACITY_OF_VECTOR - 1U - EMPLACE_POSITION - 1U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS)); + EXPECT_THAT(stats.moveCTor, Eq(1U)); + EXPECT_THAT(stats.moveAssignment, Eq(CAPACITY_OF_VECTOR - 1U - EMPLACE_POSITION - 1U)); + EXPECT_THAT(stats.dTor, Eq(1U)); } // Last element in the vector is moved and not constructed, hence #moveCTor + #customCTor = #dTor - EXPECT_THAT(moveCTor, Eq(1U)); - EXPECT_THAT(customCTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS)); - EXPECT_THAT(dTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS + 1U)); + EXPECT_THAT(stats.moveCTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS)); + EXPECT_THAT(stats.dTor, Eq(EXPECTED_NUMBER_OF_CTOR_CALLS + 1U)); } TEST_F(vector_test, CopyAssignmentWithEmptySource) @@ -494,9 +406,9 @@ TEST_F(vector_test, CopyAssignmentWithEmptySource) sut1 = sut2; - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut1.size(), Eq(0U)); EXPECT_THAT(sut1.empty(), Eq(true)); } @@ -512,9 +424,9 @@ TEST_F(vector_test, CopyAssignmentWithEmptyDestination) sut2 = sut1; - EXPECT_THAT(dTor, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(3U)); EXPECT_THAT(sut2.size(), Eq(3U)); EXPECT_THAT(sut2.empty(), Eq(false)); @@ -537,9 +449,9 @@ TEST_F(vector_test, CopyAssignmentWithLargerDestination) sut1 = sut2; - EXPECT_THAT(dTor, Eq(2U)); - EXPECT_THAT(copyAssignment, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); + EXPECT_THAT(stats.copyAssignment, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut1.size(), Eq(2U)); EXPECT_THAT(sut1.empty(), Eq(false)); EXPECT_THAT(sut1.at(0U).value, Eq(313U)); @@ -560,9 +472,9 @@ TEST_F(vector_test, CopyAssignmentWithLargerSource) sut2 = sut1; - EXPECT_THAT(dTor, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(2U)); EXPECT_THAT(sut2.size(), Eq(4U)); EXPECT_THAT(sut2.empty(), Eq(false)); EXPECT_THAT(sut2.at(0U).value, Eq(15842U)); @@ -583,11 +495,11 @@ TEST_F(vector_test, ReverseDestructionOrderInCopyAssignment) } sut1 = sut2; - EXPECT_THAT(dTor, Eq(VECTOR_CAPACITY)); - ASSERT_THAT(dtorOrder.size(), Eq(VECTOR_CAPACITY)); + EXPECT_THAT(stats.dTor, Eq(VECTOR_CAPACITY)); + ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_CAPACITY)); for (uint64_t i{0}; i < VECTOR_CAPACITY; ++i) { - EXPECT_THAT(dtorOrder[i], Eq(VECTOR_CAPACITY - 1 - i)); + EXPECT_THAT(stats.dTorOrder[i], Eq(VECTOR_CAPACITY - 1 - i)); } } @@ -603,11 +515,11 @@ TEST_F(vector_test, ReverseDestructionOrderInMoveAssignment) } sut1 = std::move(sut2); - EXPECT_THAT(dTor, Eq(VECTOR_CAPACITY)); - ASSERT_THAT(dtorOrder.size(), Eq(VECTOR_CAPACITY)); + EXPECT_THAT(stats.dTor, Eq(VECTOR_CAPACITY)); + ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_CAPACITY)); for (uint64_t i{0}; i < VECTOR_CAPACITY; ++i) { - EXPECT_THAT(dtorOrder[i], Eq(VECTOR_CAPACITY - i)); + EXPECT_THAT(stats.dTorOrder[i], Eq(VECTOR_CAPACITY - i)); } } @@ -622,9 +534,9 @@ TEST_F(vector_test, MoveAssignmentWithEmptySource) sut1 = std::move(sut2); - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut1.size(), Eq(0U)); EXPECT_THAT(sut1.empty(), Eq(true)); } @@ -640,9 +552,9 @@ TEST_F(vector_test, MoveAssignmentWithEmptyDestination) sut2 = std::move(sut1); - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(3U)); EXPECT_THAT(sut2.size(), Eq(3U)); EXPECT_THAT(sut2.empty(), Eq(false)); EXPECT_THAT(sut2.at(0U).value, Eq(5812U)); @@ -664,9 +576,9 @@ TEST_F(vector_test, MoveAssignmentWithLargerDestination) sut1 = std::move(sut2); - EXPECT_THAT(dTor, Eq(4U)); - EXPECT_THAT(moveAssignment, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(4U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut1.size(), Eq(2U)); EXPECT_THAT(sut1.empty(), Eq(false)); EXPECT_THAT(sut1.at(0U).value, Eq(313U)); @@ -687,9 +599,9 @@ TEST_F(vector_test, MoveAssignmentWithLargerSource) sut2 = std::move(sut1); - EXPECT_THAT(dTor, Eq(4U)); - EXPECT_THAT(moveAssignment, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(4U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(2U)); EXPECT_THAT(sut2.size(), Eq(4U)); EXPECT_THAT(sut2.empty(), Eq(false)); EXPECT_THAT(sut2.at(0U).value, Eq(15842U)); @@ -943,8 +855,8 @@ TEST_F(vector_test, EraseOfLastElementCallsDTorOnly) EXPECT_TRUE(sut1.erase(sut1.begin() + 2U)); - EXPECT_THAT(dTor, Eq(1U)); - EXPECT_THAT(classValue, Eq(9U)); + EXPECT_THAT(stats.dTor, Eq(1U)); + EXPECT_THAT(stats.classValue, Eq(9U)); } TEST_F(vector_test, EraseOfMiddleElementCallsDTorAndMove) @@ -959,8 +871,8 @@ TEST_F(vector_test, EraseOfMiddleElementCallsDTorAndMove) EXPECT_TRUE(sut1.erase(sut1.begin() + 2U)); - EXPECT_THAT(dTor, Eq(1U)); - EXPECT_THAT(moveAssignment, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(1U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); } TEST_F(vector_test, AccessOfNonExistingElementOnEmptyVectorLeadTermination) @@ -1053,8 +965,8 @@ TEST_F(vector_test, EraseOfFrontElementCallsDTorAndMove) EXPECT_TRUE(sut1.erase(sut1.begin())); - EXPECT_THAT(dTor, Eq(1U)); - EXPECT_THAT(moveAssignment, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(1U)); + EXPECT_THAT(stats.moveAssignment, Eq(4U)); } TEST_F(vector_test, EraseMiddleElementDataCorrectAfterwards) @@ -1169,7 +1081,7 @@ TEST_F(vector_test, ConstructorWithSizeParameterSmallerThanCapacity) { ::testing::Test::RecordProperty("TEST_ID", "b55f3818-ded5-420a-ad9a-88d5e90b429e"); vector sut(2U); - EXPECT_THAT(vector_test::cTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); ASSERT_THAT(sut.size(), Eq(2U)); } @@ -1177,7 +1089,7 @@ TEST_F(vector_test, ConstructorWithSizeParameterGreaterThanCapacity) { ::testing::Test::RecordProperty("TEST_ID", "57d86dd4-ba23-4911-a451-bbc78d3f899a"); vector sut(7U); - EXPECT_THAT(vector_test::cTor, Eq(5U)); + EXPECT_THAT(stats.cTor, Eq(5U)); ASSERT_THAT(sut.size(), Eq(5U)); } @@ -1348,10 +1260,10 @@ TEST_F(vector_test, FullVectorDestroysElementsInReverseOrder) } } - ASSERT_THAT(dtorOrder.size(), Eq(VECTOR_CAPACITY)); + ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_CAPACITY)); for (uint64_t i = 0U; i < VECTOR_CAPACITY; ++i) { - EXPECT_THAT(dtorOrder[i], Eq(INDEX_END - i + SOME_OFFSET)); + EXPECT_THAT(stats.dTorOrder[i], Eq(INDEX_END - i + SOME_OFFSET)); } } @@ -1372,10 +1284,10 @@ TEST_F(vector_test, PartiallyFullVectorDestroysElementsInReverseOrder) } } - ASSERT_THAT(dtorOrder.size(), Eq(VECTOR_SIZE)); + ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_SIZE)); for (uint64_t i = 0U; i < VECTOR_SIZE; ++i) { - EXPECT_THAT(dtorOrder[i], Eq(INDEX_END - i + SOME_OFFSET)); + EXPECT_THAT(stats.dTorOrder[i], Eq(INDEX_END - i + SOME_OFFSET)); } } @@ -1465,11 +1377,11 @@ TEST_F(vector_test, SizeDecreaseWithResizeAndDefaultCTorWorks) } EXPECT_TRUE(sut.resize(7U)); - EXPECT_THAT(dTor, Eq(3U)); - ASSERT_THAT(dtorOrder.size(), Eq(3U)); - EXPECT_THAT(dtorOrder[0], Eq(9)); - EXPECT_THAT(dtorOrder[1], Eq(8)); - EXPECT_THAT(dtorOrder[2], Eq(7)); + EXPECT_THAT(stats.dTor, Eq(3U)); + ASSERT_THAT(stats.dTorOrder.size(), Eq(3U)); + EXPECT_THAT(stats.dTorOrder[0], Eq(9)); + EXPECT_THAT(stats.dTorOrder[1], Eq(8)); + EXPECT_THAT(stats.dTorOrder[2], Eq(7)); } TEST_F(vector_test, SizeDecreaseWithResizeAndTemplateValueWorks) @@ -1483,11 +1395,11 @@ TEST_F(vector_test, SizeDecreaseWithResizeAndTemplateValueWorks) } EXPECT_TRUE(sut.resize(7U, 66807U)); - EXPECT_THAT(dTor, Eq(3U)); - ASSERT_THAT(dtorOrder.size(), Eq(3U)); - EXPECT_THAT(dtorOrder[0], Eq(19)); - EXPECT_THAT(dtorOrder[1], Eq(18)); - EXPECT_THAT(dtorOrder[2], Eq(17)); + EXPECT_THAT(stats.dTor, Eq(3U)); + ASSERT_THAT(stats.dTorOrder.size(), Eq(3U)); + EXPECT_THAT(stats.dTorOrder[0], Eq(19)); + EXPECT_THAT(stats.dTorOrder[1], Eq(18)); + EXPECT_THAT(stats.dTorOrder[2], Eq(17)); } TEST_F(vector_test, ResizeWithDefaultCTorChangesNothingIfSizeAlreadyFits) diff --git a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp new file mode 100644 index 0000000000..9be1afd804 --- /dev/null +++ b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp @@ -0,0 +1,134 @@ +// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2023 by Mathias Kraus . All rights reserved. +// +// 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. +// +// SPDX-License-Identifier: Apache-2.0 + +#ifndef IOX_HOOFS_TESTING_CTOR_AND_ASSIGNMENT_OPERATOR_TEST_CLASS_HPP +#define IOX_HOOFS_TESTING_CTOR_AND_ASSIGNMENT_OPERATOR_TEST_CLASS_HPP + +#include +#include + +namespace iox +{ +namespace testing +{ +template +class CTorAndAssignmentOperatorTestClass +{ + public: + CTorAndAssignmentOperatorTestClass() + { + stats.cTor++; + stats.classValue = value; + } + + // NOLINTNEXTLINE(hicpp-explicit-conversions) we want to use this class in tests transparently to a 'T' + CTorAndAssignmentOperatorTestClass(const T value) + : value(value) + { + stats.customCTor++; + stats.classValue = value; + } + + CTorAndAssignmentOperatorTestClass(const CTorAndAssignmentOperatorTestClass& rhs) + : value(rhs.value) + { + stats.copyCTor++; + stats.classValue = value; + } + + CTorAndAssignmentOperatorTestClass(CTorAndAssignmentOperatorTestClass&& rhs) noexcept + : value(rhs.value) + { + stats.moveCTor++; + stats.classValue = value; + } + + CTorAndAssignmentOperatorTestClass& operator=(const CTorAndAssignmentOperatorTestClass& rhs) + { + if (this != &rhs) + { + stats.copyAssignment++; + value = rhs.value; + stats.classValue = value; + } + return *this; + } + + CTorAndAssignmentOperatorTestClass& operator=(CTorAndAssignmentOperatorTestClass&& rhs) noexcept + { + if (this != &rhs) + { + stats.moveAssignment++; + value = rhs.value; + stats.classValue = value; + } + return *this; + } + + bool operator==(const CTorAndAssignmentOperatorTestClass& rhs) const + { + return value == rhs.value; + } + + ~CTorAndAssignmentOperatorTestClass() + { + stats.dTor++; + stats.classValue = value; + stats.dTorOrder.emplace_back(value); + } + + struct Statistics + { + uint64_t cTor{0}; + uint64_t customCTor{0}; + uint64_t copyCTor{0}; + uint64_t moveCTor{0}; + uint64_t moveAssignment{0}; + uint64_t copyAssignment{0}; + uint64_t dTor{0}; + T classValue{0}; + + std::vector dTorOrder; + + void reset() + { + cTor = 0; + customCTor = 0; + copyCTor = 0; + moveCTor = 0; + moveAssignment = 0; + copyAssignment = 0; + dTor = 0; + classValue = 0; + dTorOrder.clear(); + } + }; + + //NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) only used for tests + static Statistics stats; + + T value = DEFAULT_VALUE; +}; + +template +typename CTorAndAssignmentOperatorTestClass::Statistics + CTorAndAssignmentOperatorTestClass::stats{}; +} // namespace testing +} // namespace iox + +#endif // IOX_HOOFS_TESTING_CTOR_AND_ASSIGNMENT_OPERATOR_TEST_CLASS_HPP From 9f02c90de03075b3fcc2c0e04a78926cce939a79 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sun, 15 Oct 2023 21:24:00 +0200 Subject: [PATCH 2/4] iox-#2041 Port 'forward_list' tests to 'iox::testing::CTorAndAssignmentOperatorTestClass' --- .../moduletests/test_cxx_forward_list.cpp | 693 ++++++++---------- 1 file changed, 304 insertions(+), 389 deletions(-) diff --git a/iceoryx_dust/test/moduletests/test_cxx_forward_list.cpp b/iceoryx_dust/test/moduletests/test_cxx_forward_list.cpp index cc717f326c..ea86c47204 100644 --- a/iceoryx_dust/test/moduletests/test_cxx_forward_list.cpp +++ b/iceoryx_dust/test/moduletests/test_cxx_forward_list.cpp @@ -16,6 +16,7 @@ #include "iceoryx_dust/cxx/forward_list.hpp" #include "iceoryx_hoofs/error_handling/error_handling.hpp" +#include "iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" #include "iox/attributes.hpp" #include "test.hpp" @@ -32,118 +33,32 @@ constexpr int64_t TEST_LIST_ELEMENT_DEFAULT_VALUE{-99L}; class forward_list_test : public Test { public: - static uint64_t cTor; - static uint64_t customCTor; - static uint64_t copyCTor; - static uint64_t moveCTor; - static uint64_t moveAssignment; - static uint64_t copyAssignment; - static uint64_t dTor; - static int64_t classValue; - - class TestListElement - { - public: - TestListElement() - { - cTor++; - classValue = m_value; - } - - // NOLINTNEXTLINE(hicpp-explicit-conversions) only used for tests - TestListElement(const int64_t value) - : m_value(value) - { - customCTor++; - classValue = m_value; - } - - TestListElement(const TestListElement& rhs) - : m_value(rhs.m_value) - { - copyCTor++; - classValue = m_value; - } - - TestListElement(TestListElement&& rhs) noexcept - : m_value(rhs.m_value) - { - moveCTor++; - classValue = m_value; - } - - TestListElement& operator=(const TestListElement& rhs) - { - if (this != &rhs) - { - copyAssignment++; - m_value = rhs.m_value; - classValue = m_value; - } - return *this; - } - - TestListElement& operator=(TestListElement&& rhs) noexcept - { - moveAssignment++; - m_value = rhs.m_value; - classValue = m_value; - return *this; - } - - bool operator==(const TestListElement& rhs) const - { - return rhs.m_value == m_value; - } - - ~TestListElement() - { - dTor++; - classValue = m_value; - } - - int64_t m_value = TEST_LIST_ELEMENT_DEFAULT_VALUE; - }; - + using TestListElement = CTorAndAssignmentOperatorTestClass; void SetUp() override { - cTor = 0U; - customCTor = 0U; - copyCTor = 0U; - moveCTor = 0U; - moveAssignment = 0U; - copyAssignment = 0U; - dTor = 0U; - classValue = 0U; + stats.reset(); } + TestListElement::Statistics& stats = TestListElement::stats; + static bool isSetupState() { - return (cTor == 0U && customCTor == 0U && copyCTor == 0U && moveCTor == 0U && moveAssignment == 0U - && copyAssignment == 0U && dTor == 0U && classValue == 0); + TestListElement::Statistics& stats = TestListElement::stats; + return (stats.cTor == 0U && stats.customCTor == 0U && stats.copyCTor == 0U && stats.moveCTor == 0U + && stats.moveAssignment == 0U && stats.copyAssignment == 0U && stats.dTor == 0U + && stats.classValue == 0); } forward_list sut; }; -// forward_list_test statics -uint64_t forward_list_test::cTor; -uint64_t forward_list_test::customCTor; -uint64_t forward_list_test::copyCTor; -uint64_t forward_list_test::moveCTor; -uint64_t forward_list_test::moveAssignment; -uint64_t forward_list_test::copyAssignment; -uint64_t forward_list_test::dTor; -int64_t forward_list_test::classValue; - - template int64_t iteratorTraitReturnDoubleValue(IterType iter) { typedef typename std::iterator_traits::value_type IterValueType; - IterValueType m_value = *iter; - return (2 * m_value); // will only work for integer-convertible m_value types + IterValueType value = *iter; + return (2 * value); // will only work for integer-convertible value types } } // namespace @@ -227,7 +142,7 @@ TEST_F(forward_list_test, beforeBeginAndCbeginAreDifferentWhenEmpty) TEST_F(forward_list_test, CbeginCendAreDifferentWhenFilled) { ::testing::Test::RecordProperty("TEST_ID", "a8e9c012-6ee8-42fb-9851-cab9757bd987"); - EXPECT_THAT(sut.emplace_front().m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(sut.emplace_front().value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); EXPECT_THAT(sut.cbegin() != sut.cend(), Eq(true)); } TEST_F(forward_list_test, BeginEndAreDifferentWhenFilled) @@ -273,7 +188,7 @@ TEST_F(forward_list_test, FullWhenFilledWithCapacityElements) ::testing::Test::RecordProperty("TEST_ID", "03487ca4-71f8-4e8c-abdc-ed2cd0867b06"); for (uint64_t i = 0U; i < sut.capacity(); ++i) { - EXPECT_THAT(sut.emplace_front().m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(sut.emplace_front().value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } EXPECT_THAT(sut.full(), Eq(true)); } @@ -338,14 +253,14 @@ TEST_F(forward_list_test, CTorWithOneElements) constexpr uint64_t ELEMENT_COUNT{1U}; forward_list sut1; - EXPECT_THAT(cTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { sut1.emplace_front(); } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, CustomCTorWithOneElements) @@ -362,9 +277,9 @@ TEST_F(forward_list_test, CustomCTorWithOneElements) } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); - EXPECT_THAT(classValue, Eq(DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.classValue, Eq(DEFAULT_VALUE)); } TEST_F(forward_list_test, CTorWithSomeElements) @@ -380,7 +295,7 @@ TEST_F(forward_list_test, CTorWithSomeElements) } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, CTorWithCapacityElements) @@ -396,7 +311,7 @@ TEST_F(forward_list_test, CTorWithCapacityElements) } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, CTorWithMoreThanCapacityElements) @@ -413,8 +328,8 @@ TEST_F(forward_list_test, CTorWithMoreThanCapacityElements) sut1.emplace_after(sut1.cbefore_begin(), 2U); EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(CAPACITY)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(CAPACITY)); + EXPECT_THAT(stats.customCTor, Eq(0U)); } @@ -425,10 +340,10 @@ TEST_F(forward_list_test, EmplaceAfterWithOneElements) constexpr uint64_t ELEMENT_COUNT{1U}; forward_list sut1; auto iter = sut1.cbefore_begin(); - decltype(TestListElement::m_value) cnt = 0U; + decltype(TestListElement::value) cnt = 0U; - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -439,13 +354,13 @@ TEST_F(forward_list_test, EmplaceAfterWithOneElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, EmplaceAfterWithSomeElements) @@ -457,8 +372,8 @@ TEST_F(forward_list_test, EmplaceAfterWithSomeElements) auto iter = sut1.cbefore_begin(); int64_t cnt = 0; - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -469,13 +384,13 @@ TEST_F(forward_list_test, EmplaceAfterWithSomeElements) cnt = 0; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, EmplaceAfterWithCapacityElements) @@ -496,13 +411,13 @@ TEST_F(forward_list_test, EmplaceAfterWithCapacityElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, EmplaceAfterWithMoreThanCapacityElements) @@ -523,13 +438,13 @@ TEST_F(forward_list_test, EmplaceAfterWithMoreThanCapacityElements) cnt = 0; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(CAPACITY)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(CAPACITY)); } @@ -551,13 +466,13 @@ TEST_F(forward_list_test, EmplaceAfterReverseWithOneElements) --cnt; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); --cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, EmplaceAfterReverseWithSomeElements) @@ -578,13 +493,13 @@ TEST_F(forward_list_test, EmplaceAfterReverseWithSomeElements) --cnt; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); --cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, EmplaceAfterReverseWithCapacityElements) @@ -605,13 +520,13 @@ TEST_F(forward_list_test, EmplaceAfterReverseWithCapacityElements) cnt = CAPACITY - 1; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); --cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(forward_list_test, EmplaceAfterReverseWithWithMoreThanCapacityElements) @@ -632,13 +547,13 @@ TEST_F(forward_list_test, EmplaceAfterReverseWithWithMoreThanCapacityElements) cnt = CAPACITY - 1; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); --cnt; } EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(CAPACITY)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(CAPACITY)); } TEST_F(forward_list_test, EmplaceAfterWithWrongListIterator) @@ -669,9 +584,9 @@ TEST_F(forward_list_test, PushFrontConstCustomSuccessfullWhenSpaceAvailableLValu const TestListElement a{DEFAULT_VALUE}; EXPECT_TRUE(sut.push_front(a)); ASSERT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT((*sut.begin()).value, Eq(DEFAULT_VALUE)); } TEST_F(forward_list_test, PushFrontConstSuccessfullWhenSpaceAvailableLValue) @@ -680,9 +595,9 @@ TEST_F(forward_list_test, PushFrontConstSuccessfullWhenSpaceAvailableLValue) const TestListElement a{}; EXPECT_TRUE(sut.push_front(a)); ASSERT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT(cTor, Eq(1U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT((*sut.begin()).value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } TEST_F(forward_list_test, PushFrontFailsWhenSpaceNotAvailableLValue) @@ -708,9 +623,9 @@ TEST_F(forward_list_test, PushFrontSuccessfullWhenSpaceAvailableRValue) EXPECT_THAT(sut.size(), Eq(0U)); - sut.push_front(DEFAULT_VALUE); + sut.push_front(TestListElement{DEFAULT_VALUE}); EXPECT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((*sut.begin()).value, Eq(DEFAULT_VALUE)); } TEST_F(forward_list_test, PushFrontFailsWhenSpaceNotAvailableRValue) @@ -730,7 +645,7 @@ TEST_F(forward_list_test, PushFrontFailsWhenSpaceNotAvailableRValue) for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(listElement.value, Eq(DEFAULT_VALUE)); } } @@ -746,8 +661,8 @@ TEST_F(forward_list_test, AccessFrontElement) TestListElement& b{sut.front()}; const TestListElement& c{sut.front()}; - EXPECT_THAT(b.m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT(c.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(b.value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(c.value, Eq(DEFAULT_VALUE)); } TEST_F(forward_list_test, AccessFrontElementFromConstList) @@ -762,8 +677,8 @@ TEST_F(forward_list_test, AccessFrontElementFromConstList) const forward_list sut1{sut}; const TestListElement& c = sut1.front(); - EXPECT_THAT(c.m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT(sut1.front().m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(c.value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(sut1.front().value, Eq(DEFAULT_VALUE)); } @@ -785,9 +700,9 @@ TEST_F(forward_list_test, PopFrontNonEmptyList) EXPECT_TRUE(sut.pop_front()); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(dTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.dTor, Eq(1U)); } TEST_F(forward_list_test, PopFrontFullToEmptyList) @@ -806,8 +721,8 @@ TEST_F(forward_list_test, PopFrontFullToEmptyList) } ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(TESTLISTCAPACITY)); - ASSERT_THAT(dTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); } TEST_F(forward_list_test, PopFrontFullPlusOneToEmptyList) @@ -828,9 +743,9 @@ TEST_F(forward_list_test, PopFrontFullPlusOneToEmptyList) EXPECT_FALSE(sut.pop_front()); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(TESTLISTCAPACITY)); - ASSERT_THAT(customCTor, Eq(0U)); - ASSERT_THAT(dTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.customCTor, Eq(0U)); + ASSERT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); } @@ -843,12 +758,12 @@ TEST_F(forward_list_test, InsertAfterEmptyListAsLValue) sut.insert_after(sut.before_begin(), a); ASSERT_THAT(sut.size(), Eq(1U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(copyCTor, Eq(1U)); - ASSERT_THAT(moveCTor, Eq(0U)); - ASSERT_THAT(copyAssignment, Eq(0U)); - ASSERT_THAT(moveAssignment, Eq(0U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.copyCTor, Eq(1U)); + ASSERT_THAT(stats.moveCTor, Eq(0U)); + ASSERT_THAT(stats.copyAssignment, Eq(0U)); + ASSERT_THAT(stats.moveAssignment, Eq(0U)); } TEST_F(forward_list_test, InsertAfterLValueCheckReturn) @@ -869,12 +784,12 @@ TEST_F(forward_list_test, InsertAfterEmptyListAsRValue) sut.insert_after(sut.before_begin(), {DATA}); ASSERT_THAT(sut.size(), Eq(1U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(copyCTor, Eq(0U)); - ASSERT_THAT(moveCTor, Eq(1U)); - ASSERT_THAT(copyAssignment, Eq(0U)); - ASSERT_THAT(moveAssignment, Eq(0U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.copyCTor, Eq(0U)); + ASSERT_THAT(stats.moveCTor, Eq(1U)); + ASSERT_THAT(stats.copyAssignment, Eq(0U)); + ASSERT_THAT(stats.moveAssignment, Eq(0U)); } TEST_F(forward_list_test, InsertAfterRValueCheckReturn) @@ -884,7 +799,7 @@ TEST_F(forward_list_test, InsertAfterRValueCheckReturn) auto iter = sut.insert_after(sut.before_begin(), {DATA}); ASSERT_THAT(iter == sut.begin(), Eq(true)); - ASSERT_THAT((*iter).m_value, Eq(DATA)); + ASSERT_THAT((*iter).value, Eq(DATA)); } TEST_F(forward_list_test, InsertAfterBeginListLValue) @@ -897,11 +812,11 @@ TEST_F(forward_list_test, InsertAfterBeginListLValue) sut.insert_after(sut.begin(), a); ASSERT_THAT(sut.size(), Eq(2U)); - ASSERT_THAT(cTor, Eq(1U)); - ASSERT_THAT(customCTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(1U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); auto iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(iter->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); } @@ -915,11 +830,11 @@ TEST_F(forward_list_test, InsertAfterBeforeBeginListLValue) sut.insert_after(sut.before_begin(), a); ASSERT_THAT(sut.size(), Eq(2U)); - ASSERT_THAT(cTor, Eq(1U)); - ASSERT_THAT(customCTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(1U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); auto iter = sut.begin(); - EXPECT_THAT((*iter).m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((*iter).value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } TEST_F(forward_list_test, InsertAfterBeforeBeginListRValue) @@ -932,11 +847,11 @@ TEST_F(forward_list_test, InsertAfterBeforeBeginListRValue) sut.insert_after(sut.before_begin(), {}); ASSERT_THAT(sut.size(), Eq(2U)); - ASSERT_THAT(cTor, Eq(1U)); - ASSERT_THAT(customCTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(1U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); auto iter = sut.begin(); - EXPECT_THAT((*iter).m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((*iter).value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); } TEST_F(forward_list_test, InsertAfterSomeElementsListLValue) @@ -968,16 +883,16 @@ TEST_F(forward_list_test, InsertAfterSomeElementsListLValue) ASSERT_THAT(sut.size(), Eq(6U)); ASSERT_THAT(loopCounter, Eq(6U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(6U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(6U)); iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(4U)); - EXPECT_THAT((++iter)->m_value, Eq(3U)); - EXPECT_THAT((++iter)->m_value, Eq(2U)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(1U)); - EXPECT_THAT((++iter)->m_value, Eq(0U)); + EXPECT_THAT(iter->value, Eq(4U)); + EXPECT_THAT((++iter)->value, Eq(3U)); + EXPECT_THAT((++iter)->value, Eq(2U)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(1U)); + EXPECT_THAT((++iter)->value, Eq(0U)); } TEST_F(forward_list_test, InsertAfterSomeElementsListRValue) @@ -1001,16 +916,16 @@ TEST_F(forward_list_test, InsertAfterSomeElementsListRValue) sut.insert_after(iter, DEFAULT_VALUE); ASSERT_THAT(sut.size(), Eq(6U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(6U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(6U)); iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(4U)); - EXPECT_THAT((++iter)->m_value, Eq(3U)); - EXPECT_THAT((++iter)->m_value, Eq(2U)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(1U)); - EXPECT_THAT((++iter)->m_value, Eq(0U)); + EXPECT_THAT(iter->value, Eq(4U)); + EXPECT_THAT((++iter)->value, Eq(3U)); + EXPECT_THAT((++iter)->value, Eq(2U)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(1U)); + EXPECT_THAT((++iter)->value, Eq(0U)); } @@ -1033,16 +948,16 @@ TEST_F(forward_list_test, InsertAfterFullElementsListLValue) sut.insert_after(iter, a); ASSERT_THAT(sut.size(), Eq(TESTLISTCAPACITY)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; if (TESTLISTCAPACITY - 1L == cnt) { - // for the last element (insert_after) check for different m_value + // for the last element (insert_after) check for different value cnt = DEFAULT_VALUE; } } @@ -1066,16 +981,16 @@ TEST_F(forward_list_test, InsertAfterFullElementsListRValue) sut.insert_after(iter, DEFAULT_VALUE); ASSERT_THAT(sut.size(), Eq(TESTLISTCAPACITY)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; if (TESTLISTCAPACITY - 1L == cnt) { - // for the last element (insert_after) check for different m_value + // for the last element (insert_after) check for different value cnt = DEFAULT_VALUE; } } @@ -1102,16 +1017,16 @@ TEST_F(forward_list_test, IteratorArrowOperator) sut.insert_after(iter, DEFAULT_VALUE); ASSERT_THAT(sut.size(), Eq(6U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(6U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(6U)); iter = sut.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(4U)); - EXPECT_THAT((++iter)->m_value, Eq(3U)); - EXPECT_THAT((++iter)->m_value, Eq(2U)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(1U)); - EXPECT_THAT((++iter)->m_value, Eq(0U)); + EXPECT_THAT((++iter)->value, Eq(4U)); + EXPECT_THAT((++iter)->value, Eq(3U)); + EXPECT_THAT((++iter)->value, Eq(2U)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(1U)); + EXPECT_THAT((++iter)->value, Eq(0U)); } TEST_F(forward_list_test, IteratorIncrementOperatorBeyondEnd) @@ -1122,7 +1037,7 @@ TEST_F(forward_list_test, IteratorIncrementOperatorBeyondEnd) sut.push_front(DEFAULT_VALUE); auto iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(iter->value, Eq(DEFAULT_VALUE)); EXPECT_TRUE((++iter) == sut.cend()); EXPECT_TRUE((++iter) == sut.cend()); } @@ -1135,7 +1050,7 @@ TEST_F(forward_list_test, ConstIteratorIncrementOperatorBeyondEnd) sut.push_front(DEFAULT_VALUE); auto iter = sut.cbegin(); - EXPECT_THAT(iter->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(iter->value, Eq(DEFAULT_VALUE)); EXPECT_TRUE((++iter) == sut.cend()); EXPECT_TRUE((++iter) == sut.cend()); } @@ -1266,19 +1181,19 @@ TEST_F(forward_list_test, CopyConstructor) constexpr uint32_t ELEMENT2 = 102U; sut11.emplace_front(ELEMENT1); sut11.emplace_front(ELEMENT2); - EXPECT_THAT(customCTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); forward_list sut12(sut11); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(0U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); auto iter = sut12.begin(); - EXPECT_THAT(iter->m_value, Eq(ELEMENT2)); + EXPECT_THAT(iter->value, Eq(ELEMENT2)); ++iter; - EXPECT_THAT(iter->m_value, Eq(ELEMENT1)); + EXPECT_THAT(iter->value, Eq(ELEMENT1)); EXPECT_THAT(sut12.empty(), Eq(false)); EXPECT_THAT(sut12.size(), Eq(2U)); } @@ -1289,7 +1204,7 @@ TEST_F(forward_list_test, CopyConstructorWithEmptyForwardList) forward_list sut11; // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) copy constructor shall be tested forward_list sut12(sut11); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut12.size(), Eq(0U)); EXPECT_THAT(sut12.empty(), Eq(true)); } @@ -1298,7 +1213,7 @@ TEST_F(forward_list_test, CopyConstructorWithFullForwardList) { ::testing::Test::RecordProperty("TEST_ID", "60f40098-0565-4276-810c-86d7e1685f2d"); forward_list sut11; - decltype(TestListElement::m_value) i = 0U; + decltype(TestListElement::value) i = 0U; for (uint64_t i = 0U; i < TESTLISTCAPACITY; ++i) { @@ -1308,11 +1223,11 @@ TEST_F(forward_list_test, CopyConstructorWithFullForwardList) forward_list sut12(sut11); for (auto& listElement : sut12) { - listElement.m_value = i; + listElement.value = i; ++i; } - EXPECT_THAT(copyCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.copyCTor, Eq(TESTLISTCAPACITY)); EXPECT_THAT(i, Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.size(), Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.empty(), Eq(false)); @@ -1329,16 +1244,16 @@ TEST_F(forward_list_test, MoveConstructor) forward_list sut12(std::move(sut11)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(2U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(2U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); auto iter = sut12.begin(); - EXPECT_THAT(iter->m_value, Eq(ELEMENT2)); - EXPECT_THAT((++iter)->m_value, Eq(ELEMENT1)); + EXPECT_THAT(iter->value, Eq(ELEMENT2)); + EXPECT_THAT((++iter)->value, Eq(ELEMENT1)); EXPECT_THAT(sut12.empty(), Eq(false)); EXPECT_THAT(sut12.size(), Eq(2U)); // NOLINTJUSTIFICATION we explicitly want to test the defined state of a moved object @@ -1351,9 +1266,9 @@ TEST_F(forward_list_test, MoveConstructorWithEmptyForwardList) ::testing::Test::RecordProperty("TEST_ID", "a4b0fa37-fd3d-424a-9564-6c13f4eb4593"); forward_list sut11; forward_list sut12(std::move(sut11)); - EXPECT_THAT(moveCTor, Eq(0U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); EXPECT_THAT(sut12.size(), Eq(0U)); EXPECT_THAT(sut12.empty(), Eq(true)); } @@ -1369,10 +1284,10 @@ TEST_F(forward_list_test, MoveConstructorWithFullForwardList) forward_list sut12(std::move(sut11)); - EXPECT_THAT(moveCTor, Eq(TESTLISTCAPACITY)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.moveCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.size(), Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.empty(), Eq(false)); } @@ -1383,7 +1298,7 @@ TEST_F(forward_list_test, DestructorWithEmptyForwardList) { forward_list sut11; } - EXPECT_THAT(dTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(0U)); } TEST_F(forward_list_test, DestructorSomeElements) @@ -1395,10 +1310,10 @@ TEST_F(forward_list_test, DestructorSomeElements) sut11.emplace_front(9191U); sut11.emplace_front(1U); } - EXPECT_THAT(cTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(3U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); } TEST_F(forward_list_test, DestructorWithFullForwardList) @@ -1412,9 +1327,9 @@ TEST_F(forward_list_test, DestructorWithFullForwardList) } } - EXPECT_THAT(dTor, Eq(TESTLISTCAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); } TEST_F(forward_list_test, CopyAssignmentWithEmptySource) @@ -1427,11 +1342,11 @@ TEST_F(forward_list_test, CopyAssignmentWithEmptySource) sut11.emplace_front(8132U); sut11 = sut12; - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(sut11.empty(), Eq(true)); } @@ -1449,16 +1364,16 @@ TEST_F(forward_list_test, CopyAssignmentWithEmptyDestination) sut11.emplace_front(ELEMENT3); sut12 = sut11; - EXPECT_THAT(dTor, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(3U)); EXPECT_THAT(sut12.size(), Eq(3U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(ELEMENT3)); - EXPECT_THAT((++iter)->m_value, Eq(ELEMENT2)); - EXPECT_THAT((++iter)->m_value, Eq(ELEMENT1)); + EXPECT_THAT((++iter)->value, Eq(ELEMENT3)); + EXPECT_THAT((++iter)->value, Eq(ELEMENT2)); + EXPECT_THAT((++iter)->value, Eq(ELEMENT1)); } @@ -1477,15 +1392,15 @@ TEST_F(forward_list_test, CopyAssignmentWithLargerDestination) sut11 = sut12; - EXPECT_THAT(dTor, Eq(2U)); - EXPECT_THAT(copyAssignment, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); + EXPECT_THAT(stats.copyAssignment, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(2U)); EXPECT_THAT(sut11.empty(), Eq(false)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(3131U)); - EXPECT_THAT((++iter)->m_value, Eq(313U)); + EXPECT_THAT((++iter)->value, Eq(3131U)); + EXPECT_THAT((++iter)->value, Eq(313U)); } TEST_F(forward_list_test, CopyAssignmentWithLargerSource) @@ -1503,17 +1418,17 @@ TEST_F(forward_list_test, CopyAssignmentWithLargerSource) sut12 = sut11; - EXPECT_THAT(dTor, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(2U)); EXPECT_THAT(sut12.size(), Eq(4U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } @@ -1528,9 +1443,9 @@ TEST_F(forward_list_test, MoveAssignmentWithEmptySource) sut11 = std::move(sut12); - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(sut11.empty(), Eq(true)); } @@ -1546,20 +1461,20 @@ TEST_F(forward_list_test, MoveAssignmentWithEmptyDestination) sut12 = std::move(sut11); - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(3U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(3U)); EXPECT_THAT(sut12.size(), Eq(3U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(58132U)); - EXPECT_THAT((++iter)->m_value, Eq(581122U)); - EXPECT_THAT((++iter)->m_value, Eq(5812U)); + EXPECT_THAT((++iter)->value, Eq(58132U)); + EXPECT_THAT((++iter)->value, Eq(581122U)); + EXPECT_THAT((++iter)->value, Eq(5812U)); } @@ -1578,15 +1493,15 @@ TEST_F(forward_list_test, MoveAssignmentWithLargerDestination) sut11 = std::move(sut12); - EXPECT_THAT(dTor, Eq(4U)); - EXPECT_THAT(moveAssignment, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(4U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(2U)); EXPECT_THAT(sut11.empty(), Eq(false)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(3131U)); - EXPECT_THAT((++iter)->m_value, Eq(313U)); + EXPECT_THAT((++iter)->value, Eq(3131U)); + EXPECT_THAT((++iter)->value, Eq(313U)); } TEST_F(forward_list_test, MoveAssignmentWithLargerSource) @@ -1604,18 +1519,18 @@ TEST_F(forward_list_test, MoveAssignmentWithLargerSource) sut12 = std::move(sut11); - EXPECT_THAT(dTor, Eq(4U)); - EXPECT_THAT(moveAssignment, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(4U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(2U)); EXPECT_THAT(sut12.size(), Eq(4U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveDefaultElementFromEmptyList) @@ -1623,9 +1538,9 @@ TEST_F(forward_list_test, RemoveDefaultElementFromEmptyList) ::testing::Test::RecordProperty("TEST_ID", "ad425b66-2e2a-4ff7-b338-ae9d86b97ca9"); auto cnt = sut.remove({}); - EXPECT_THAT(cTor, Eq(1U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(0U)); } @@ -1634,9 +1549,9 @@ TEST_F(forward_list_test, RemoveCustomElementFromEmptyList) ::testing::Test::RecordProperty("TEST_ID", "43a46355-3fc5-42dd-ae88-db28f1e6dcba"); auto cnt = sut.remove({10U}); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(0U)); } @@ -1653,17 +1568,17 @@ TEST_F(forward_list_test, RemoveOneDefaultElementFromList) auto cnt = sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(4U)); EXPECT_THAT(cnt, Eq(2U)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveOneCustomElementFromList) { @@ -1678,18 +1593,18 @@ TEST_F(forward_list_test, RemoveOneCustomElementFromList) auto cnt = sut11.remove({1584122U}); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(5U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(5U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(5U)); EXPECT_THAT(cnt, Eq(1U)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveNotExistentElementFromList) { @@ -1704,20 +1619,20 @@ TEST_F(forward_list_test, RemoveNotExistentElementFromList) auto cnt = sut11.remove({1243U}); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(5U)); - EXPECT_THAT(dTor, Eq(1U)); - EXPECT_THAT(classValue, Eq(1243U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(5U)); + EXPECT_THAT(stats.dTor, Eq(1U)); + EXPECT_THAT(stats.classValue, Eq(1243U)); EXPECT_THAT(sut11.size(), Eq(6U)); EXPECT_THAT(cnt, Eq(0U)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveOnetoEmptyList) @@ -1728,9 +1643,9 @@ TEST_F(forward_list_test, RemoveOnetoEmptyList) auto cnt = sut11.remove({15842U}); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(1U)); } @@ -1745,9 +1660,9 @@ TEST_F(forward_list_test, RemoveWithFewMatches) auto cnt = sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(1U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -1761,9 +1676,9 @@ TEST_F(forward_list_test, RemoveWithAllMatches) auto cnt = sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -1780,9 +1695,9 @@ TEST_F(forward_list_test, RemoveAllFromList) auto cnt = sut11.remove({ELEMENT}); cnt += sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(dTor, Eq(5U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(5U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(3U)); } @@ -1811,20 +1726,20 @@ TEST_F(forward_list_test, RemoveIfOneDefaultElementFromList) sut11.emplace_front(158432U); auto cnt = - sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(2U)); - EXPECT_THAT(classValue, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(2U)); + EXPECT_THAT(stats.classValue, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); EXPECT_THAT(sut11.size(), Eq(4U)); EXPECT_THAT(cnt, Eq(2U)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveIfOneCustomElementFromList) @@ -1838,20 +1753,20 @@ TEST_F(forward_list_test, RemoveIfOneCustomElementFromList) sut11.emplace_front(158432U); sut11.emplace_front(158432U); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 1584122U; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 1584122U; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut11.size(), Eq(5U)); EXPECT_THAT(cnt, Eq(1U)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveIfNotExistentElementFromList) @@ -1865,21 +1780,21 @@ TEST_F(forward_list_test, RemoveIfNotExistentElementFromList) sut11.emplace_front(158432U); sut11.emplace_front(158432U); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 1234U; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 1234U; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(6U)); EXPECT_THAT(cnt, Eq(0U)); auto iter = sut11.cbefore_begin(); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(forward_list_test, RemoveIfOnetoEmptyList) @@ -1888,11 +1803,11 @@ TEST_F(forward_list_test, RemoveIfOnetoEmptyList) forward_list sut11; sut11.emplace_front(15842U); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 15842U; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 15842U; }); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(1U)); } @@ -1906,11 +1821,11 @@ TEST_F(forward_list_test, RemoveIfWithFewMatches) sut11.emplace_front(); auto cnt = - sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(1U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -1923,11 +1838,11 @@ TEST_F(forward_list_test, RemoveIfWithAllMatches) sut11.emplace_front(); auto cnt = - sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -1940,12 +1855,12 @@ TEST_F(forward_list_test, RemoveIfAllFromList) sut11.emplace_front(); sut11.emplace_front(); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 15842U; }); - cnt += sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 15842U; }); + cnt += sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(3U)); } @@ -1964,7 +1879,7 @@ TEST_F(forward_list_test, writeContentViaDereferencedIterator) auto iter = sut1.begin(); TestListElement element{TEST_VALUE}; *iter = element; - EXPECT_THAT(sut1.front().m_value, Eq(TEST_VALUE)); + EXPECT_THAT(sut1.front().value, Eq(TEST_VALUE)); } TEST_F(forward_list_test, invalidIteratorErase) @@ -2056,7 +1971,7 @@ TEST_F(forward_list_test, invalidIteratorAddressOfOperator) auto iter = sut.cbegin(); sut.pop_front(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->m_value == 12U); }, + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->value == 12U); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); } @@ -2096,6 +2011,6 @@ TEST_F(forward_list_test, ListIsCopyableViaMemcpy) for (auto& listElement : *reinterpret_cast(otherSutPtr)) { --i; - EXPECT_THAT(listElement.m_value, Eq(i)); + EXPECT_THAT(listElement.value, Eq(i)); } } From f45b9ade1caacf282d7d43b967efb16be9c1c5ee Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sun, 15 Oct 2023 21:29:32 +0200 Subject: [PATCH 3/4] iox-#2041 Port 'list' tests to 'iox::testing::CTorAndAssignmentOperatorTestClass' --- .../test/moduletests/test_cxx_list.cpp | 781 ++++++++---------- 1 file changed, 346 insertions(+), 435 deletions(-) diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_list.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_list.cpp index 0ef25e3a7a..725a95a903 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_list.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_list.cpp @@ -17,6 +17,7 @@ #include "iceoryx_hoofs/cxx/list.hpp" #include "iceoryx_hoofs/error_handling/error_handling.hpp" +#include "iceoryx_hoofs/testing/ctor_and_assignment_operator_test_class.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" #include "iox/attributes.hpp" #include "iox/logging.hpp" @@ -35,122 +36,32 @@ constexpr int64_t TEST_LIST_ELEMENT_DEFAULT_VALUE{-99L}; class list_test : public Test { public: - static uint64_t cTor; - static uint64_t customCTor; - static uint64_t copyCTor; - static uint64_t moveCTor; - static uint64_t moveAssignment; - static uint64_t copyAssignment; - static uint64_t dTor; - static int64_t classValue; - - class TestListElement - { - public: - TestListElement() - { - cTor++; - classValue = m_value; - } - - /// @NOLINTJUSTIFICATION only used in tests - /// @NOLINTNEXTLINE(hicpp-explicit-conversions) - TestListElement(const int64_t value) - : m_value(value) - { - customCTor++; - classValue = m_value; - } - - TestListElement(const TestListElement& rhs) - : m_value{rhs.m_value} - { - copyCTor++; - classValue = m_value; - } - - TestListElement(TestListElement&& rhs) noexcept - : m_value{rhs.m_value} - { - moveCTor++; - classValue = m_value; - } - - TestListElement& operator=(const TestListElement& rhs) - { - if (this != &rhs) - { - copyAssignment++; - m_value = rhs.m_value; - classValue = m_value; - } - return *this; - } - - TestListElement& operator=(TestListElement&& rhs) noexcept - { - if (this != &rhs) - { - moveAssignment++; - m_value = rhs.m_value; - classValue = m_value; - } - return *this; - } - - bool operator==(const TestListElement& rhs) const - { - return rhs.m_value == m_value; - } - - ~TestListElement() - { - dTor++; - classValue = m_value; - } - - int64_t m_value = TEST_LIST_ELEMENT_DEFAULT_VALUE; - }; - + using TestListElement = CTorAndAssignmentOperatorTestClass; void SetUp() override { - cTor = 0U; - customCTor = 0U; - copyCTor = 0U; - moveCTor = 0U; - moveAssignment = 0U; - copyAssignment = 0U; - dTor = 0U; - classValue = 0U; + stats.reset(); } + TestListElement::Statistics& stats = TestListElement::stats; + static bool isSetupState() { - return (cTor == 0U && customCTor == 0U && copyCTor == 0U && moveCTor == 0U && moveAssignment == 0U - && copyAssignment == 0U && dTor == 0U && classValue == 0U); + TestListElement::Statistics& stats = TestListElement::stats; + return (stats.cTor == 0U && stats.customCTor == 0U && stats.copyCTor == 0U && stats.moveCTor == 0U + && stats.moveAssignment == 0U && stats.copyAssignment == 0U && stats.dTor == 0U + && stats.classValue == 0); } list sut; }; -// list_test statics -uint64_t list_test::cTor; -uint64_t list_test::customCTor; -uint64_t list_test::copyCTor; -uint64_t list_test::moveCTor; -uint64_t list_test::moveAssignment; -uint64_t list_test::copyAssignment; -uint64_t list_test::dTor; -int64_t list_test::classValue; - - template int64_t iteratorTraitReturnDoubleValue(IterType iter) { typedef typename std::iterator_traits::value_type IterValueType; - IterValueType m_value = *iter; - return (2 * m_value); // will only work for integer-convertible m_value types + IterValueType value = *iter; + return (2 * value); // will only work for integer-convertible value types } } // namespace @@ -213,7 +124,7 @@ TEST_F(list_test, BeginCendAreTheSameWhenEmpty) TEST_F(list_test, CbeginCendAreDifferentWhenFilled) { ::testing::Test::RecordProperty("TEST_ID", "b355ea2c-9662-40c1-992b-a6c1c01d94ec"); - EXPECT_THAT(sut.emplace_front().m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(sut.emplace_front().value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); EXPECT_THAT(sut.cbegin() != sut.cend(), Eq(true)); } TEST_F(list_test, BeginEndAreDifferentWhenFilled) @@ -259,7 +170,7 @@ TEST_F(list_test, FullWhenFilledWithCapacityElements) ::testing::Test::RecordProperty("TEST_ID", "52b993fb-ff52-4ef9-8626-61cb4049c2e3"); for (uint64_t i = 0U; i < sut.capacity(); ++i) { - EXPECT_THAT(sut.emplace_front().m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(sut.emplace_front().value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } EXPECT_THAT(sut.full(), Eq(true)); } @@ -322,14 +233,14 @@ TEST_F(list_test, CTorWithOneElements) constexpr uint64_t ELEMENT_COUNT{1U}; list sut1; - EXPECT_THAT(cTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { sut1.emplace_front(); } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, CustomCTorWithOneElements) @@ -346,9 +257,9 @@ TEST_F(list_test, CustomCTorWithOneElements) } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); - EXPECT_THAT(classValue, Eq(DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.classValue, Eq(DEFAULT_VALUE)); } TEST_F(list_test, CTorWithSomeElements) @@ -364,7 +275,7 @@ TEST_F(list_test, CTorWithSomeElements) } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, CTorWithCapacityElements) @@ -380,7 +291,7 @@ TEST_F(list_test, CTorWithCapacityElements) } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, CTorWithMoreThanCapacityElements) @@ -397,8 +308,8 @@ TEST_F(list_test, CTorWithMoreThanCapacityElements) sut1.emplace(sut1.cbegin(), 2U); EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(CAPACITY)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(CAPACITY)); + EXPECT_THAT(stats.customCTor, Eq(0U)); } @@ -409,10 +320,10 @@ TEST_F(list_test, EmplaceWithOneElements) constexpr uint64_t ELEMENT_COUNT{1U}; list sut1; auto iter = sut1.begin(); - decltype(TestListElement::m_value) cnt = 0U; + decltype(TestListElement::value) cnt = 0U; - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -423,12 +334,12 @@ TEST_F(list_test, EmplaceWithOneElements) for (auto& listElement : sut1) { --cnt; - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, EmplaceWithSomeElements) @@ -440,8 +351,8 @@ TEST_F(list_test, EmplaceWithSomeElements) auto iter = sut1.cbegin(); int64_t cnt = 0; - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -452,12 +363,12 @@ TEST_F(list_test, EmplaceWithSomeElements) for (auto& listElement : sut1) { --cnt; - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, EmplaceWithCapacityElements) @@ -478,12 +389,12 @@ TEST_F(list_test, EmplaceWithCapacityElements) for (auto& listElement : sut1) { --cnt; - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, EmplaceWithMoreThanCapacityElements) @@ -505,12 +416,12 @@ TEST_F(list_test, EmplaceWithMoreThanCapacityElements) for (auto& listElement : sut1) { --cnt; - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); } EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(CAPACITY)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(CAPACITY)); } @@ -532,13 +443,13 @@ TEST_F(list_test, EmplaceReverseWithOneElements) cnt = 0; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, EmplaceReverseWithSomeElements) @@ -559,13 +470,13 @@ TEST_F(list_test, EmplaceReverseWithSomeElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, EmplaceReverseWithCapacityElements) @@ -586,13 +497,13 @@ TEST_F(list_test, EmplaceReverseWithCapacityElements) cnt = 0; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT)); } TEST_F(list_test, EmplaceReverseWithWithMoreThanCapacityElements) @@ -613,13 +524,13 @@ TEST_F(list_test, EmplaceReverseWithWithMoreThanCapacityElements) cnt = 0; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(CAPACITY)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(CAPACITY)); } @@ -630,10 +541,10 @@ TEST_F(list_test, EmplaceBackWithOneElements) constexpr uint64_t ELEMENT_COUNT{1U}; list sut1; // TestListElement compareElement{}; - decltype(TestListElement::m_value) cnt = 0U; + decltype(TestListElement::value) cnt = 0U; - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -644,13 +555,13 @@ TEST_F(list_test, EmplaceBackWithOneElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT * 2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT * 2U)); } TEST_F(list_test, EmplaceBackWithSomeElements) @@ -659,10 +570,10 @@ TEST_F(list_test, EmplaceBackWithSomeElements) constexpr uint64_t CAPACITY{42U}; constexpr uint64_t ELEMENT_COUNT{37U}; list sut1; - decltype(TestListElement::m_value) cnt = 0U; + decltype(TestListElement::value) cnt = 0U; - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -673,13 +584,13 @@ TEST_F(list_test, EmplaceBackWithSomeElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT * 2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT * 2U)); } TEST_F(list_test, EmplaceBackWithCapacityElements) @@ -688,7 +599,7 @@ TEST_F(list_test, EmplaceBackWithCapacityElements) constexpr uint64_t CAPACITY{42U}; constexpr uint64_t ELEMENT_COUNT{CAPACITY}; list sut1; - decltype(TestListElement::m_value) cnt = 0U; + decltype(TestListElement::value) cnt = 0U; for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -699,13 +610,13 @@ TEST_F(list_test, EmplaceBackWithCapacityElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(ELEMENT_COUNT)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(ELEMENT_COUNT * 2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(ELEMENT_COUNT * 2U)); } TEST_F(list_test, EmplaceBackWithMoreThanCapacityElements) @@ -714,7 +625,7 @@ TEST_F(list_test, EmplaceBackWithMoreThanCapacityElements) constexpr uint64_t CAPACITY{42U}; constexpr uint64_t ELEMENT_COUNT{CAPACITY + 1U}; list sut1; - decltype(TestListElement::m_value) cnt = 0U; + decltype(TestListElement::value) cnt = 0U; for (uint64_t i = 0U; i < ELEMENT_COUNT; ++i) { @@ -733,13 +644,13 @@ TEST_F(list_test, EmplaceBackWithMoreThanCapacityElements) cnt = 0U; for (auto& listElement : sut1) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; } EXPECT_THAT(sut1.size(), Eq(CAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(CAPACITY * 2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(CAPACITY * 2U)); } TEST_F(list_test, EmplaceWithWrongListIterator) @@ -770,9 +681,9 @@ TEST_F(list_test, PushFrontConstCustomSuccessfullWhenSpaceAvailableLValue) const TestListElement a{DEFAULT_VALUE}; EXPECT_TRUE(sut.push_front(a)); ASSERT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT((*sut.begin()).value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, PushFrontConstSuccessfullWhenSpaceAvailableLValue) @@ -781,9 +692,9 @@ TEST_F(list_test, PushFrontConstSuccessfullWhenSpaceAvailableLValue) const TestListElement a{}; EXPECT_TRUE(sut.push_front(a)); ASSERT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT(cTor, Eq(1U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT((*sut.begin()).value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } TEST_F(list_test, PushFrontFailsWhenSpaceNotAvailableLValue) @@ -811,7 +722,7 @@ TEST_F(list_test, PushFrontSuccessfullWhenSpaceAvailableRValue) sut.push_front(DEFAULT_VALUE); EXPECT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((*sut.begin()).value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, PushFrontFailsWhenSpaceNotAvailableRValue) @@ -831,7 +742,7 @@ TEST_F(list_test, PushFrontFailsWhenSpaceNotAvailableRValue) for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(listElement.value, Eq(DEFAULT_VALUE)); } } @@ -843,9 +754,9 @@ TEST_F(list_test, PushBackConstCustomSuccessfullWhenSpaceAvailableLValue) const TestListElement a{DEFAULT_VALUE}; EXPECT_TRUE(sut.push_back(a)); ASSERT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT((*sut.begin()).value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, PushBackConstSuccessfullWhenSpaceAvailableLValue) @@ -854,9 +765,9 @@ TEST_F(list_test, PushBackConstSuccessfullWhenSpaceAvailableLValue) const TestListElement a{}; EXPECT_TRUE(sut.push_back(a)); ASSERT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT(cTor, Eq(1U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT((*sut.begin()).value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } TEST_F(list_test, PushBackFailsWhenSpaceNotAvailableLValue) @@ -884,7 +795,7 @@ TEST_F(list_test, PushBackSuccessfullWhenSpaceAvailableRValue) sut.push_back(DEFAULT_VALUE); EXPECT_THAT(sut.size(), Eq(1U)); - EXPECT_THAT((*sut.begin()).m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((*sut.begin()).value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, PushBackFailsWhenSpaceNotAvailableRValue) @@ -906,7 +817,7 @@ TEST_F(list_test, PushBackFailsWhenSpaceNotAvailableRValue) for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(listElement.value, Eq(DEFAULT_VALUE)); } } @@ -923,7 +834,7 @@ TEST_F(list_test, PushBackCheckInsertPosition) counter = 0; for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(counter)); + EXPECT_THAT(listElement.value, Eq(counter)); ++counter; } } @@ -939,8 +850,8 @@ TEST_F(list_test, AccessFrontElement) TestListElement& b{sut.front()}; const TestListElement& c{sut.front()}; - EXPECT_THAT(b.m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT(c.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(b.value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(c.value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, AccessFrontElementFromConstList) @@ -955,7 +866,7 @@ TEST_F(list_test, AccessFrontElementFromConstList) const list sut1{sut}; const TestListElement& c = sut1.front(); - EXPECT_THAT(c.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(c.value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, AccessBackElement) @@ -969,8 +880,8 @@ TEST_F(list_test, AccessBackElement) TestListElement& b{sut.back()}; const TestListElement& c{sut.back()}; - EXPECT_THAT(b.m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT(c.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(b.value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(c.value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, AccessBackElementFromConstList) @@ -985,7 +896,7 @@ TEST_F(list_test, AccessBackElementFromConstList) const list sut1{sut}; const TestListElement& c = sut1.back(); - EXPECT_THAT(c.m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(c.value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, PopFrontOnEmptyList) @@ -1005,9 +916,9 @@ TEST_F(list_test, PopFrontNonEmptyList) EXPECT_TRUE(sut.pop_front()); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(dTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.dTor, Eq(1U)); } TEST_F(list_test, PopFrontFullToEmptyList) @@ -1026,8 +937,8 @@ TEST_F(list_test, PopFrontFullToEmptyList) } ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(TESTLISTCAPACITY)); - ASSERT_THAT(dTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); } TEST_F(list_test, PopFrontFullPlusOneToEmptyList) @@ -1048,9 +959,9 @@ TEST_F(list_test, PopFrontFullPlusOneToEmptyList) EXPECT_FALSE(sut.pop_front()); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(TESTLISTCAPACITY)); - ASSERT_THAT(customCTor, Eq(0U)); - ASSERT_THAT(dTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.customCTor, Eq(0U)); + ASSERT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); } @@ -1071,9 +982,9 @@ TEST_F(list_test, PopBackNonEmptyList) EXPECT_TRUE(sut.pop_back()); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(dTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.dTor, Eq(1U)); } TEST_F(list_test, PopBackFullToEmptyList) @@ -1093,8 +1004,8 @@ TEST_F(list_test, PopBackFullToEmptyList) } ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(TESTLISTCAPACITY)); - ASSERT_THAT(dTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); } TEST_F(list_test, PopBackFullPlusOneToEmptyList) @@ -1116,9 +1027,9 @@ TEST_F(list_test, PopBackFullPlusOneToEmptyList) EXPECT_FALSE(sut.pop_back()); ASSERT_THAT(sut.size(), Eq(0U)); - ASSERT_THAT(cTor, Eq(TESTLISTCAPACITY)); - ASSERT_THAT(customCTor, Eq(0U)); - ASSERT_THAT(dTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.customCTor, Eq(0U)); + ASSERT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); } @@ -1131,12 +1042,12 @@ TEST_F(list_test, InsertEmptyListAsLValue) sut.insert(sut.cbegin(), a); ASSERT_THAT(sut.size(), Eq(1U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(copyCTor, Eq(1U)); - ASSERT_THAT(moveCTor, Eq(0U)); - ASSERT_THAT(copyAssignment, Eq(0U)); - ASSERT_THAT(moveAssignment, Eq(0U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.copyCTor, Eq(1U)); + ASSERT_THAT(stats.moveCTor, Eq(0U)); + ASSERT_THAT(stats.copyAssignment, Eq(0U)); + ASSERT_THAT(stats.moveAssignment, Eq(0U)); } TEST_F(list_test, InsertLValueCheckReturn) @@ -1156,12 +1067,12 @@ TEST_F(list_test, InsertEmptyListAsRValue) sut.insert(sut.begin(), {10U}); ASSERT_THAT(sut.size(), Eq(1U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(1U)); - ASSERT_THAT(copyCTor, Eq(0U)); - ASSERT_THAT(moveCTor, Eq(1U)); - ASSERT_THAT(copyAssignment, Eq(0U)); - ASSERT_THAT(moveAssignment, Eq(0U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); + ASSERT_THAT(stats.copyCTor, Eq(0U)); + ASSERT_THAT(stats.moveCTor, Eq(1U)); + ASSERT_THAT(stats.copyAssignment, Eq(0U)); + ASSERT_THAT(stats.moveAssignment, Eq(0U)); } TEST_F(list_test, InsertRValueCheckReturn) @@ -1170,7 +1081,7 @@ TEST_F(list_test, InsertRValueCheckReturn) auto iter = sut.insert(sut.begin(), {10U}); ASSERT_THAT(iter == sut.begin(), Eq(true)); - ASSERT_THAT((*iter).m_value, Eq(10U)); + ASSERT_THAT((*iter).value, Eq(10U)); } TEST_F(list_test, InsertBeginListLValue) @@ -1183,11 +1094,11 @@ TEST_F(list_test, InsertBeginListLValue) sut.emplace_front(); ASSERT_THAT(sut.size(), Eq(2U)); - ASSERT_THAT(cTor, Eq(1U)); - ASSERT_THAT(customCTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(1U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); auto iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(iter->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); } @@ -1201,11 +1112,11 @@ TEST_F(list_test, InsertBeforeBeginListLValue) sut.insert(sut.begin(), a); ASSERT_THAT(sut.size(), Eq(2U)); - ASSERT_THAT(cTor, Eq(1U)); - ASSERT_THAT(customCTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(1U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); auto iter = sut.begin(); - EXPECT_THAT((*iter).m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((*iter).value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); } TEST_F(list_test, InsertBeforeBeginListRValue) @@ -1218,11 +1129,11 @@ TEST_F(list_test, InsertBeforeBeginListRValue) sut.insert(sut.begin(), {}); ASSERT_THAT(sut.size(), Eq(2U)); - ASSERT_THAT(cTor, Eq(1U)); - ASSERT_THAT(customCTor, Eq(1U)); + ASSERT_THAT(stats.cTor, Eq(1U)); + ASSERT_THAT(stats.customCTor, Eq(1U)); auto iter = sut.begin(); - EXPECT_THAT((*iter).m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((*iter).value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); } TEST_F(list_test, InsertSomeElementsListLValue) @@ -1257,16 +1168,16 @@ TEST_F(list_test, InsertSomeElementsListLValue) ASSERT_THAT(sut.size(), Eq(6U)); ASSERT_THAT(loopCounter, Eq(6U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(6U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(6U)); iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(4U)); - EXPECT_THAT((++iter)->m_value, Eq(3U)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(2U)); - EXPECT_THAT((++iter)->m_value, Eq(1U)); - EXPECT_THAT((++iter)->m_value, Eq(0U)); + EXPECT_THAT(iter->value, Eq(4U)); + EXPECT_THAT((++iter)->value, Eq(3U)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(2U)); + EXPECT_THAT((++iter)->value, Eq(1U)); + EXPECT_THAT((++iter)->value, Eq(0U)); } TEST_F(list_test, InsertSomeElementsListRValue) @@ -1293,16 +1204,16 @@ TEST_F(list_test, InsertSomeElementsListRValue) sut.insert(iter, DEFAULT_VALUE); ASSERT_THAT(sut.size(), Eq(6U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(6U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(6U)); iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(4U)); - EXPECT_THAT((++iter)->m_value, Eq(3U)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(2U)); - EXPECT_THAT((++iter)->m_value, Eq(1U)); - EXPECT_THAT((++iter)->m_value, Eq(0U)); + EXPECT_THAT(iter->value, Eq(4U)); + EXPECT_THAT((++iter)->value, Eq(3U)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(2U)); + EXPECT_THAT((++iter)->value, Eq(1U)); + EXPECT_THAT((++iter)->value, Eq(0U)); } @@ -1325,16 +1236,16 @@ TEST_F(list_test, InsertFullElementsListLValue) sut.insert(iter, a); ASSERT_THAT(sut.size(), Eq(TESTLISTCAPACITY)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; if (TESTLISTCAPACITY - 1L == cnt) { - // for the last element (insert) check for different m_value + // for the last element (insert) check for different value cnt = DEFAULT_VALUE; } } @@ -1358,16 +1269,16 @@ TEST_F(list_test, InsertFullElementsListRValue) sut.insert(iter, DEFAULT_VALUE); ASSERT_THAT(sut.size(), Eq(TESTLISTCAPACITY)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); for (auto& listElement : sut) { - EXPECT_THAT(listElement.m_value, Eq(cnt)); + EXPECT_THAT(listElement.value, Eq(cnt)); ++cnt; if (TESTLISTCAPACITY - 1L == cnt) { - // for the last element (insert) check for different m_value + // for the last element (insert) check for different value cnt = DEFAULT_VALUE; } } @@ -1396,16 +1307,16 @@ TEST_F(list_test, IteratorArrowOperator) sut.insert(iter, DEFAULT_VALUE); ASSERT_THAT(sut.size(), Eq(6U)); - ASSERT_THAT(cTor, Eq(0U)); - ASSERT_THAT(customCTor, Eq(6U)); + ASSERT_THAT(stats.cTor, Eq(0U)); + ASSERT_THAT(stats.customCTor, Eq(6U)); iter = sut.cbegin(); - EXPECT_THAT(iter->m_value, Eq(4U)); - EXPECT_THAT((++iter)->m_value, Eq(3U)); - EXPECT_THAT((++iter)->m_value, Eq(DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(2U)); - EXPECT_THAT((++iter)->m_value, Eq(1U)); - EXPECT_THAT((++iter)->m_value, Eq(0U)); + EXPECT_THAT(iter->value, Eq(4U)); + EXPECT_THAT((++iter)->value, Eq(3U)); + EXPECT_THAT((++iter)->value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(2U)); + EXPECT_THAT((++iter)->value, Eq(1U)); + EXPECT_THAT((++iter)->value, Eq(0U)); } TEST_F(list_test, IteratorIncrementOperatorBeyondEnd) @@ -1416,7 +1327,7 @@ TEST_F(list_test, IteratorIncrementOperatorBeyondEnd) sut.push_front(DEFAULT_VALUE); auto iter = sut.begin(); - EXPECT_THAT(iter->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(iter->value, Eq(DEFAULT_VALUE)); EXPECT_TRUE((++iter) == sut.cend()); EXPECT_TRUE((++iter) == sut.cend()); } @@ -1429,7 +1340,7 @@ TEST_F(list_test, ConstIteratorIncrementOperatorBeyondEnd) sut.push_front(DEFAULT_VALUE); auto iter = sut.cbegin(); - EXPECT_THAT(iter->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT(iter->value, Eq(DEFAULT_VALUE)); EXPECT_TRUE((++iter) == sut.cend()); EXPECT_TRUE((++iter) == sut.cend()); } @@ -1442,7 +1353,7 @@ TEST_F(list_test, IteratorDecrementOperatorBeyondBegin) sut.push_front(DEFAULT_VALUE); auto iter = sut.end(); - EXPECT_THAT((--iter)->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((--iter)->value, Eq(DEFAULT_VALUE)); EXPECT_TRUE((--iter) == sut.cbegin()); EXPECT_TRUE((--iter) == sut.cbegin()); } @@ -1455,7 +1366,7 @@ TEST_F(list_test, ConstIteratorDecrementOperatorBeyondBegin) sut.push_front(DEFAULT_VALUE); auto iter = sut.cend(); - EXPECT_THAT((--iter)->m_value, Eq(DEFAULT_VALUE)); + EXPECT_THAT((--iter)->value, Eq(DEFAULT_VALUE)); EXPECT_TRUE((--iter) == sut.cbegin()); EXPECT_TRUE((--iter) == sut.cbegin()); } @@ -1471,7 +1382,7 @@ TEST_F(list_test, IteratorDecrementOperatorBeyondBeginWithFullList) auto iter = sut.end(); for (uint64_t i = 0U; i < sut.capacity(); ++i) { - EXPECT_THAT((--iter)->m_value, Eq(i)); + EXPECT_THAT((--iter)->value, Eq(i)); } EXPECT_TRUE((iter) == sut.cbegin()); EXPECT_TRUE((--iter) == sut.cbegin()); @@ -1601,18 +1512,18 @@ TEST_F(list_test, CopyConstructor) list sut11; sut11.emplace_front(101U); sut11.emplace_front(102); - EXPECT_THAT(customCTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); list sut12(sut11); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(0U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); auto iter = sut12.begin(); - EXPECT_THAT(iter->m_value, Eq(102)); - EXPECT_THAT((++iter)->m_value, Eq(101U)); + EXPECT_THAT(iter->value, Eq(102)); + EXPECT_THAT((++iter)->value, Eq(101U)); EXPECT_THAT(sut12.empty(), Eq(false)); EXPECT_THAT(sut12.size(), Eq(2U)); } @@ -1624,7 +1535,7 @@ TEST_F(list_test, CopyConstructorWithEmptyList) /// @NOLINTJUSTIFICATION the test should explicitly test the copy constructor /// @NOLINTNEXTLINE(performance-unnecessary-copy-initialization) list sut12(sut11); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut12.size(), Eq(0U)); EXPECT_THAT(sut12.empty(), Eq(true)); } @@ -1633,7 +1544,7 @@ TEST_F(list_test, CopyConstructorWithFullList) { ::testing::Test::RecordProperty("TEST_ID", "674ac8f0-3bb5-47e4-afd9-30f0bcaf6b55"); list sut11; - decltype(TestListElement::m_value) i = 0U; + decltype(TestListElement::value) i = 0U; for (uint64_t i = 0U; i < TESTLISTCAPACITY; ++i) { @@ -1643,11 +1554,11 @@ TEST_F(list_test, CopyConstructorWithFullList) list sut12(sut11); for (auto& listElement : sut12) { - listElement.m_value = i; + listElement.value = i; ++i; } - EXPECT_THAT(copyCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.copyCTor, Eq(TESTLISTCAPACITY)); EXPECT_THAT(i, Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.size(), Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.empty(), Eq(false)); @@ -1662,16 +1573,16 @@ TEST_F(list_test, MoveConstructor) list sut12(std::move(sut11)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(2U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(2U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); auto iter = sut12.begin(); - EXPECT_THAT(iter->m_value, Eq(8102)); - EXPECT_THAT((++iter)->m_value, Eq(8101U)); + EXPECT_THAT(iter->value, Eq(8102)); + EXPECT_THAT((++iter)->value, Eq(8101U)); EXPECT_THAT(sut12.empty(), Eq(false)); EXPECT_THAT(sut12.size(), Eq(2U)); // NOLINTJUSTIFICATION we explicitly want to test the defined state of a moved object @@ -1684,9 +1595,9 @@ TEST_F(list_test, MoveConstructorWithEmptyList) ::testing::Test::RecordProperty("TEST_ID", "42991766-c8dd-4261-814f-837ae99f6647"); list sut11; list sut12(std::move(sut11)); - EXPECT_THAT(moveCTor, Eq(0U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); EXPECT_THAT(sut12.size(), Eq(0U)); EXPECT_THAT(sut12.empty(), Eq(true)); } @@ -1702,10 +1613,10 @@ TEST_F(list_test, MoveConstructorWithFullList) list sut12(std::move(sut11)); - EXPECT_THAT(moveCTor, Eq(TESTLISTCAPACITY)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.moveCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.size(), Eq(TESTLISTCAPACITY)); EXPECT_THAT(sut12.empty(), Eq(false)); } @@ -1716,7 +1627,7 @@ TEST_F(list_test, DestructorWithEmptyList) { list sut11; } - EXPECT_THAT(dTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(0U)); } TEST_F(list_test, DestructorSomeElements) @@ -1728,9 +1639,9 @@ TEST_F(list_test, DestructorSomeElements) sut11.emplace_front(9191U); sut11.emplace_front(1U); } - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(3U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); } TEST_F(list_test, DestructorWithFullList) @@ -1744,9 +1655,9 @@ TEST_F(list_test, DestructorWithFullList) } } - EXPECT_THAT(dTor, Eq(TESTLISTCAPACITY)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.dTor, Eq(TESTLISTCAPACITY)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(TESTLISTCAPACITY)); } TEST_F(list_test, CopyAssignmentWithEmptySource) @@ -1759,11 +1670,11 @@ TEST_F(list_test, CopyAssignmentWithEmptySource) sut11.emplace_front(8132U); sut11 = sut12; - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(sut11.empty(), Eq(true)); } @@ -1778,16 +1689,16 @@ TEST_F(list_test, CopyAssignmentWithEmptyDestination) sut11.emplace_front(58132U); sut12 = sut11; - EXPECT_THAT(dTor, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(3U)); EXPECT_THAT(sut12.size(), Eq(3U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbegin(); - EXPECT_THAT(iter->m_value, Eq(58132U)); - EXPECT_THAT((++iter)->m_value, Eq(581122U)); - EXPECT_THAT((++iter)->m_value, Eq(5812U)); + EXPECT_THAT(iter->value, Eq(58132U)); + EXPECT_THAT((++iter)->value, Eq(581122U)); + EXPECT_THAT((++iter)->value, Eq(5812U)); } @@ -1806,15 +1717,15 @@ TEST_F(list_test, CopyAssignmentWithLargerDestination) sut11 = sut12; - EXPECT_THAT(dTor, Eq(2U)); - EXPECT_THAT(copyAssignment, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); + EXPECT_THAT(stats.copyAssignment, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(2U)); EXPECT_THAT(sut11.empty(), Eq(false)); auto iter = sut11.cbegin(); - EXPECT_THAT(iter->m_value, Eq(3131U)); - EXPECT_THAT((++iter)->m_value, Eq(313U)); + EXPECT_THAT(iter->value, Eq(3131U)); + EXPECT_THAT((++iter)->value, Eq(313U)); } TEST_F(list_test, CopyAssignmentWithLargerSource) @@ -1832,17 +1743,17 @@ TEST_F(list_test, CopyAssignmentWithLargerSource) sut12 = sut11; - EXPECT_THAT(dTor, Eq(0U)); - EXPECT_THAT(copyAssignment, Eq(2U)); - EXPECT_THAT(copyCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(0U)); + EXPECT_THAT(stats.copyAssignment, Eq(2U)); + EXPECT_THAT(stats.copyCTor, Eq(2U)); EXPECT_THAT(sut12.size(), Eq(4U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbegin(); - EXPECT_THAT(iter->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT(iter->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } @@ -1857,9 +1768,9 @@ TEST_F(list_test, MoveAssignmentWithEmptySource) sut11 = std::move(sut12); - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(sut11.empty(), Eq(true)); } @@ -1875,20 +1786,20 @@ TEST_F(list_test, MoveAssignmentWithEmptyDestination) sut12 = std::move(sut11); - EXPECT_THAT(dTor, Eq(3U)); - EXPECT_THAT(moveAssignment, Eq(0U)); - EXPECT_THAT(copyCTor, Eq(0U)); - EXPECT_THAT(moveCTor, Eq(3U)); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(3U)); + EXPECT_THAT(stats.dTor, Eq(3U)); + EXPECT_THAT(stats.moveAssignment, Eq(0U)); + EXPECT_THAT(stats.copyCTor, Eq(0U)); + EXPECT_THAT(stats.moveCTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(3U)); EXPECT_THAT(sut12.size(), Eq(3U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(58132U)); - EXPECT_THAT((++iter)->m_value, Eq(581122U)); - EXPECT_THAT((++iter)->m_value, Eq(5812U)); + EXPECT_THAT((iter)->value, Eq(58132U)); + EXPECT_THAT((++iter)->value, Eq(581122U)); + EXPECT_THAT((++iter)->value, Eq(5812U)); } @@ -1907,15 +1818,15 @@ TEST_F(list_test, MoveAssignmentWithLargerDestination) sut11 = std::move(sut12); - EXPECT_THAT(dTor, Eq(4U)); - EXPECT_THAT(moveAssignment, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(4U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(2U)); EXPECT_THAT(sut11.empty(), Eq(false)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(3131U)); - EXPECT_THAT((++iter)->m_value, Eq(313U)); + EXPECT_THAT((iter)->value, Eq(3131U)); + EXPECT_THAT((++iter)->value, Eq(313U)); } TEST_F(list_test, MoveAssignmentWithLargerSource) @@ -1933,18 +1844,18 @@ TEST_F(list_test, MoveAssignmentWithLargerSource) sut12 = std::move(sut11); - EXPECT_THAT(dTor, Eq(4U)); - EXPECT_THAT(moveAssignment, Eq(2U)); - EXPECT_THAT(moveCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(4U)); + EXPECT_THAT(stats.moveAssignment, Eq(2U)); + EXPECT_THAT(stats.moveCTor, Eq(2U)); EXPECT_THAT(sut12.size(), Eq(4U)); EXPECT_THAT(sut12.empty(), Eq(false)); auto iter = sut12.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveDefaultElementFromEmptyList) @@ -1952,9 +1863,9 @@ TEST_F(list_test, RemoveDefaultElementFromEmptyList) ::testing::Test::RecordProperty("TEST_ID", "c77e3f62-1c49-4672-9772-79a1fd818b80"); auto cnt = sut.remove({}); - EXPECT_THAT(cTor, Eq(1U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(1U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(0U)); } @@ -1963,9 +1874,9 @@ TEST_F(list_test, RemoveCustomElementFromEmptyList) ::testing::Test::RecordProperty("TEST_ID", "c5c57a6d-e7d7-4219-a4a9-fa59f0b9d08f"); auto cnt = sut.remove({10U}); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(0U)); } @@ -1982,17 +1893,17 @@ TEST_F(list_test, RemoveOneDefaultElementFromList) auto cnt = sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(4U)); EXPECT_THAT(cnt, Eq(2U)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveOneCustomElementFromList) { @@ -2007,18 +1918,18 @@ TEST_F(list_test, RemoveOneCustomElementFromList) auto cnt = sut11.remove({1584122U}); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(5U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(5U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(5U)); EXPECT_THAT(cnt, Eq(1U)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveNotExistentElementFromList) { @@ -2033,20 +1944,20 @@ TEST_F(list_test, RemoveNotExistentElementFromList) auto cnt = sut11.remove({1243U}); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(5U)); - EXPECT_THAT(dTor, Eq(1U)); - EXPECT_THAT(classValue, Eq(1243U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(5U)); + EXPECT_THAT(stats.dTor, Eq(1U)); + EXPECT_THAT(stats.classValue, Eq(1243U)); EXPECT_THAT(sut11.size(), Eq(6U)); EXPECT_THAT(cnt, Eq(0U)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveOnetoEmptyList) @@ -2057,9 +1968,9 @@ TEST_F(list_test, RemoveOnetoEmptyList) auto cnt = sut11.remove({15842U}); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(1U)); } @@ -2074,9 +1985,9 @@ TEST_F(list_test, RemoveWithFewMatches) auto cnt = sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(1U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -2090,9 +2001,9 @@ TEST_F(list_test, RemoveWithAllMatches) auto cnt = sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -2108,9 +2019,9 @@ TEST_F(list_test, RemoveAllFromList) auto cnt = sut11.remove({15842U}); cnt += sut11.remove({}); - EXPECT_THAT(cTor, Eq(3U)); - EXPECT_THAT(customCTor, Eq(2U)); - EXPECT_THAT(dTor, Eq(5U)); + EXPECT_THAT(stats.cTor, Eq(3U)); + EXPECT_THAT(stats.customCTor, Eq(2U)); + EXPECT_THAT(stats.dTor, Eq(5U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(3U)); } @@ -2139,20 +2050,20 @@ TEST_F(list_test, RemoveIfOneDefaultElementFromList) sut11.emplace_front(158432U); auto cnt = - sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(2U)); - EXPECT_THAT(classValue, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(2U)); + EXPECT_THAT(stats.classValue, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); EXPECT_THAT(sut11.size(), Eq(4U)); EXPECT_THAT(cnt, Eq(2U)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveIfOneCustomElementFromList) @@ -2166,20 +2077,20 @@ TEST_F(list_test, RemoveIfOneCustomElementFromList) sut11.emplace_front(158432U); sut11.emplace_front(158432U); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 1584122U; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 1584122U; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut11.size(), Eq(5U)); EXPECT_THAT(cnt, Eq(1U)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveIfNotExistentElementFromList) @@ -2193,21 +2104,21 @@ TEST_F(list_test, RemoveIfNotExistentElementFromList) sut11.emplace_front(158432U); sut11.emplace_front(158432U); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 1234U; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 1234U; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(4U)); - EXPECT_THAT(dTor, Eq(0U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(4U)); + EXPECT_THAT(stats.dTor, Eq(0U)); EXPECT_THAT(sut11.size(), Eq(6U)); EXPECT_THAT(cnt, Eq(0U)); auto iter = sut11.cbegin(); - EXPECT_THAT((iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(158432U)); - EXPECT_THAT((++iter)->m_value, Eq(1584122U)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); - EXPECT_THAT((++iter)->m_value, Eq(15842U)); + EXPECT_THAT((iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(158432U)); + EXPECT_THAT((++iter)->value, Eq(1584122U)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(TEST_LIST_ELEMENT_DEFAULT_VALUE)); + EXPECT_THAT((++iter)->value, Eq(15842U)); } TEST_F(list_test, RemoveIfOnetoEmptyList) @@ -2216,11 +2127,11 @@ TEST_F(list_test, RemoveIfOnetoEmptyList) list sut11; sut11.emplace_front(15842U); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 15842U; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 15842U; }); - EXPECT_THAT(cTor, Eq(0U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(1U)); + EXPECT_THAT(stats.cTor, Eq(0U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(1U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(1U)); } @@ -2234,11 +2145,11 @@ TEST_F(list_test, RemoveIfWithFewMatches) sut11.emplace_front(); auto cnt = - sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(1U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -2251,11 +2162,11 @@ TEST_F(list_test, RemoveIfWithAllMatches) sut11.emplace_front(); auto cnt = - sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(0U)); - EXPECT_THAT(dTor, Eq(2U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(0U)); + EXPECT_THAT(stats.dTor, Eq(2U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(2U)); } @@ -2268,12 +2179,12 @@ TEST_F(list_test, RemoveIfAllFromList) sut11.emplace_front(); sut11.emplace_front(); - auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == 15842U; }); - cnt += sut11.remove_if([](const TestListElement& sut1) { return sut1.m_value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); + auto cnt = sut11.remove_if([](const TestListElement& sut1) { return sut1.value == 15842U; }); + cnt += sut11.remove_if([](const TestListElement& sut1) { return sut1.value == TEST_LIST_ELEMENT_DEFAULT_VALUE; }); - EXPECT_THAT(cTor, Eq(2U)); - EXPECT_THAT(customCTor, Eq(1U)); - EXPECT_THAT(dTor, Eq(3U)); + EXPECT_THAT(stats.cTor, Eq(2U)); + EXPECT_THAT(stats.customCTor, Eq(1U)); + EXPECT_THAT(stats.dTor, Eq(3U)); EXPECT_THAT(sut11.size(), Eq(0U)); EXPECT_THAT(cnt, Eq(3U)); } @@ -2292,7 +2203,7 @@ TEST_F(list_test, writeContentViaDereferencedIterator) auto iter = sut1.begin(); TestListElement element{TEST_VALUE}; *iter = element; - EXPECT_THAT(sut1.front().m_value, Eq(TEST_VALUE)); + EXPECT_THAT(sut1.front().value, Eq(TEST_VALUE)); } TEST_F(list_test, invalidIteratorErase) @@ -2393,7 +2304,7 @@ TEST_F(list_test, invalidIteratorDereferencing) ++iter; auto iter2 IOX_MAYBE_UNUSED = sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT((*iter).m_value); }, + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT((*iter).value); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); } @@ -2410,7 +2321,7 @@ TEST_F(list_test, invalidIteratorAddressOfOperator) ++iter; auto iter2 IOX_MAYBE_UNUSED = sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->m_value == 12U); }, + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->value == 12U); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); } @@ -2452,6 +2363,6 @@ TEST_F(list_test, ListIsCopyableViaMemcpy) for (auto& listElement : *reinterpret_cast(otherSutPtr)) { --i; - EXPECT_THAT(listElement.m_value, Eq(i)); + EXPECT_THAT(listElement.value, Eq(i)); } } From 91ec2be9cd99731333b0fec14c8ba750d9d6edb4 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sun, 15 Oct 2023 21:35:35 +0200 Subject: [PATCH 4/4] iox-#2041 Update release notes --- doc/website/release-notes/iceoryx-unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 34bbd0bfcf..64c8bcaa9a 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -161,6 +161,7 @@ - Use logger for "RouDi is ready for clients" message [\#1994](https://github.com/eclipse-iceoryx/iceoryx/issues/1994) - Speed up posh tests [#1030](https://github.com/eclipse-iceoryx/iceoryx/issues/1030) - Roudi Environment independent from Googletest [#1533](https://github.com/eclipse-iceoryx/iceoryx/issues/1533) +- Move test class for ctor and assignment operators to hoofs testing [#2041](https://github.com/eclipse-iceoryx/iceoryx/issues/2041) **Workflow:**