summaryrefslogtreecommitdiff
path: root/tests/test_limit_reference.cc
blob: 3f56ded5dfcfe9a974bc74adb28737157f43d4ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "testutilities.h"
#include <sigc++/sigc++.h>
#include <sstream>
#include <cstdlib>

namespace
{
std::ostringstream result_stream;

class Base
  : virtual public sigc::trackable
{
};

class Base2
{
public:
  virtual ~Base2()
  {}
};

class Derived
  : virtual public Base,
    public Base2
{
public:
  void method()
  {
    result_stream << "method()";
  }
};

} // end anonymous namespace

int main(int argc, char* argv[])
{
  auto util = TestUtilities::get_instance();

  if (!util->check_command_args(argc, argv))
    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;

  auto instance = new Derived();
  sigc::slot<void> handler = sigc::mem_fun(*instance, &Derived::method);
  handler();
  util->check_result(result_stream, "method()");

  auto param =
    sigc::bind(sigc::slot<void, Derived&>(), std::ref(*instance));
  param();
  util->check_result(result_stream, "");

  auto ret =
    sigc::bind_return(sigc::slot<void>(), std::ref(*instance));
  ret();
  util->check_result(result_stream, "");

  delete instance;

  handler();
  param();
  ret();
  util->check_result(result_stream, "");

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