]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - tests/test_hide.cc
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / tests / test_hide.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 <sigc++/adaptors/hide.h>
8 #include <sstream>
9 #include <cstdlib>
10
11 namespace
12 {
13 std::ostringstream result_stream;
14
15 struct foo : public sigc::functor_base
16 {
17   // choose a type that can hold all return values
18   typedef int result_type;
19
20   int operator()()
21   {
22     result_stream << "foo() ";
23     return true;
24   }
25
26   int operator()(int j)
27   {
28     result_stream << "foo(int " << j << ") ";
29     return 1 + j;
30   }
31 };
32
33 struct foo_void : public sigc::functor_base
34 {
35   typedef void result_type;
36
37   void operator()()
38   {
39     result_stream << "foo_void()";
40   }
41 };
42
43 } // end anonymous namespace
44
45 namespace sigc { SIGC_FUNCTOR_TRAIT(foo,bool) }
46
47 int main(int argc, char* argv[])
48 {
49   auto util = TestUtilities::get_instance();
50
51   if (!util->check_command_args(argc, argv))
52     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
53
54   result_stream << sigc::hide<0>(foo())(1, 2);
55   util->check_result(result_stream, "foo(int 2) 3");
56
57   result_stream << sigc::hide<1>(foo())(1, 2);
58   util->check_result(result_stream, "foo(int 1) 2");
59
60   result_stream << sigc::hide<-1>(foo())(1);
61   util->check_result(result_stream, "foo() 1");
62
63   result_stream << sigc::hide(foo())(1);
64   util->check_result(result_stream, "foo() 1");
65
66   sigc::hide(foo_void())(1); // void test
67   util->check_result(result_stream, "foo_void()");
68
69   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
70 }