10
10
11
11
namespace
12
12
{
13
+
14
+ TestUtilities* util = nullptr ;
13
15
std::ostringstream result_stream;
14
16
15
17
struct foo : public sigc ::trackable
@@ -32,40 +34,76 @@ void bar(short s)
32
34
result_stream << " bar(short " << s << " )" ;
33
35
}
34
36
35
- } // end anonymous namespace
36
-
37
- int main (int argc, char * argv[])
37
+ void test_member_int ()
38
38
{
39
- auto util = TestUtilities::get_instance ();
40
-
41
- if (!util->check_command_args (argc, argv))
42
- return util->get_result_and_delete_instance () ? EXIT_SUCCESS : EXIT_FAILURE;
43
-
44
39
foo foo_;
45
40
result_stream << sigc::retype (sigc::mem_fun (foo_, &foo::test_int))(1 .234f );
46
41
util->check_result (result_stream, " foo::test_int(int 1) 1.5" );
42
+ }
47
43
44
+ void test_member_float ()
45
+ {
46
+ foo foo_;
48
47
result_stream << sigc::retype (sigc::mem_fun (foo_, &foo::test_float))(5 );
49
48
util->check_result (result_stream, " foo::test_float(float 5) 25" );
49
+ }
50
50
51
+ void test_ptr_fun ()
52
+ {
51
53
sigc::retype (sigc::ptr_fun (&bar))(6 .789f );
52
54
util->check_result (result_stream, " bar(short 6)" );
55
+ }
53
56
57
+ void test_member_int_with_slot ()
58
+ {
59
+ foo foo_;
54
60
sigc::slot<float ,float > s1 = sigc::retype (sigc::mem_fun (foo_, &foo::test_int));
55
- sigc::slot<float ,int > s2 = sigc::retype (sigc::mem_fun (foo_, &foo::test_float));
56
- sigc::slot<void ,double > s3 = sigc::retype (sigc::ptr_fun (&bar));
57
61
result_stream << s1 (1 .234f );
58
62
util->check_result (result_stream, " foo::test_int(int 1) 1.5" );
63
+ }
59
64
65
+ void test_member_float_with_slot ()
66
+ {
67
+ foo foo_;
68
+ sigc::slot<float ,int > s2 = sigc::retype (sigc::mem_fun (foo_, &foo::test_float));
60
69
result_stream << s2 (5 );
61
70
util->check_result (result_stream, " foo::test_float(float 5) 25" );
71
+ }
62
72
73
+ void test_ptr_fun_with_slot ()
74
+ {
75
+ sigc::slot<void ,double > s3 = sigc::retype (sigc::ptr_fun (&bar));
63
76
s3 (6.789 );
64
77
util->check_result (result_stream, " bar(short 6)" );
78
+ }
65
79
66
- s2 = sigc::retype (s1);
80
+ void test_retype_slot ()
81
+ {
82
+ foo foo_;
83
+ sigc::slot<float ,float > s1 = sigc::retype (sigc::mem_fun (foo_, &foo::test_int));
84
+ sigc::slot<float ,int > s2 = sigc::retype (s1);
67
85
result_stream << s2 (5 );
68
86
util->check_result (result_stream, " foo::test_int(int 5) 7.5" );
87
+ }
88
+
89
+ } // end anonymous namespace
90
+
91
+ int main (int argc, char * argv[])
92
+ {
93
+ util = TestUtilities::get_instance ();
94
+
95
+ if (!util->check_command_args (argc, argv))
96
+ return util->get_result_and_delete_instance () ? EXIT_SUCCESS : EXIT_FAILURE;
97
+
98
+ test_member_int ();
99
+ test_member_float ();
100
+ test_ptr_fun ();
101
+
102
+ test_member_int_with_slot ();
103
+ test_member_float_with_slot ();
104
+ test_ptr_fun_with_slot ();
105
+
106
+ test_retype_slot ();
69
107
70
108
return util->get_result_and_delete_instance () ? EXIT_SUCCESS : EXIT_FAILURE;
71
109
}
0 commit comments