]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - tests/test_trackable.cc
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / tests / test_trackable.cc
1 // -*- c++ -*-
2 /* Copyright 2002, The libsigc++ Development Team
3  *  Assigned to public domain.  Use as you wish without restriction.
4  */
5
6 #include "testutilities.h"
7 #include <sstream>
8 #include <cstdlib>
9 #include <sigc++/trackable.h>
10 #include <sigc++/functors/slot.h>
11 #include <sigc++/functors/mem_fun.h>
12
13 namespace
14 {
15 std::ostringstream result_stream;
16
17 class my_class: public sigc::trackable
18 {
19 public:
20   int i;
21
22   void foo()
23   {
24     result_stream << i;
25   }
26 };
27
28 } // end anonymous namespace
29
30 int main(int argc, char* argv[])
31 {
32   auto util = TestUtilities::get_instance();
33
34   if (!util->check_command_args(argc, argv))
35     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
36
37   sigc::slot<void> sl;
38   {
39     my_class t;
40     t.i = 10;
41     sl = sigc::mem_fun0(t, &my_class::foo);
42     sl();
43     util->check_result(result_stream, "10");
44   }
45
46   sl();
47   util->check_result(result_stream, "");
48
49   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
50 }