Skip to content

Commit 11f0357

Browse files
committed
better fixed function test coverage
1 parent f50c7b2 commit 11f0357

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/fixed_function.t.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,24 @@ TEST(FixedFunction, allocDealloc)
125125
TEST(FixedFunction, freeFunc)
126126
{
127127
tp::FixedFunction<int(int)> f(test_free_func);
128-
ASSERT_EQ(3, f(3));
128+
auto f1 = std::move(f);
129+
ASSERT_EQ(3, f1(3));
129130
};
130131

131132
TEST(FixedFunction, freeFuncTemplate)
132133
{
133134
tp::FixedFunction<std::string(std::string)> f(test_free_func_template<std::string>);
134-
ASSERT_EQ(std::string("abc"), f("abc"));
135+
auto f1 = std::move(f);
136+
ASSERT_EQ(std::string("abc"), f1("abc"));
135137
}
136138

137139

138140
TEST(FixedFunction, voidFunc)
139141
{
140142
tp::FixedFunction<void(int &, int)> f(test_void);
143+
auto f1 = std::move(f);
141144
int p = 0;
142-
f(p, 42);
145+
f1(p, 42);
143146
ASSERT_EQ(42, p);
144147
}
145148

@@ -149,7 +152,8 @@ TEST(FixedFunction, classMethodVoid)
149152
A a;
150153
int i = 0;
151154
tp::FixedFunction<void(int &)> f(std::bind(&A::c, &a, _1));
152-
f(i);
155+
auto f1 = std::move(f);
156+
f1(i);
153157
ASSERT_EQ(43, i);
154158
}
155159

@@ -158,7 +162,8 @@ TEST(FixedFunction, classMethod1)
158162
using namespace std::placeholders;
159163
A a;
160164
tp::FixedFunction<int(const int&)> f(std::bind(&A::b, &a, _1));
161-
ASSERT_EQ(4, f(4));
165+
auto f1 = std::move(f);
166+
ASSERT_EQ(4, f1(4));
162167
}
163168

164169
TEST(FixedFunction, classMethod2)
@@ -167,7 +172,8 @@ TEST(FixedFunction, classMethod2)
167172
Foo<float> foo;
168173
foo.payload = 1.f;
169174
tp::FixedFunction<int(int)> f(std::bind(&Foo<float>::bar<int>, &foo, _1));
170-
ASSERT_EQ(2, f(1));
175+
auto f1 = std::move(f);
176+
ASSERT_EQ(2, f1(1));
171177
}
172178

173179
TEST(FixedFunction, lambda)
@@ -177,8 +183,8 @@ TEST(FixedFunction, lambda)
177183
{
178184
return s1;
179185
});
180-
181-
ASSERT_EQ(s1, f());
186+
auto f1 = std::move(f);
187+
ASSERT_EQ(s1, f1());
182188
}
183189

184190
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)