12 #include <gtest/gtest.h> 13 #include "../../include/ecl/utilities/function_objects.hpp" 27 class FunctionObject {
29 FunctionObject() : result(-1) {}
30 typedef void result_type;
38 class MemberFunctions {
44 void f(
const int &i) {
52 void h(
const int& i) {
63 static int free_result = -1;
76 void ruf1(
const int &i) {
81 int ruf2(
const int &i) {
94 using namespace ecl::utilities::tests;
100 TEST(FunctionObjects,freeFunctions) {
103 EXPECT_EQ(0,free_result);
111 EXPECT_EQ(2,free_result);
118 TEST(FunctionObjects,boundFreeFunctions) {
122 EXPECT_EQ(2,free_result);
125 TEST(FunctionObjects,memberFunctions) {
130 EXPECT_EQ(0,a.result);
134 EXPECT_EQ(1,a.result);
137 TEST(FunctionObjects,boundMemberFunctions) {
142 EXPECT_EQ(0,a.result);
146 EXPECT_EQ(1,a.result);
149 TEST(FunctionObjects,wrappers) {
151 FunctionObject function_object;
162 TEST(FunctionObjects,generators) {
166 EXPECT_EQ(0,free_result);
168 EXPECT_EQ(2,free_result);
170 EXPECT_EQ(2,free_result);
172 EXPECT_EQ(0,a.result);
174 EXPECT_EQ(0,a.result);
176 EXPECT_EQ(1,a.result);
178 EXPECT_EQ(3,a.result);
180 EXPECT_EQ(3,a.result);
183 EXPECT_EQ(3,a.result);
190 int main(
int argc,
char **argv) {
191 testing::InitGoogleTest(&argc,argv);
192 return RUN_ALL_TESTS();
Embedded control libraries.
Specialisation for free nullary functions that return void.
Nullary function object for bound unary global/static functions.
Create a NullaryFunction object composited from an existing function object.
Binary function object for unary member functions.
Unary function object for member functions without arguments.
Creates a nullary function from a reference wrapper.
Nullary function object for bound nullary member functions.
TEST(TypeTests, fundamentals)
Nullary function object for bound unary member functions.
Unary function object for global/static functions.
int main(int argc, char **argv)
Nullary function object for void global/static functions.
ReferenceWrapper< T > ref(T &wrapped_object)
NullaryFreeFunction< R > generateFunctionObject(R(*function)())
Generate a nullary function object from a void global/static function.