Skip to content

Commit 2599dc7

Browse files
committed
ClangTidy issue in lib/system/Route.hpp #1296
1 parent 5116b27 commit 2599dc7

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

lib/system/Route.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ namespace MAT_NS_BEGIN {
102102
void operator()(TRealArgs&& ... args) const
103103
{
104104
for (IRoutePassThrough<TArgs...>* target : m_passthroughs) {
105-
if (!(*target)(std::forward<TRealArgs>(args) ...)) {
105+
if (!(*target)(args ...)) {
106106
return;
107107
}
108108
}
109109
if (m_target) {
110-
(*m_target)(std::forward<TRealArgs>(args) ...);
110+
(*m_target)(args ...);
111111
}
112112
}
113113

tests/unittests/RouteTests.cpp

+12-24
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,17 @@ class Canary : public std::string {
6060

6161
class RouteTests : public StrictMock<Test> {
6262
public:
63-
RouteSink<RouteTests> sink0{this, &RouteTests::handleSink0};
64-
RouteSink<RouteTests, int> sink1{this, &RouteTests::handleSink1};
65-
RoutePassThrough<RouteTests, int> passThrough1a{this, &RouteTests::handlePassThrough1a};
66-
RoutePassThrough<RouteTests, int> passThrough1b{this, &RouteTests::handlePassThrough1b};
67-
RouteSink<RouteTests, int, bool&, NonCopyableThing const&, Canary, std::vector<int>&&> sink5{this, &RouteTests::handleSink5x};
63+
RouteSink<RouteTests> sink0{this, &RouteTests::handleSink0};
64+
RouteSink<RouteTests, int> sink1{this, &RouteTests::handleSink1};
65+
RoutePassThrough<RouteTests, int> passThrough1a{this, &RouteTests::handlePassThrough1a};
66+
RoutePassThrough<RouteTests, int> passThrough1b{this, &RouteTests::handlePassThrough1b};
67+
RouteSink<RouteTests, int, bool&, NonCopyableThing const&, Canary> sink4{this, &RouteTests::handleSink4};
6868

6969
MOCK_METHOD0(handleSink0, void());
7070
MOCK_METHOD1(handleSink1, void(int));
7171
MOCK_METHOD1(handlePassThrough1a, bool(int));
7272
MOCK_METHOD1(handlePassThrough1b, bool(int));
73-
MOCK_METHOD4(handleSink5, void(int, bool&, NonCopyableThing const &, Canary));
74-
75-
void handleSink5x(int a, bool& b, NonCopyableThing const& c, Canary d, std::vector<int>&& e)
76-
{
77-
// This extra function exists just to handle the r-value reference.
78-
// The move cannot be done properly in a mocked method.
79-
std::vector<int> x = std::move(e);
80-
handleSink5(a, b, c, d);
81-
}
73+
MOCK_METHOD4(handleSink4, void(int, bool&, NonCopyableThing const &, Canary));
8274
};
8375

8476

@@ -92,18 +84,16 @@ TEST_F(RouteTests, SinkPassesArgsAsDefined)
9284
NonCopyableThing thing;
9385
Canary canary;
9486
canary.bear();
95-
std::vector<int> data{1, 2, 3};
9687

97-
EXPECT_CALL(*this, handleSink5(123, _, Ref(thing), Eq("alive")))
88+
EXPECT_CALL(*this, handleSink4(123, _, Ref(thing), Eq("alive")))
9889
.WillOnce(DoAll(
9990
SetArgReferee<1>(true),
10091
InvokeArgument<3>()
10192
));
102-
sink5(123, flag, thing, canary, std::move(data));
93+
sink4(123, flag, thing, canary);
10394

10495
EXPECT_THAT(flag, true);
10596
EXPECT_THAT(canary, Eq("alive"));
106-
EXPECT_THAT(data, IsEmpty());
10797
}
10898

10999
TEST_F(RouteTests, SourceIsNoopWhenUnbound)
@@ -117,8 +107,8 @@ TEST_F(RouteTests, SourceCallsSink)
117107
RouteSource<> source0;
118108
source0 >> sink0;
119109

120-
RouteSource<int, bool&, NonCopyableThing const&, Canary, std::vector<int>&&> source5;
121-
source5 >> sink5;
110+
RouteSource<int, bool&, NonCopyableThing const&, Canary> source4;
111+
source4 >> sink4;
122112

123113

124114
EXPECT_CALL(*this, handleSink0())
@@ -130,17 +120,15 @@ TEST_F(RouteTests, SourceCallsSink)
130120
NonCopyableThing thing;
131121
Canary canary;
132122
canary.bear();
133-
std::vector<int> data{1, 2, 3};
134123

135-
EXPECT_CALL(*this, handleSink5(123, _, Ref(thing), Eq("alive")))
124+
EXPECT_CALL(*this, handleSink4(123, _, Ref(thing), Eq("alive")))
136125
.WillOnce(DoAll(
137126
SetArgReferee<1>(true),
138127
InvokeArgument<3>()
139128
));
140-
source5(123, flag, thing, canary, std::move(data));
129+
source4(123, flag, thing, canary);
141130
EXPECT_THAT(flag, true);
142131
EXPECT_THAT(canary, Eq("alive"));
143-
EXPECT_THAT(data, IsEmpty());
144132
}
145133

146134
TEST_F(RouteTests, PassThroughsAreInvokedInBetween)

0 commit comments

Comments
 (0)