]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - tests/test_limit_reference.cc
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / tests / test_limit_reference.cc
1 #include "testutilities.h"
2 #include <sigc++/sigc++.h>
3 #include <sstream>
4 #include <cstdlib>
5
6 namespace
7 {
8 std::ostringstream result_stream;
9
10 class Base
11   : virtual public sigc::trackable
12 {
13 };
14
15 class Base2
16 {
17 public:
18   virtual ~Base2()
19   {}
20 };
21
22 class Derived
23   : virtual public Base,
24     public Base2
25 {
26 public:
27   void method()
28   {
29     result_stream << "method()";
30   }
31 };
32
33 } // end anonymous namespace
34
35 int main(int argc, char* argv[])
36 {
37   auto util = TestUtilities::get_instance();
38
39   if (!util->check_command_args(argc, argv))
40     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
41
42   auto instance = new Derived();
43   sigc::slot<void> handler = sigc::mem_fun(*instance, &Derived::method);
44   handler();
45   util->check_result(result_stream, "method()");
46
47   auto param =
48     sigc::bind(sigc::slot<void, Derived&>(), std::ref(*instance));
49   param();
50   util->check_result(result_stream, "");
51
52   auto ret =
53     sigc::bind_return(sigc::slot<void>(), std::ref(*instance));
54   ret();
55   util->check_result(result_stream, "");
56
57   delete instance;
58
59   handler();
60   param();
61   ret();
62   util->check_result(result_stream, "");
63
64   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
65 }