2 /* Copyright 2002, The libsigc++ Development Team
3 * Assigned to public domain. Use as you wish without restriction.
6 #include "testutilities.h"
8 #include <sigc++/sigc++.h>
11 //TODO: put something like #ifndef FORTE ... #else ... #endif around:
12 #define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
16 std::ostringstream result_stream;
20 result_stream << "foo()";
26 result_stream << "foo(int " << i1 << ")";
29 #if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
32 result_stream << "bar(char " << (int)i1 << ")";
38 result_stream << "bar(float " << i1 << ")";
41 double bar(int i1, int i2)
43 result_stream << "bar(int " << i1 << ", int " << i2 << ")";
51 result_stream << "test::foo()";
55 } // end anonymous namespace
57 int main(int argc, char* argv[])
59 auto util = TestUtilities::get_instance();
61 if (!util->check_command_args(argc, argv))
62 return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
64 sigc::ptr_fun0(&foo)();
65 util->check_result(result_stream, "foo()");
67 sigc::ptr_fun1(&foo)(1);
68 util->check_result(result_stream, "foo(int 1)");
70 #if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
71 sigc::ptr_fun1<char>(&bar)(2);
72 util->check_result(result_stream, "bar(char 2)");
74 sigc::ptr_fun1<float>(&bar)(2.0f);
75 util->check_result(result_stream, "bar(float 2)");
77 sigc::ptr_fun1(&bar)(2.0f);
78 util->check_result(result_stream, "bar(float 2)");
81 sigc::ptr_fun2(&bar)(3, 5);
82 util->check_result(result_stream, "bar(int 3, int 5)");
84 sigc::ptr_fun(&test::foo)();
85 util->check_result(result_stream, "test::foo()");
87 return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;