Skip to content

Commit 9f6ecb3

Browse files
committed
test_retype: Break into smaller tests.
1 parent 60154aa commit 9f6ecb3

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

tests/test_retype.cc

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace
1212
{
13+
14+
TestUtilities* util = nullptr;
1315
std::ostringstream result_stream;
1416

1517
struct foo : public sigc::trackable
@@ -32,40 +34,76 @@ void bar(short s)
3234
result_stream << "bar(short " << s << ")";
3335
}
3436

35-
} // end anonymous namespace
36-
37-
int main(int argc, char* argv[])
37+
void test_member_int()
3838
{
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-
4439
foo foo_;
4540
result_stream << sigc::retype(sigc::mem_fun(foo_, &foo::test_int))(1.234f);
4641
util->check_result(result_stream, "foo::test_int(int 1) 1.5");
42+
}
4743

44+
void test_member_float()
45+
{
46+
foo foo_;
4847
result_stream << sigc::retype(sigc::mem_fun(foo_, &foo::test_float))(5);
4948
util->check_result(result_stream, "foo::test_float(float 5) 25");
49+
}
5050

51+
void test_ptr_fun()
52+
{
5153
sigc::retype(sigc::ptr_fun(&bar))(6.789f);
5254
util->check_result(result_stream, "bar(short 6)");
55+
}
5356

57+
void test_member_int_with_slot()
58+
{
59+
foo foo_;
5460
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));
5761
result_stream << s1(1.234f);
5862
util->check_result(result_stream, "foo::test_int(int 1) 1.5");
63+
}
5964

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));
6069
result_stream << s2(5);
6170
util->check_result(result_stream, "foo::test_float(float 5) 25");
71+
}
6272

73+
void test_ptr_fun_with_slot()
74+
{
75+
sigc::slot<void,double> s3 = sigc::retype(sigc::ptr_fun(&bar));
6376
s3(6.789);
6477
util->check_result(result_stream, "bar(short 6)");
78+
}
6579

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);
6785
result_stream << s2(5);
6886
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();
69107

70108
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
71109
}

0 commit comments

Comments
 (0)