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();