1 /* Copyright 2002, The libsigc++ Development Team
2 * Assigned to public domain. Use as you wish without restriction.
5 #include "testutilities.h"
6 #include <sigc++/functors/slot.h>
11 //The Tru64 compiler seems to need this to avoid an unresolved symbol
18 TestUtilities* util = nullptr;
19 std::ostringstream result_stream;
24 void operator()(int i)
26 result_stream << "foo(int " << i << ")";
29 void operator()(std::string& str)
31 result_stream << "foo(string '" << str << "') ";
35 void operator()(int, int)
37 result_stream << "foo(int, int)";
44 sigc::slot<void,int> s1 = foo();
46 util->check_result(result_stream, "foo(int 1)");
50 util->check_result(result_stream, "foo(int 2)");
53 void test_std_function_style_syntax()
56 sigc::slot<void(int)> s1 = foo();
58 util->check_result(result_stream, "foo(int 1)");
62 util->check_result(result_stream, "foo(int 2)");
65 void test_implicit_conversion()
67 // test implicit conversion
68 sigc::slot<void,char> s2 = foo();
70 util->check_result(result_stream, "foo(int 3)");
76 sigc::slot<void,std::string&> sl1 = foo();
77 std::string str("guest book");
80 util->check_result(result_stream, "foo(string 'guest book') foo was here");
83 void test_operator_equals()
86 std::string str = "guest book";
87 sigc::slot<void,std::string&> sl1 = foo();
88 sigc::slot<void,std::string&> sl2;
93 util->check_result(result_stream, "foo(string 'guest book') foo was here");
99 sigc::slot<void,int> s1 = foo();
100 sigc::slot<void,int> s1_clone(s1);
102 util->check_result(result_stream, "foo(int 4)");
105 } // end anonymous namespace
107 int main(int argc, char* argv[])
109 util = TestUtilities::get_instance();
111 if (!util->check_command_args(argc, argv))
112 return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
115 test_std_function_style_syntax();
116 test_implicit_conversion();
118 test_operator_equals();
121 return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;