]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - tests/test_accum_iter.cc
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / tests / test_accum_iter.cc
1 #include "testutilities.h"
2 #include <sigc++/sigc++.h>
3 #include <sstream>
4 #include <algorithm>
5 #include <functional>
6 #include <cstdlib>
7
8 namespace
9 {
10 std::ostringstream result_stream;
11
12 int ident(int i)
13 {
14   return i;
15 }
16
17 template<typename T>
18 struct min_accum
19 {
20   typedef T result_type;
21
22   template<class I>
23 #ifndef SIGC_HAVE_SUN_REVERSE_ITERATOR
24   typename std::iterator_traits<I>::value_type operator()(I i1, I i2)
25 #else
26   typename I::value_type operator()(I i1, I i2)
27 #endif
28   {
29     return *std::min_element(i1, i2);
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   sigc::signal0<int,min_accum<int> > signal;
43
44   signal.connect(sigc::bind(sigc::ptr_fun(ident), 3));
45   signal.connect(sigc::bind(sigc::ptr_fun(ident), 1));
46   signal.connect(sigc::bind(sigc::ptr_fun(ident), 42));
47
48   result_stream << signal();
49   util->check_result(result_stream, "1");
50
51   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
52 }