diff options
author | Murray Cumming <murrayc@murrayc.com> | 2016-03-11 10:13:06 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2016-03-11 11:23:32 +0100 |
commit | 0d64fd36d31ed33ef198227e1c6a6d51d8f68763 (patch) | |
tree | c80c478964502dce9136cfe600586158792747f8 | |
parent | 470c3b779f76bcceac9a78cf97e465622f3e7838 (diff) | |
download | sigc++-0d64fd36d31ed33ef198227e1c6a6d51d8f68763.tar.gz |
test_slot(): Restructure this.
To make it clearer and to keep the small tests more self-contained and
separate.
-rw-r--r-- | tests/test_slot.cc | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/tests/test_slot.cc b/tests/test_slot.cc index 07b3580..49c0226 100644 --- a/tests/test_slot.cc +++ b/tests/test_slot.cc @@ -14,6 +14,8 @@ namespace { + +TestUtilities* util = nullptr; std::ostringstream result_stream; class foo @@ -36,15 +38,8 @@ public: } }; -} // end anonymous namespace - -int main(int argc, char* argv[]) +void test_simple() { - auto util = TestUtilities::get_instance(); - - if (!util->check_command_args(argc, argv)) - return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; - // simple test sigc::slot<void,int> s1 = foo(); s1(1); @@ -53,32 +48,62 @@ int main(int argc, char* argv[]) s1 = foo(); s1(2); util->check_result(result_stream, "foo(int 2)"); +} +void test_implicit_conversion() +{ // test implicit conversion sigc::slot<void,char> s2 = foo(); s2(3); util->check_result(result_stream, "foo(int 3)"); +} +void test_reference() +{ // test reference sigc::slot<void,std::string&> sl1 = foo(); std::string str("guest book"); sl1(str); result_stream << str; util->check_result(result_stream, "foo(string 'guest book') foo was here"); +} +void test_operator_equals() +{ // test operator= - str = "guest book"; + std::string str = "guest book"; + sigc::slot<void,std::string&> sl1 = foo(); sigc::slot<void,std::string&> sl2; sl2 = sl1; sl1 = sl2; sl1(str); result_stream << str; util->check_result(result_stream, "foo(string 'guest book') foo was here"); +} +void test_copy_ctor() +{ // test copy ctor + sigc::slot<void,int> s1 = foo(); sigc::slot<void,int> s1_clone(s1); s1_clone(4); util->check_result(result_stream, "foo(int 4)"); +} + +} // end anonymous namespace + +int main(int argc, char* argv[]) +{ + util = TestUtilities::get_instance(); + + if (!util->check_command_args(argc, argv)) + return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; + + test_simple(); + test_implicit_conversion(); + test_reference(); + test_operator_equals(); + test_copy_ctor(); return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; } |