14
14
15
15
namespace
16
16
{
17
+
18
+ TestUtilities* util = nullptr ;
17
19
std::ostringstream result_stream;
18
20
19
21
class foo
@@ -36,15 +38,8 @@ class foo
36
38
}
37
39
};
38
40
39
- } // end anonymous namespace
40
-
41
- int main (int argc, char * argv[])
41
+ void test_simple ()
42
42
{
43
- auto util = TestUtilities::get_instance ();
44
-
45
- if (!util->check_command_args (argc, argv))
46
- return util->get_result_and_delete_instance () ? EXIT_SUCCESS : EXIT_FAILURE;
47
-
48
43
// simple test
49
44
sigc::slot<void ,int > s1 = foo ();
50
45
s1 (1 );
@@ -53,32 +48,62 @@ int main(int argc, char* argv[])
53
48
s1 = foo ();
54
49
s1 (2 );
55
50
util->check_result (result_stream, " foo(int 2)" );
51
+ }
56
52
53
+ void test_implicit_conversion ()
54
+ {
57
55
// test implicit conversion
58
56
sigc::slot<void ,char > s2 = foo ();
59
57
s2 (3 );
60
58
util->check_result (result_stream, " foo(int 3)" );
59
+ }
61
60
61
+ void test_reference ()
62
+ {
62
63
// test reference
63
64
sigc::slot<void ,std::string&> sl1 = foo ();
64
65
std::string str (" guest book" );
65
66
sl1 (str);
66
67
result_stream << str;
67
68
util->check_result (result_stream, " foo(string 'guest book') foo was here" );
69
+ }
68
70
71
+ void test_operator_equals ()
72
+ {
69
73
// test operator=
70
- str = " guest book" ;
74
+ std::string str = " guest book" ;
75
+ sigc::slot<void ,std::string&> sl1 = foo ();
71
76
sigc::slot<void ,std::string&> sl2;
72
77
sl2 = sl1;
73
78
sl1 = sl2;
74
79
sl1 (str);
75
80
result_stream << str;
76
81
util->check_result (result_stream, " foo(string 'guest book') foo was here" );
82
+ }
77
83
84
+ void test_copy_ctor ()
85
+ {
78
86
// test copy ctor
87
+ sigc::slot<void ,int > s1 = foo ();
79
88
sigc::slot<void ,int > s1_clone (s1);
80
89
s1_clone (4 );
81
90
util->check_result (result_stream, " foo(int 4)" );
91
+ }
92
+
93
+ } // end anonymous namespace
94
+
95
+ int main (int argc, char * argv[])
96
+ {
97
+ util = TestUtilities::get_instance ();
98
+
99
+ if (!util->check_command_args (argc, argv))
100
+ return util->get_result_and_delete_instance () ? EXIT_SUCCESS : EXIT_FAILURE;
101
+
102
+ test_simple ();
103
+ test_implicit_conversion ();
104
+ test_reference ();
105
+ test_operator_equals ();
106
+ test_copy_ctor ();
82
107
83
108
return util->get_result_and_delete_instance () ? EXIT_SUCCESS : EXIT_FAILURE;
84
109
}
0 commit comments