16
16
17
17
#include " iceoryx_dust/cxx/forward_list.hpp"
18
18
#include " iceoryx_hoofs/cxx/attributes.hpp"
19
+ #include " iceoryx_hoofs/error_handling/error_handling.hpp"
20
+ #include " iceoryx_hoofs/testing/fatal_failure.hpp"
19
21
#include " test.hpp"
20
22
21
23
namespace
22
24
{
23
25
using namespace ::testing;
24
26
using namespace iox ::cxx;
27
+ using namespace iox ::testing;
25
28
26
29
constexpr uint64_t TESTLISTCAPACITY{10U };
27
30
constexpr int64_t TEST_LIST_ELEMENT_DEFAULT_VALUE{-99L };
@@ -142,15 +145,6 @@ int64_t iteratorTraitReturnDoubleValue(IterType iter)
142
145
IterValueType m_value = *iter;
143
146
return (2 * m_value); // will only work for integer-convertible m_value types
144
147
}
145
-
146
- // in context of EXPECT_DEATH tests, dummyFunc() shall help suppressing following warning :
147
- // -Wunused-comparison
148
- // reason: the warning is already addressed with the internal handling, which shall be tested here
149
- bool dummyFunc (bool whatever)
150
- {
151
- std::cerr << " Never get here - ever " << whatever << std::endl;
152
- return whatever;
153
- }
154
148
} // namespace
155
149
156
150
@@ -292,9 +286,7 @@ TEST_F(forward_list_test, FullWhenFilledWithMoreThanCapacityElements)
292
286
}
293
287
294
288
EXPECT_THAT (sut.full (), Eq (true ));
295
- // @todo iox-#1613 remove EXPECT_DEATH
296
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
297
- EXPECT_DEATH (sut.emplace_front (), " " );
289
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.emplace_front (); }, iox::HoofsError::EXPECTS_ENSURES_FAILED);
298
290
}
299
291
TEST_F (forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements)
300
292
{
@@ -666,9 +658,8 @@ TEST_F(forward_list_test, EmplaceAfterWithWrongListIterator)
666
658
++cnt;
667
659
}
668
660
669
- // @todo iox-#1613 remove EXPECT_DEATH
670
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
671
- EXPECT_DEATH (sut11.emplace_after (iterOfSut12, cnt), " " );
661
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut11.emplace_after (iterOfSut12, cnt); },
662
+ iox::HoofsError::EXPECTS_ENSURES_FAILED);
672
663
}
673
664
674
665
TEST_F (forward_list_test, PushFrontConstCustomSuccessfullWhenSpaceAvailableLValue)
@@ -1166,39 +1157,39 @@ TEST_F(forward_list_test, IteratorComparisonOfDifferentLists)
1166
1157
1167
1158
auto iterSut1 = sut11.begin ();
1168
1159
auto iterSut2 = sut12.begin ();
1169
- // @todo iox-#1613 remove EXPECT_DEATH
1170
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1171
- EXPECT_DEATH ( dummyFunc (iterSut1 == iterSut2), " " );
1160
+
1161
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iterSut1 == iterSut2); },
1162
+ iox::HoofsError::EXPECTS_ENSURES_FAILED );
1172
1163
1173
1164
iterSut1 = sut11.before_begin ();
1174
1165
iterSut2 = sut12.before_begin ();
1175
- // @todo iox-#1613 remove EXPECT_DEATH
1176
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1177
- EXPECT_DEATH ( dummyFunc (iterSut1 == iterSut2), " " );
1166
+
1167
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iterSut1 == iterSut2); },
1168
+ iox::HoofsError::EXPECTS_ENSURES_FAILED );
1178
1169
1179
1170
iterSut1 = sut11.end ();
1180
1171
iterSut2 = sut12.end ();
1181
- // @todo iox-#1613 remove EXPECT_DEATH
1182
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1183
- EXPECT_DEATH ( dummyFunc (iterSut1 == iterSut2), " " );
1172
+
1173
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iterSut1 == iterSut2); },
1174
+ iox::HoofsError::EXPECTS_ENSURES_FAILED );
1184
1175
1185
1176
iterSut1 = sut11.begin ();
1186
1177
iterSut2 = sut12.begin ();
1187
- // @todo iox-#1613 remove EXPECT_DEATH
1188
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1189
- EXPECT_DEATH ( dummyFunc (iterSut1 != iterSut2), " " );
1178
+
1179
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iterSut1 != iterSut2); },
1180
+ iox::HoofsError::EXPECTS_ENSURES_FAILED );
1190
1181
1191
1182
iterSut1 = sut11.before_begin ();
1192
1183
iterSut2 = sut12.before_begin ();
1193
- // @todo iox-#1613 remove EXPECT_DEATH
1194
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1195
- EXPECT_DEATH ( dummyFunc (iterSut1 != iterSut2), " " );
1184
+
1185
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iterSut1 != iterSut2); },
1186
+ iox::HoofsError::EXPECTS_ENSURES_FAILED );
1196
1187
1197
1188
iterSut1 = sut11.end ();
1198
1189
iterSut2 = sut12.end ();
1199
- // @todo iox-#1613 remove EXPECT_DEATH
1200
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1201
- EXPECT_DEATH ( dummyFunc (iterSut1 != iterSut2), " " );
1190
+
1191
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iterSut1 != iterSut2); },
1192
+ iox::HoofsError::EXPECTS_ENSURES_FAILED );
1202
1193
}
1203
1194
1204
1195
@@ -1988,9 +1979,7 @@ TEST_F(forward_list_test, invalidIteratorErase)
1988
1979
auto iter = sut.begin ();
1989
1980
sut.pop_front ();
1990
1981
1991
- // @todo iox-#1613 remove EXPECT_DEATH
1992
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
1993
- EXPECT_DEATH (sut.erase_after (iter), " " );
1982
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.erase_after (iter); }, iox::HoofsError::EXPECTS_ENSURES_FAILED);
1994
1983
}
1995
1984
1996
1985
TEST_F (forward_list_test, invalidIteratorIncrement)
@@ -2005,9 +1994,7 @@ TEST_F(forward_list_test, invalidIteratorIncrement)
2005
1994
auto iter = sut.cbegin ();
2006
1995
sut.pop_front ();
2007
1996
2008
- // @todo iox-#1613 remove EXPECT_DEATH
2009
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
2010
- EXPECT_DEATH (++iter, " " );
1997
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { ++iter; }, iox::HoofsError::EXPECTS_ENSURES_FAILED);
2011
1998
}
2012
1999
2013
2000
TEST_F (forward_list_test, invalidIteratorComparison)
@@ -2022,9 +2009,8 @@ TEST_F(forward_list_test, invalidIteratorComparison)
2022
2009
auto iter = sut.cbegin ();
2023
2010
sut.pop_front ();
2024
2011
2025
- // @todo iox-#1613 remove EXPECT_DEATH
2026
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
2027
- EXPECT_DEATH (dummyFunc (sut.cbegin () == iter), " " );
2012
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (sut.cbegin () == iter); },
2013
+ iox::HoofsError::EXPECTS_ENSURES_FAILED);
2028
2014
}
2029
2015
2030
2016
TEST_F (forward_list_test, invalidIteratorComparisonUnequal)
@@ -2039,9 +2025,8 @@ TEST_F(forward_list_test, invalidIteratorComparisonUnequal)
2039
2025
sut.pop_front ();
2040
2026
auto iter2 = sut.cbegin ();
2041
2027
2042
- // @todo iox-#1613 remove EXPECT_DEATH
2043
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
2044
- EXPECT_DEATH (dummyFunc (iter2 != iter), " " );
2028
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iter2 != iter); },
2029
+ iox::HoofsError::EXPECTS_ENSURES_FAILED);
2045
2030
}
2046
2031
2047
2032
TEST_F (forward_list_test, invalidIteratorDereferencing)
@@ -2056,9 +2041,7 @@ TEST_F(forward_list_test, invalidIteratorDereferencing)
2056
2041
auto iter = sut.cbegin ();
2057
2042
sut.pop_front ();
2058
2043
2059
- // @todo iox-#1613 remove EXPECT_DEATH
2060
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
2061
- EXPECT_DEATH (sut.remove (*iter), " " );
2044
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.remove (*iter); }, iox::HoofsError::EXPECTS_ENSURES_FAILED);
2062
2045
}
2063
2046
2064
2047
TEST_F (forward_list_test, invalidIteratorAddressOfOperator)
@@ -2073,9 +2056,8 @@ TEST_F(forward_list_test, invalidIteratorAddressOfOperator)
2073
2056
auto iter = sut.cbegin ();
2074
2057
sut.pop_front ();
2075
2058
2076
- // @todo iox-#1613 remove EXPECT_DEATH
2077
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
2078
- EXPECT_DEATH (dummyFunc (iter->m_value == 12U ), " " );
2059
+ IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { IOX_DISCARD_RESULT (iter->m_value == 12U ); },
2060
+ iox::HoofsError::EXPECTS_ENSURES_FAILED);
2079
2061
}
2080
2062
2081
2063
TEST_F (forward_list_test, ListIsCopyableViaMemcpy)
0 commit comments