[libsigc++2] Test cases: Report pass/fail with exit status.



commit 12bbd742f1e47422940c3068619cac62a5f5d708
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Oct 18 14:45:53 2012 +0200

    Test cases: Report pass/fail with exit status.
    
    * tests/testutilities.[h|cc]: New files. Code common to all test cases.
    * tests/*.cc: Use class TestUtilities. Don't print anything
    if the test passes. Return EXIT_FAILURE if the test fails.
    * tests/Makefile.am: Add testutilities.[h|cc] to all test cases.
    Bug #684956.

 ChangeLog                            |   10 ++
 tests/Makefile.am                    |  112 ++++++++--------
 tests/test_accum_iter.cc             |   65 +++++-----
 tests/test_accumulated.cc            |  141 +++++++++++++--------
 tests/test_bind.cc                   |  129 +++++++++++++------
 tests/test_bind_ref.cc               |   45 +++++--
 tests/test_bind_refptr.cc            |   49 +++++---
 tests/test_bind_return.cc            |   58 ++++++---
 tests/test_compose.cc                |  101 +++++++++++----
 tests/test_copy_invalid_slot.cc      |   87 ++++++++-----
 tests/test_cpp11_lambda.cc           |  140 ++++++++++-----------
 tests/test_custom.cc                 |   21 +++-
 tests/test_deduce_result_type.cc     |   47 +++++--
 tests/test_disconnect.cc             |   98 ++++++++++----
 tests/test_disconnect_during_emit.cc |   28 +++-
 tests/test_exception_catch.cc        |   67 +++++++---
 tests/test_functor_trait.cc          |   64 +++++++---
 tests/test_hide.cc                   |   57 +++++++--
 tests/test_lambda.cc                 |  235 ++++++++++++++++++++++++----------
 tests/test_limit_reference.cc        |   37 +++++-
 tests/test_mem_fun.cc                |  224 +++++++++++++++++++++-----------
 tests/test_ptr_fun.cc                |   82 ++++++++++---
 tests/test_retype.cc                 |   50 ++++++--
 tests/test_retype_return.cc          |   38 ++++--
 tests/test_signal.cc                 |   59 +++++++--
 tests/test_size.cc                   |   58 ++++++---
 tests/test_slot.cc                   |   53 ++++++--
 tests/test_slot_disconnect.cc        |   50 +++++---
 tests/test_trackable.cc              |   28 ++++-
 tests/testutilities.cc               |   92 +++++++++++++
 tests/testutilities.h                |   48 +++++++
 31 files changed, 1661 insertions(+), 712 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5cdd5f4..f194172 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-10-18  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Test cases: Report pass/fail with exit status.
+
+	* tests/testutilities.[h|cc]: New files. Code common to all test cases.
+	* tests/*.cc: Use class TestUtilities. Don't print anything
+	if the test passes. Return EXIT_FAILURE if the test fails.
+	* tests/Makefile.am: Add testutilities.[h|cc] to all test cases.
+	Bug #684956.
+
 2.3.1:
 
 2012-10-18  Murray Cumming  <murrayc murray com>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6fd1dcb..067fd71 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,64 +19,66 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)
 AM_CXXFLAGS = $(SIGC_WXXFLAGS)
 LDADD       = $(top_builddir)/sigc++/libsigc-$(SIGCXX_API_VERSION).la
 
-check_PROGRAMS =			\
-	test_accum_iter			\
-	test_accumulated		\
-	test_bind			\
-	test_bind_ref			\
-	test_bind_refptr 		\
-	test_bind_return		\
-	test_cpp11_lambda		\
-	test_compose			\
-	test_copy_invalid_slot		\
-	test_custom			\
-	test_deduce_result_type		\
-	test_disconnect			\
-	test_disconnect_during_emit	\
-	test_exception_catch		\
-	test_functor_trait		\
-	test_hide			\
-	test_lambda			\
-	test_limit_reference		\
-	test_mem_fun			\
-	test_ptr_fun			\
-	test_retype			\
-	test_retype_return		\
-	test_signal			\
-	test_size			\
-	test_slot			\
-	test_slot_disconnect		\
-	test_trackable
+check_PROGRAMS = \
+  test_accum_iter \
+  test_accumulated \
+  test_bind \
+  test_bind_ref \
+  test_bind_refptr \
+  test_bind_return \
+  test_compose \
+  test_copy_invalid_slot \
+  test_cpp11_lambda \
+  test_custom \
+  test_deduce_result_type \
+  test_disconnect \
+  test_disconnect_during_emit \
+  test_exception_catch \
+  test_functor_trait \
+  test_hide \
+  test_lambda \
+  test_limit_reference \
+  test_mem_fun \
+  test_ptr_fun \
+  test_retype \
+  test_retype_return \
+  test_signal \
+  test_size \
+  test_slot \
+  test_slot_disconnect \
+  test_trackable
 
 TESTS = $(check_PROGRAMS)
 
-test_accum_iter_SOURCES			= test_accum_iter.cc
-test_accumulated_SOURCES 		= test_accumulated.cc
-test_bind_SOURCES			= test_bind.cc
-test_bind_ref_SOURCES			= test_bind_ref.cc
-test_bind_refptr_SOURCES		= test_bind_refptr.cc
-test_bind_return_SOURCES		= test_bind_return.cc
-test_cpp11_lambda_SOURCES   = test_cpp11_lambda.cc
-test_compose_SOURCES			= test_compose.cc
-test_copy_invalid_slot_SOURCES		= test_copy_invalid_slot.cc
-test_custom_SOURCES			= test_custom.cc
-test_deduce_result_type_SOURCES		= test_deduce_result_type.cc
-test_disconnect_SOURCES			= test_disconnect.cc
-test_disconnect_during_emit_SOURCES	= test_disconnect_during_emit.cc
-test_exception_catch_SOURCES		= test_exception_catch.cc
-test_functor_trait_SOURCES		= test_functor_trait.cc
-test_hide_SOURCES			= test_hide.cc
-test_lambda_SOURCES			= test_lambda.cc
-test_limit_reference_SOURCES		= test_limit_reference.cc
-test_mem_fun_SOURCES			= test_mem_fun.cc
-test_ptr_fun_SOURCES			= test_ptr_fun.cc
-test_retype_SOURCES			= test_retype.cc
-test_retype_return_SOURCES		= test_retype_return.cc
-test_signal_SOURCES			= test_signal.cc
-test_size_SOURCES			= test_size.cc
-test_slot_SOURCES			= test_slot.cc
-test_slot_disconnect_SOURCES		= test_slot_disconnect.cc
-test_trackable_SOURCES			= test_trackable.cc
+sigc_test_util = testutilities.h testutilities.cc
+
+test_accum_iter_SOURCES      = test_accum_iter.cc $(sigc_test_util)
+test_accumulated_SOURCES     = test_accumulated.cc $(sigc_test_util)
+test_bind_SOURCES            = test_bind.cc $(sigc_test_util)
+test_bind_ref_SOURCES        = test_bind_ref.cc $(sigc_test_util)
+test_bind_refptr_SOURCES     = test_bind_refptr.cc $(sigc_test_util)
+test_bind_return_SOURCES     = test_bind_return.cc $(sigc_test_util)
+test_compose_SOURCES         = test_compose.cc $(sigc_test_util)
+test_copy_invalid_slot_SOURCES = test_copy_invalid_slot.cc $(sigc_test_util)
+test_cpp11_lambda_SOURCES    = test_cpp11_lambda.cc $(sigc_test_util)
+test_custom_SOURCES          = test_custom.cc $(sigc_test_util)
+test_deduce_result_type_SOURCES = test_deduce_result_type.cc $(sigc_test_util)
+test_disconnect_SOURCES      = test_disconnect.cc $(sigc_test_util)
+test_disconnect_during_emit_SOURCES = test_disconnect_during_emit.cc $(sigc_test_util)
+test_exception_catch_SOURCES = test_exception_catch.cc $(sigc_test_util)
+test_functor_trait_SOURCES   = test_functor_trait.cc $(sigc_test_util)
+test_hide_SOURCES            = test_hide.cc $(sigc_test_util)
+test_lambda_SOURCES          = test_lambda.cc $(sigc_test_util)
+test_limit_reference_SOURCES = test_limit_reference.cc $(sigc_test_util)
+test_mem_fun_SOURCES         = test_mem_fun.cc $(sigc_test_util)
+test_ptr_fun_SOURCES         = test_ptr_fun.cc $(sigc_test_util)
+test_retype_SOURCES          = test_retype.cc $(sigc_test_util)
+test_retype_return_SOURCES   = test_retype_return.cc $(sigc_test_util)
+test_signal_SOURCES          = test_signal.cc $(sigc_test_util)
+test_size_SOURCES            = test_size.cc $(sigc_test_util)
+test_slot_SOURCES            = test_slot.cc $(sigc_test_util)
+test_slot_disconnect_SOURCES = test_slot_disconnect.cc $(sigc_test_util)
+test_trackable_SOURCES       = test_trackable.cc $(sigc_test_util)
 
 # 2005-01-19
 # Disabled: test_lambda - The Tru64 compiler can't build this when not using
diff --git a/tests/test_accum_iter.cc b/tests/test_accum_iter.cc
index ef8ab13..d89aae0 100644
--- a/tests/test_accum_iter.cc
+++ b/tests/test_accum_iter.cc
@@ -1,47 +1,52 @@
+#include "testutilities.h"
 #include <sigc++/sigc++.h>
-#include <iostream>
+#include <sstream>
 #include <algorithm>
 #include <functional>
+#include <cstdlib>
 
-#include <new>
-SIGC_USING_STD(new)
+namespace
+{
+std::ostringstream result_stream;
 
-static int ident(int i)
+int ident(int i)
 {
-    return i;
+  return i;
 }
 
 template<typename T>
 struct min_accum
 {
-    typedef T result_type;
+  typedef T result_type;
 
-    template<class I>
-#ifndef SIGC_HAVE_SUN_REVERSE_ITERATOR  
-        typename std::iterator_traits<I>::value_type operator()(I i1, I i2)
+  template<class I>
+#ifndef SIGC_HAVE_SUN_REVERSE_ITERATOR
+  typename std::iterator_traits<I>::value_type operator()(I i1, I i2)
 #else
-        typename I::value_type operator()(I i1, I i2)
-#endif  
-        {
-            return *std::min_element(i1, i2);
-        }
+  typename I::value_type operator()(I i1, I i2)
+#endif
+  {
+    return *std::min_element(i1, i2);
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
-    sigc::signal0<int,min_accum<int> > signal;
-
-    signal.connect(
-            sigc::bind(sigc::ptr_fun(ident), 3));
-    signal.connect(
-            sigc::bind(sigc::ptr_fun(ident), 1));
-    signal.connect(
-            sigc::bind(sigc::ptr_fun(ident), 42));
-
-    int rv = signal();
-    std::cout <<rv <<std::endl;
-    if (rv != 1)
-        return 1;
-    else
-        return 0;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  sigc::signal0<int,min_accum<int> > signal;
+
+  signal.connect(sigc::bind(sigc::ptr_fun(ident), 3));
+  signal.connect(sigc::bind(sigc::ptr_fun(ident), 1));
+  signal.connect(sigc::bind(sigc::ptr_fun(ident), 42));
+
+  result_stream << signal();
+  util->check_result(result_stream, "1");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_accumulated.cc b/tests/test_accumulated.cc
index e20ead6..5b3c0ae 100644
--- a/tests/test_accumulated.cc
+++ b/tests/test_accumulated.cc
@@ -3,28 +3,32 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/trackable.h>
 #include <sigc++/signal.h>
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/functors/mem_fun.h>
-#include <iostream>
+#include <sstream>
+#include <iomanip>
 #include <vector>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
 
 struct arithmetic_mean_accumulator
 {
   typedef double result_type;
   template<typename T_iterator>
   double operator()(T_iterator first, T_iterator last) const
-    {
-      double value_ = 0;
-      int n_ = 0;
-      for (; first != last; ++first, ++n_)
-        value_ += *first;
-      return (n_ ? value_ / n_ : -1); // empty slot list <=> n_==0
-    }
+  {
+    double value_ = 0;
+    int n_ = 0;
+    for (; first != last; ++first, ++n_)
+      value_ += *first;
+    return (n_ ? value_ / n_ : -1); // empty slot list <=> n_==0
+  }
 };
 
 template<class Ret>
@@ -33,55 +37,90 @@ struct vector_accumulator
   typedef std::vector<Ret> result_type;
   template<typename T_iterator>
   result_type operator()(T_iterator first, T_iterator last) const
-    {
-      result_type vec;
-      for (; first != last; ++first)
-        vec.push_back(*first);
-      return vec;
-    }
+  {
+    result_type vec;
+    for (; first != last; ++first)
+      vec.push_back(*first);
+    return vec;
+  }
 };
 
-int foo(int i)    { std::cout << "foo: " << 3*i+1 << std::endl; return 3*i+1;}
-int bar(double i) { std::cout << "bar: " << 5*int(i)-3 << std::endl; return 5*int(i)-3;}
+int foo(int i)
+{
+  const int result = 3 * i + 1;
+  result_stream << "foo: " << result << ", ";
+  return result;
+}
+
+int bar(double i)
+{
+  const int result = 5 * int(i) - 3;
+  result_stream << "bar: " << result << ", ";
+  return result;
+}
 
-struct A : public sigc::trackable 
+struct A : public sigc::trackable
 {
-  int foo(int i) { std::cout << "A::foo: " << 20*i-14 << std::endl; return 20*i-14;}
+  int foo(int i)
+  {
+    const int result = 20 * i - 14;
+    result_stream << "A::foo: " << result << ", ";
+    return result;
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
    sigc::signal<int,int>::accumulated<arithmetic_mean_accumulator> sig;
    sigc::signal<int,int>::accumulated<vector_accumulator<int> > sig_vec;
 
-   std::cout << "Result (empty slot list): " << sig(0) << std::endl;
-   std::cout << "Vector result (empty slot list): "
-             << (sig_vec(0).empty() ? "empty" : "not empty") << std::endl;
-
-   A a;
-   sig.connect(sigc::ptr_fun1(&foo));
-   sig.connect(sigc::mem_fun1(&a, &A::foo));
-   sig.connect(sigc::ptr_fun1(&bar));
-   
-   sig_vec.connect(sigc::ptr_fun1(&foo));
-   sig_vec.connect(sigc::mem_fun1(&a, &A::foo));
-   sig_vec.connect(sigc::ptr_fun1(&bar));
-
-   std::cout << "Mean accumulator: Result (i=1): " << sig(1) << std::endl;
-   std::cout << "Mean accumulator: Plain Result (i=11): " << sig(11) << std::endl;
-   
-   std::vector<int> res1 = sig_vec(1);
-   std::vector<int> res3 = sig_vec(3);
-   
-   std::cout << "Vector accumulator: Result (i=1): ";
-   for (std::vector<int>::iterator i = res1.begin(); i != res1.end(); ++i)
-     std::cout << *i << " ";
-   std::cout << std::endl;
-   
-   std::cout << "Vector accumulator: Result (i=3): ";
-   for (std::vector<int>::iterator i = res3.begin(); i != res3.end(); ++i)
-     std::cout << *i << " ";
-   std::cout << std::endl;
-   
-   return 0;
+  result_stream << "Result (empty slot list): " << sig(0);
+  util->check_result(result_stream, "Result (empty slot list): -1");
+  result_stream << "Vector result (empty slot list): "
+                << (sig_vec(0).empty() ? "empty" : "not empty");
+  util->check_result(result_stream, "Vector result (empty slot list): empty");
+
+  A a;
+  sig.connect(sigc::ptr_fun1(&foo));
+  sig.connect(sigc::mem_fun1(&a, &A::foo));
+  sig.connect(sigc::ptr_fun1(&bar));
+
+  sig_vec.connect(sigc::ptr_fun1(&foo));
+  sig_vec.connect(sigc::mem_fun1(&a, &A::foo));
+  sig_vec.connect(sigc::ptr_fun1(&bar));
+
+  double dres = sig(1);
+  result_stream << "Mean accumulator: Result (i=1): "
+                << std::fixed << std::setprecision(3) << dres;
+  util->check_result(result_stream,
+    "foo: 4, A::foo: 6, bar: 2, Mean accumulator: Result (i=1): 4.000");
+
+  dres = sig(11);
+  result_stream << "Mean accumulator: Plain Result (i=11): "
+                << std::fixed << std::setprecision(3) << dres;
+  util->check_result(result_stream,
+    "foo: 34, A::foo: 206, bar: 52, Mean accumulator: Plain Result (i=11): 97.333");
+
+  std::vector<int> res1 = sig_vec(1);
+  result_stream << "Vector accumulator: Result (i=1): ";
+  for (std::vector<int>::iterator i = res1.begin(); i != res1.end(); ++i)
+    result_stream << *i << " ";
+  util->check_result(result_stream,
+    "foo: 4, A::foo: 6, bar: 2, Vector accumulator: Result (i=1): 4 6 2 ");
+
+  std::vector<int> res3 = sig_vec(3);
+  result_stream << "Vector accumulator: Result (i=3): ";
+  for (std::vector<int>::iterator i = res3.begin(); i != res3.end(); ++i)
+    result_stream << *i << " ";
+  util->check_result(result_stream,
+    "foo: 10, A::foo: 46, bar: 12, Vector accumulator: Result (i=3): 10 46 12 ");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_bind.cc b/tests/test_bind.cc
index 7f33e9e..bb62755 100644
--- a/tests/test_bind.cc
+++ b/tests/test_bind.cc
@@ -3,52 +3,75 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/bind.h>
 #include <sigc++/functors/slot.h>
-#include <iostream>
+#include <sstream>
 #include <string>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(string)
+namespace
+{
+std::ostringstream result_stream;
 
 struct foo : public sigc::functor_base
 {
   // choose a type that can hold all return values
   typedef int result_type;
+
   int operator()(int i)
-    {std::cout << "foo(int "<<i<<")" << std::endl; return (i>0);}
-    
+  {
+    result_stream << "foo(int " << i << ") ";
+    return i > 0;
+  }
+
   int operator()(int i, int j)
-    {std::cout << "foo(int "<<i<<",int "<<j<<")" << std::endl; return i+j;}
-    
+  {
+    result_stream << "foo(int " << i << ", int "<< j << ") ";
+    return i + j;
+  }
+
   int operator()(int i, int j, int k)
-    {std::cout << "foo(int "<<i<<",int "<<j<<", int "<<k<<")" << std::endl; return 0;}
+  {
+    result_stream << "foo(int " << i << ", int " << j << ", int " << k << ") ";
+    return 0;
+  }
 };
 
 struct foo_void : public sigc::functor_base
 {
   typedef void result_type;
+
   void operator()(int i)
-    {std::cout << "foo_void(int "<<i<<")" << std::endl;}
+  {
+    result_stream << "foo_void(int " << i << ")";
+  }
 };
 
-
-int bar(int i,int j) 
-  {std::cout << "bar(int "<< i << ", int " << j << ")" << std::endl; return i+j;}
+int bar(int i, int j)
+{
+  result_stream << "bar(int " << i << ", int " << j << ") ";
+  return i + j;
+}
 
 bool simple(bool test)
-  {std::cout << "simple(bool " << test <<")" << std::endl; return test;}
+{
+  result_stream << "simple(bool " << test << ") ";
+  return test;
+}
 
 void egon(std::string& str)
-  {std::cout << "egon(string '" << str <<"')" << std::endl; str="egon was here";}
+{
+  result_stream << "egon(string '" << str << "')";
+  str = "egon was here";
+}
 
 
 struct book : public sigc::trackable
 {
   book(const std::string& name) : name_(name) {}
-  std::string& get_name()  {return name_;}
-  operator std::string& () {return get_name();}
+  std::string& get_name()  { return name_; }
+  operator std::string& () { return get_name(); }
 
 private:
   std::string name_;
@@ -58,53 +81,81 @@ private:
   book& operator=(const book&);
 };
 
+} // end anonymous namespace
 
-int main()
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   // replacing bind1st, bind2nd
-  std::cout << sigc::bind<0>(foo(),-12345)(5) << std::endl;
-  std::cout << sigc::bind<1>(foo(),-12345)(5) << std::endl;
+  result_stream << sigc::bind<0>(foo(), -12345)(5);
+  util->check_result(result_stream, "foo(int -12345, int 5) -12340");
+
+  result_stream << sigc::bind<1>(foo(), -12345)(5);
+  util->check_result(result_stream, "foo(int 5, int -12345) -12340");
 
   // multiple
-  sigc::bind(foo(),1,2)();
+  sigc::bind(foo(), 1, 2)();
+  util->check_result(result_stream, "foo(int 1, int 2) ");
 
   // bind from end
-  sigc::bind<-1>(foo(),4)(3);
-  sigc::bind(foo(),4)(3);
+  sigc::bind<-1>(foo(), 4)(3);
+  util->check_result(result_stream, "foo(int 3, int 4) ");
+
+  sigc::bind(foo(), 4)(3);
+  util->check_result(result_stream, "foo(int 3, int 4) ");
 
   // used together
-  sigc::bind<0>(sigc::bind<0>(foo(),7),8)();
+  sigc::bind<0>(sigc::bind<0>(foo(), 7), 8)();
+  util->check_result(result_stream, "foo(int 7, int 8) ");
 
   // void return
-  sigc::bind(foo(),9,10)(11); // (only returned void if typeof() would be supported)
-  sigc::bind(foo_void(),12)();
+  sigc::bind(foo(), 9, 10)(11); // (only returned void if typeof() would be supported)
+  util->check_result(result_stream, "foo(int 11, int 9, int 10) ");
+
+  sigc::bind(foo_void(), 12)();
+  util->check_result(result_stream, "foo_void(int 12)");
 
   // function pointer instead of functor
-  sigc::bind(&bar,13,14)();
+  sigc::bind(&bar, 13, 14)();
+  util->check_result(result_stream, "bar(int 13, int 14) ");
 
   // method pointer instead of functor
   book test_book("otto");
-  sigc::bind<0>(&book::get_name, sigc::ref(test_book))();
+  result_stream << sigc::bind<0>(&book::get_name, sigc::ref(test_book))();
+  util->check_result(result_stream, "otto");
 
   // test return type of bind_functor::operator() overload with no arguments
-  std::cout << sigc::bind(foo(),15)() << std::endl;
-  std::cout << sigc::bind(&simple, true)() << std::endl;
+  result_stream << sigc::bind(foo(), 15)();
+  util->check_result(result_stream, "foo(int 15) 1");
+
+  result_stream << sigc::bind(&simple, true)();
+  util->check_result(result_stream, "simple(bool 1) 1");
 
   // test references
   std::string str("guest book");
-  sigc::bind(&egon, sigc::ref(str))(); // Tell bind that is shall store a reference.
-  std::cout << str << std::endl;     // (This cannot be the default behaviour: just think about what happens if str dies!)
+  sigc::bind(&egon, sigc::ref(str))(); // Tell bind that it shall store a reference.
+  result_stream << " " << str; // (This cannot be the default behaviour: just think about what happens if str dies!)
+  util->check_result(result_stream, "egon(string 'guest book') egon was here");
 
   sigc::slot<void> sl;
   {
     book guest_book("karl");
     sl = sigc::bind(&egon, sigc::ref(guest_book));
     sl();
-    std::cout << static_cast<std::string&>(guest_book) << std::endl;
-  }    // auto-disconnect
-
-  //sl();
-  // This causes a crash when using g++ 3.3.4 or 3.3.5 (but not 3.4.x) when not specifying the exact template
-  // specialization in visit_each_type() - see the comments there.
-  // It looks like the auto-disconnect does not work, so the last sl() call tries to access the guest_book data again.
+    result_stream << " " << static_cast<std::string&>(guest_book);
+    util->check_result(result_stream, "egon(string 'karl') egon was here");
+  } // auto-disconnect
+
+  sl();
+  util->check_result(result_stream, "");
+  // This causes a crash when using g++ 3.3.4 or 3.3.5 (but not 3.4.x) when not specifying
+  // the exact template specialization in visit_each_type() - see the comments there.
+  // It looks like the auto-disconnect does not work, so the last sl() call tries
+  // to access the guest_book data again.
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_bind_ref.cc b/tests/test_bind_ref.cc
index 0bcda12..4cbeb5e 100644
--- a/tests/test_bind_ref.cc
+++ b/tests/test_bind_ref.cc
@@ -1,7 +1,12 @@
+#include "testutilities.h"
 #include <sigc++/sigc++.h>
-#include <iostream>
+#include <sstream>
 #include <string>
+#include <cstdlib>
 
+namespace
+{
+std::ostringstream result_stream;
 
 class Param : public sigc::trackable
 {
@@ -18,35 +23,47 @@ private:
   Param& operator=(const Param&);
 };
 
-
 void handler(Param& param)
 {
-  std::cout << "  handler(param): param.name_=" << param.name_ << std::endl;
+  result_stream << "  handler(param): param.name_=" << param.name_;
 }
 
+} // end anonymous namespace
 
-int main()
+int main(int argc, char* argv[])
 {
-  sigc::slot<void, Param &> slot_full = sigc::ptr_fun(&handler);
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  sigc::slot<void, Param&> slot_full = sigc::ptr_fun(&handler);
   sigc::slot<void> slot_bound;
 
-  //slot_bound();
+  slot_bound();
+  util->check_result(result_stream, "");
 
   {
-    //Because Param derives from sigc::trackable(), sigc::ref() should disconnect the signal handler when param is destroyed.
+    //Because Param derives from sigc::trackable(), sigc::ref() should disconnect
+    // the signal handler when param is destroyed.
     Param param("murrayc");
     // A convoluted way to do
     // slot_bound = sigc::bind(slot_full, sigc::ref(param));
     slot_bound = sigc::bind< -1, sigc::reference_wrapper<Param> >(slot_full, sigc::ref(param));
 
-    std::cout << "Calling slot when param exists:" << std::endl;
+    result_stream << "Calling slot when param exists:";
     slot_bound();
-  }    // auto-disconnect
+    util->check_result(result_stream,
+      "Calling slot when param exists:  handler(param): param.name_=murrayc");
+  } // auto-disconnect
 
-  
-  std::cout << "Calling slot when param does not exist:" << std::endl;
+  result_stream << "Calling slot when param does not exist:";
   slot_bound();
-  // This causes a crash when using g++ 3.3.4 or 3.3.5 (but not 3.4.x) when not specifying the exact template
-  // specialization in visit_each_type() - see the comments there.
-  // It looks like the auto-disconnect does not work, so the last sl() call tries to access the guest_book data again.
+  util->check_result(result_stream, "Calling slot when param does not exist:");
+  // This causes a crash when using g++ 3.3.4 or 3.3.5 (but not 3.4.x) when not specifying
+  // the exact template specialization in visit_each_type() - see the comments there.
+  // It looks like the auto-disconnect does not work, so the last slot_bound() call tries
+  // to access the param data again.
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_bind_refptr.cc b/tests/test_bind_refptr.cc
index 577b285..edbf766 100644
--- a/tests/test_bind_refptr.cc
+++ b/tests/test_bind_refptr.cc
@@ -3,6 +3,15 @@
 
 // libsigc++-only test case. (Or almost so. RefPtr is stolen from glibmm.)
 
+// This test case is much more useful if it's run under valgrind.
+
+#include "testutilities.h"
+#include <sigc++/sigc++.h>
+#include <sstream>
+#include <cstdlib>
+
+#define ACTIVATE_BUG 1
+
 // -*- c++ -*-
 #ifndef _GLIBMM_REFPTR_H
 #define _GLIBMM_REFPTR_H
@@ -60,7 +69,7 @@ public:
    * Afterwards it will be null and use of -> will cause a segmentation fault.
    */
   inline RefPtr();
-  
+
   /// Destructor - decrements reference count.
   inline ~RefPtr();
 
@@ -99,7 +108,7 @@ public:
 
   /// Tests whether the RefPtr<> point to the same underlying instance.
   inline bool operator==(const RefPtr<T_CppObject>& src) const;
-  
+
   /// See operator==().
   inline bool operator!=(const RefPtr<T_CppObject>& src) const;
 
@@ -142,7 +151,7 @@ public:
 
   /** Static cast to derived class.
    *
-   * Like the dynamic cast; the notation is 
+   * Like the dynamic cast; the notation is
    * @code
    *   ptr_derived = RefPtr<Derived>::cast_static(ptr_base);
    * @endcode
@@ -160,7 +169,7 @@ public:
   template <class T_CastFrom>
   static inline RefPtr<T_CppObject> cast_const(const RefPtr<T_CastFrom>& src);
 
-  //TODO: Maybe remove these if we replace operator bool() with operator const void* after 
+  //TODO: Maybe remove these if we replace operator bool() with operator const void* after
   //an API/ABI break, as suggested by Daniel Elstner? murrayc.
   //See bug https://bugzilla.gnome.org/show_bug.cgi?id=626858
 
@@ -406,11 +415,9 @@ void swap(RefPtr<T_CppObject>& lhs, RefPtr<T_CppObject>& rhs)
 #endif /* _GLIBMM_REFPTR_H */
 
 
-#include <sigc++/sigc++.h>
-#include <iostream>
-#include <stdlib.h>
-
-#define ACTIVATE_BUG 1
+namespace
+{
+std::ostringstream result_stream;
 
 class Action : public sigc::trackable
 {
@@ -436,8 +443,8 @@ public:
   Test()
   : action(new Action)
   {
-    //std::cout << "new Test" << std::endl;
-#ifdef ACTIVATE_BUG //See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c15s
+    result_stream << "new Test; ";
+#ifdef ACTIVATE_BUG //See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c14
     action->signal_sig1().connect(sigc::bind(sigc::mem_fun(this, &Test::on_sig1), action));
 #else
     Glib::RefPtr<Action> action2(new Action);
@@ -447,24 +454,32 @@ public:
 
   ~Test()
   {
-    //std::cout << "delete Test" << std::endl;
+    result_stream << "delete Test; ";
   }
 
-  void on_sig1(int /* n */, Glib::RefPtr<Action> /* action */)
+  void on_sig1(int n, Glib::RefPtr<Action> /* action */)
   {
-    //std::cout << "Test::on_sig1, n=" << n << std::endl;
+    result_stream << "Test::on_sig1, n=" << n << "; ";
   }
-  
+
   Glib::RefPtr<Action> action;
 
 }; // end Test
 
-int main(int, char**)
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   Test* test = new Test;
 
   test->action->emit_sig1(23);
   delete test;
+  util->check_result(result_stream, "new Test; Test::on_sig1, n=23; delete Test; ");
 
-  return EXIT_SUCCESS;
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_bind_return.cc b/tests/test_bind_return.cc
index 09c2666..123240b 100644
--- a/tests/test_bind_return.cc
+++ b/tests/test_bind_return.cc
@@ -3,33 +3,49 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/bind_return.h>
 #include <sigc++/functors/slot.h>
-#include <iostream>
+#include <sstream>
 #include <string>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(string)
+namespace
+{
+std::ostringstream result_stream;
 
-struct foo 
+struct foo
 {
-  void operator()(int i) 
-    {std::cout << "foo(int "<<i<<")"<<std::endl; }
-  float operator()(float i) 
-    {std::cout << "foo(float "<<i<<")"<<std::endl; return i*5;}
+  void operator()(int i)
+  {
+    result_stream << "foo(int " << i << ") ";
+  }
+
+  float operator()(float i)
+  {
+    result_stream << "foo(float " << i << ") ";
+    return i*5;
+  }
 };
 
 struct bar : public sigc::trackable
 {
-  bar(int i=0) : i_(i) {}
-  operator int() {return i_;}
+  bar(int i = 0) : i_(i) {}
+  operator int() { return i_; }
   int i_;
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
-  std::cout << sigc::bind_return(foo(),-12345)(5) << std::endl;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  result_stream << sigc::bind_return(foo(), -12345)(5);
+  util->check_result(result_stream, "foo(int 5) -12345");
 
   // Here we just build a functor, not a slot. There is no such thing as a
   // default functor, or an invalidated functor. As such, functors can return
@@ -38,7 +54,8 @@ int main()
   // A convoluted way to do
   // sigc::bind_return(foo(), sigc::ref(str))(6) = "main";
   sigc::bind_return<sigc::reference_wrapper<std::string> >(foo(), sigc::ref(str))(6) = "main";
-  std::cout << str << std::endl;
+  result_stream << str;
+  util->check_result(result_stream, "foo(int 6) main");
 
   // Here we build a slot (constructed from a functor). Slots cannot return
   // references: if they could, then what would be the return value of the
@@ -46,12 +63,17 @@ int main()
   // guaranteed to be able to construct and return a valid default instance as
   // long as there exists a default constructor for it.
   //
-  // Therefore, we use 'bar', and not 'bar &' for this slot signature.
-  sigc::slot<bar,int> sl;
+  // Therefore, we use 'bar', and not 'bar&' for this slot signature.
+  sigc::slot<bar, int> sl;
   {
     bar choco(-1);
     sl = sigc::bind_return(foo(),sigc::ref(choco));
-    std::cout << sl(7) << std::endl;
+    result_stream << sl(7);
+    util->check_result(result_stream, "foo(int 7) -1");
   } // auto-disconnect
-  std::cout << sl(8) << std::endl;
+
+  result_stream << sl(8);
+  util->check_result(result_stream, "0");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_compose.cc b/tests/test_compose.cc
index e5b6a93..7de3d00 100644
--- a/tests/test_compose.cc
+++ b/tests/test_compose.cc
@@ -3,59 +3,110 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/compose.h>
-#include <iostream>
-
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+#include <sstream>
+#include <cstdlib>
 
 // assume existance of T_functor::result_type for unknown functor types:
 namespace sigc { SIGC_FUNCTORS_HAVE_RESULT_TYPE }
 
+namespace
+{
+std::ostringstream result_stream;
 
-struct set 
+struct set
 {
   // choose a type that can hold all return values
   typedef double result_type;
-  double operator()(int i) 
-    {std::cout << "set(int "<<i<<")"<<std::endl; return i*i;}
-  double operator()(double i) 
-    {std::cout << "set(double "<<i<<")"<<std::endl; return i*5;}
+
+  double operator()(int i)
+  {
+    result_stream << "set(int " << i << ") ";
+    return i*i;
+  }
+
+  double operator()(double i)
+  {
+    result_stream << "set(double " << i << ") ";
+    return i*5;
+  }
 };
 
 struct set_void
 {
   typedef void result_type;
+
   void operator()(double i)
-    { std::cout << "set_void(double "<<i<<")"<<std::endl; }
+  {
+    result_stream << "set_void(double " << i << ")";
+  }
 };
 
 struct get
 {
 #ifdef SIGC_CXX_TYPEOF
   bool operator()()
-    { std::cout << "get()"<<std::endl; return true; }
-  int operator()(int i) 
-    { std::cout << "get("<<i<<")"<<std::endl; return i*2; }
-  double operator()(int i,int j) 
-    { std::cout << "get("<<i<<","<<j<<")"<<std::endl; return double(i)/double(j); }
+  {
+    result_stream << "get() ";
+    return true;
+  }
+
+  int operator()(int i)
+  {
+    result_stream << "get(" << i << ") ";
+    return i*2;
+  }
+
+  double operator()(int i, int j)
+  {
+    result_stream << "get(" << i << ", " << j << ") ";
+    return double(i)/double(j);
+  }
 #else
   // choose a type that can hold all return values
   typedef double result_type;
+
   double operator()()
-    { std::cout << "get()"<<std::endl; return true; }
-  double operator()(int i) 
-    { std::cout << "get("<<i<<")"<<std::endl; return i*2; }
-  double operator()(int i,int j) 
-    { std::cout << "get("<<i<<","<<j<<")"<<std::endl; return double(i)/double(j); }
+  {
+    result_stream << "get() ";
+    return true;
+  }
+
+  double operator()(int i)
+  {
+    result_stream << "get(" << i << ") ";
+    return i*2;
+  }
+
+  double operator()(int i, int j)
+  {
+    result_stream << "get(" << i << ", " << j << ") ";
+    return double(i)/double(j);
+  }
 #endif
 };
 
+} // end anonymous namespace
 
-int main()
+int main(int argc, char* argv[])
 {
-  std::cout << sigc::compose(set(),get())() << std::endl;
-  std::cout << sigc::compose(set(),get())(1) << std::endl;
-  std::cout << sigc::compose(set(),get())(1,2) << std::endl;
-  sigc::compose(set_void(),get())(3); //void test
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  result_stream << sigc::compose(set(), get())();
+  util->check_result(result_stream, "get() set(double 1) 5");
+
+  result_stream << sigc::compose(set(), get())(1);
+  util->check_result(result_stream, "get(1) set(double 2) 10");
+
+  result_stream << sigc::compose(set(), get())(1, 2);
+  util->check_result(result_stream, "get(1, 2) set(double 0.5) 2.5");
+
+  sigc::compose(set_void(), get())(3); //void test
+  util->check_result(result_stream, "get(3) set_void(double 6)");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_copy_invalid_slot.cc b/tests/test_copy_invalid_slot.cc
index 96547f0..64ace36 100644
--- a/tests/test_copy_invalid_slot.cc
+++ b/tests/test_copy_invalid_slot.cc
@@ -1,38 +1,65 @@
-#include <iostream>
+#include "testutilities.h"
+#include <sstream>
 #include <cstdlib>
-#include <cstring>
 #include <sigc++/sigc++.h>
-
 #include <stdlib.h>
 #include <string.h>
 
-static void Foo(sigc::trackable&) {}
+namespace
+{
+std::ostringstream result_stream;
 
-int main(int, char**)
+void Foo(sigc::trackable&)
 {
-   sigc::trackable *t = new sigc::trackable();
-   std::cout << "sigc::trackable instance at " << t << std::endl;
-   sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), sigc::ref(*t));
-   // This invalidates foo.
-   delete t;
-
-   // Try to crash if the invalid slot parameter is used by libsigc++,
-   // and get a debugger backtrace at the point that it happens.
-   //
-   // Comment this out to get a meaningful backtrace from valgrind.
-   //
-   // Try to pollute the memory previously occupied by the sigc::trackable
-   // instance. The hope is that with a regular memory allocator (i.e. not
-   // valgrind), we end up with buffer == (void *)t.
-   void *buffer = malloc(sizeof(sigc::trackable));
-   memset(buffer, 0xFF, sizeof(sigc::trackable));
-   std::cout << "         Polluted buffer at " << buffer << std::endl;
-
-   // Now copy foo: up to libsigc++ version 2.0.11, the copy constructor fails
-   // because the pointer value it dereferences does not point to a
-   // sigc::trackable anymore, it now points to a polluted buffer.
-   sigc::slot<void> bar = foo;
-
-   free(buffer);
-   return 0;
+  result_stream << "Foo(x)";
+}
+
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
+{
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  std::ostringstream pointer_stream;
+  sigc::trackable* t = new sigc::trackable();
+  pointer_stream << t;
+  result_stream << "sigc::trackable instance at " << pointer_stream.str();
+  util->check_result(result_stream, "sigc::trackable instance at " + pointer_stream.str());
+  pointer_stream.str("");
+
+  sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), sigc::ref(*t));
+  foo();
+  util->check_result(result_stream, "Foo(x)");
+
+  // This invalidates foo.
+  delete t;
+
+  // Try to crash if the invalid slot parameter is used by libsigc++,
+  // and get a debugger backtrace at the point that it happens.
+  //
+  // Comment this out to get a meaningful backtrace from valgrind.
+  //
+  // Try to pollute the memory previously occupied by the sigc::trackable
+  // instance. The hope is that with a regular memory allocator (i.e. not
+  // valgrind), we end up with buffer == (void *)t.
+  void* buffer = malloc(sizeof(sigc::trackable));
+  memset(buffer, 0xFF, sizeof(sigc::trackable));
+  pointer_stream << buffer;
+  result_stream << "         Polluted buffer at " << pointer_stream.str();
+  util->check_result(result_stream, "         Polluted buffer at " + pointer_stream.str());
+  pointer_stream.str("");
+
+  // Now copy foo: up to libsigc++ version 2.0.11, the copy constructor fails
+  // because the pointer value it dereferences does not point to a
+  // sigc::trackable anymore, it now points to a polluted buffer.
+  sigc::slot<void> bar = foo;
+  bar();
+  util->check_result(result_stream, "");
+
+  free(buffer);
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc
index c94c8ca..ad0271d 100644
--- a/tests/test_cpp11_lambda.cc
+++ b/tests/test_cpp11_lambda.cc
@@ -45,6 +45,7 @@
 #  define USING_CPP11_LAMBDA_EXPRESSIONS
 #endif
 
+#include "testutilities.h"
 #include <string>
 #include <iostream>
 #include <sstream>
@@ -64,25 +65,11 @@ namespace sigc
 
 namespace
 {
-bool result_ok = true;
-int test_number = 0;
 std::ostringstream result_stream;
 
-void check_result(const std::string& expected_result)
-{
-  ++test_number;
-  if (expected_result != result_stream.str())
-  {
-    std::cout << "Test " << test_number << ". Expected \"" << expected_result
-      << "\", got \"" << result_stream.str() << "\"" << std::endl;
-    result_ok = false;
-  }
-  result_stream.str("");
-}
-
 int foo(int i, int j)
 {
-  result_stream << "foo(int " << i << ", int " << j << ")";
+  result_stream << "foo(int " << i << ", int " << j << ") ";
   return 4*i + j;
 }
 
@@ -95,7 +82,7 @@ struct bar
 {
   int test(int i, int j)
   {
-    result_stream << "bar::test(int " << i << ", int " << j << ")";
+    result_stream << "bar::test(int " << i << ", int " << j << ") ";
     return 4*i + j;
   }
 
@@ -131,7 +118,7 @@ void foo_group1(int i, int j)
 
 int bar_group1(int i)
 {
-  result_stream << "bar_group1(int " << i << ")";
+  result_stream << "bar_group1(int " << i << ") ";
   return i + 2;
 }
 
@@ -158,44 +145,49 @@ void foo_group4(bar_group4&)
 } // end anonymous namespace
 
 
-int main()
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
 #ifdef USING_CPP11_LAMBDA_EXPRESSIONS
 
   // test lambda operators
   int a = 1;
   //std::cout << "(_1 + _2) (3,4):    " << (_1 + _2) (3,4)      << std::endl;
   result_stream << ([] (int a, int b) -> int { return a + b; }(3,4));
-  check_result("7");
+  util->check_result(result_stream, "7");
 
   //std::cout << "(_1 + 1)  (3,4):    " << (_1 + 1)  (3,4)      << std::endl;
   result_stream << ([] (int a, int) -> int { return a + 1; }(3,4));
-  check_result("4");
+  util->check_result(result_stream, "4");
 
   //std::cout << "(_2 + 1)  (3,4):    " << (_2 + 1)  (3,4)      << std::endl;
   result_stream << ([] (int, int b) -> int { return b + 1; }(3,4));
-  check_result("5");
+  util->check_result(result_stream, "5");
 
   //std::cout << "(2 + _1)  (3,4):    " << (2 + _1)  (3,4)      << std::endl;
   result_stream << ([] (int a, int) -> int { return 2 + a; }(3,4));
-  check_result("5");
+  util->check_result(result_stream, "5");
 
   //std::cout << "(2 + _2)  (3,4):    " << (2 + _2)  (3,4)      << std::endl;
   result_stream << ([] (int, int b) -> int { return 2 + b; }(3,4));
-  check_result("6");
+  util->check_result(result_stream, "6");
 
   //std::cout << "(_1+_2*_3)(1,2,3):  " << (_1+_2*_3)(1,2,3)    << std::endl;
   result_stream << ([] (int a, int b, int c) -> int { return a + b*c; }(1,2,3));
-  check_result("7");
+  util->check_result(result_stream, "7");
 
   //std::cout << "((++_1)*2)(1):      " << ((++_1)*2)(1)        << std::endl;
   result_stream << ([] (int a) -> int { return ++a * 2; }(1));
-  check_result("4");
+  util->check_result(result_stream, "4");
 
   //std::cout << "((++_1)*2)(a):      " << ((++_1)*2)(a);
   //std::cout << "; a: "                << a                    << std::endl;
   result_stream << ([] (int x) -> int { return ++x * 2; }(a)) << " " << a;
-  check_result("4 1");
+  util->check_result(result_stream, "4 1");
 
   // gcc can't compile libsigc++ lambda expressions with sigc::ref() parameters.
   // See https://bugzilla.gnome.org/show_bug.cgi?id=669128
@@ -203,41 +195,41 @@ int main()
   //  std::cout << "; a: "                << a                    << std::endl;
   result_stream << ([] (std::reference_wrapper<int> x) -> int { return ++x * 2; }(std::ref(a)));
   result_stream << " " << a;
-  check_result("4 2");
+  util->check_result(result_stream, "4 2");
   result_stream << ([] (int& x) -> int { return ++x * 2; }(a));
   result_stream << " " << a;
-  check_result("6 3");
+  util->check_result(result_stream, "6 3");
 
   //std::cout << "((++(*_1))*2)(&a):  " << ((++(*_1))*2)(&a);
   //std::cout << "; a: "                << a                    << std::endl;
   result_stream << ([] (int* x) -> int { return ++(*x) * 2; }(&a));
   result_stream << " " << a;
-  check_result("8 4");
+  util->check_result(result_stream, "8 4");
 
   //  std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(sigc::ref(a));
   //  std::cout << "; a: "                << a                    << std::endl;
   result_stream << ([] (std::reference_wrapper<int> x) -> int { return --(*(&x)) * 2; }(std::ref(a)));
   result_stream << " " << a;
-  check_result("6 3");
+  util->check_result(result_stream, "6 3");
   result_stream << ([] (int& x) -> int { return --(*(&x)) * 2; }(a));
   result_stream << " " << a;
-  check_result("4 2");
+  util->check_result(result_stream, "4 2");
 
   //std::cout << "(-_1)     (-5):     " << (-_1)     (-5)       << std::endl;
   result_stream << ([] (int x) -> int { return -x; }(-5));
-  check_result("5");
+  util->check_result(result_stream, "5");
 
   //std::cout << "(var(&a)[0])():     " << (sigc::var(&a)[0])() << std::endl;
   result_stream << ([&a]() -> int { return a; }());
-  check_result("2");
+  util->check_result(result_stream, "2");
 
   //std::cout << "(_1[_2])    (&a,0): " << (_1[_2])    (&a,0)   << std::endl;
   result_stream << ([] (int* x, int y) -> int { return x[y]; }(&a,0));
-  check_result("2");
+  util->check_result(result_stream, "2");
 
   //std::cout << "(*_1=_2)    (&a,1): " << (*_1=_2)    (&a,1)   << std::endl;
   result_stream << ([] (int* x, int y) -> int { *x = y; return *x; }(&a,1));
-  check_result("1");
+  util->check_result(result_stream, "1");
 
   // Comma operator, https://bugzilla.gnome.org/show_bug.cgi?id=342911
   a = -1;
@@ -248,7 +240,7 @@ int main()
   //std::cout << "; a: " << a << "; b: " << b << "; c: " << c << std::endl;
   result_stream << ([&a,&b,&c](int x, int y) -> int { return c = (a = x, b = y); }(2,3));
   result_stream << " " << a << " " << b << " " << c;
-  check_result("3 2 3 3");
+  util->check_result(result_stream, "3 2 3 3");
 
   // c++ restrictions:
   // - ref() must be used to indicate that the value shall not be copied
@@ -258,23 +250,23 @@ int main()
   // - cannot use "\n" without var() because arrays cannot be copied
   //  (sigc::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))();
   [](){ result_stream << 1 << "\n"; }();
-  check_result("1\n");
+  util->check_result(result_stream, "1\n");
 
   //(sigc::ref(std::cout) << _1 << std::string("\n"))("hello world");
   [](const char* a){ result_stream << a << std::string("\n"); }("hello world");
-  check_result("hello world\n");
+  util->check_result(result_stream, "hello world\n");
 
   //(sigc::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234);
   [](double a){ result_stream << static_cast<int>(a) << std::string("\n"); }(1.234);
-  check_result("1\n");
+  util->check_result(result_stream, "1\n");
 
   //  (sigc::var(std::cout) << 1 << sigc::var("\n"))();
   [](){ result_stream << 1 << "\n"; }();
-  check_result("1\n");
+  util->check_result(result_stream, "1\n");
 
   //(sigc::var(std::cout) << _1 << std::string("\n"))("hello world");
   [](const char* a){ result_stream << a << std::string("\n"); }("hello world");
-  check_result("hello world\n");
+  util->check_result(result_stream, "hello world\n");
 
   // auto-disconnect
   // Here's an area where the libsigc++ lambda expressions are advantageous.
@@ -293,40 +285,40 @@ int main()
     // sl1 = printable_guest_book; // no auto-disconnect, no error; a copy is stored in sl1
     sl1 = sigc::mem_fun(printable_guest_book, &printable_book::operator());
     sl1(result_stream);
-    check_result("karl\n");
+    util->check_result(result_stream, "karl\n");
 
   } // auto-disconnect
 
   sl1(result_stream);
-  check_result("");
+  util->check_result(result_stream, "");
 
   // test group adaptor, here replaced by std::bind
   bar the_bar;
   //std::cout << (sigc::group(&foo, _1, _2)) (1, 2) << std::endl;
   result_stream << std::bind(&foo, std::placeholders::_1, std::placeholders::_2)(1, 2);
-  check_result("foo(int 1, int 2)6");
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
 
   //std::cout << (sigc::group(&foo, _2, _1)) (1, 2) << std::endl;
   result_stream << std::bind(&foo, std::placeholders::_2, std::placeholders::_1)(1, 2);
-  check_result("foo(int 2, int 1)9");
+  util->check_result(result_stream, "foo(int 2, int 1) 9");
 
   //std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (sigc::ref(the_bar), 1, 2) << std::endl;
   result_stream << std::bind(std::mem_fn(&bar::test), std::placeholders::_1,
     std::placeholders::_2, std::placeholders::_3)(std::ref(the_bar), 1, 2);
-  check_result("bar::test(int 1, int 2)6");
+  util->check_result(result_stream, "bar::test(int 1, int 2) 6");
 
   // same functionality as bind
   //std::cout << (sigc::group(&foo, _1, 2))  (1)    << std::endl;
   result_stream << std::bind(&foo, std::placeholders::_1, 2)(1);
-  check_result("foo(int 1, int 2)6");
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
 
   //std::cout << (sigc::group(&foo, 1, 2))   ()     << std::endl;
   result_stream << std::bind(&foo, 1, 2)();
-  check_result("foo(int 1, int 2)6");
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
 
   //(sigc::group(sigc::ptr_fun(&foo_void), 1)) ();
   std::bind(sigc::ptr_fun(&foo_void), 1)();
-  check_result("foo_void(int 1)");
+  util->check_result(result_stream, "foo_void(int 1)");
 
   // auto-disconnect
   sigc::slot<void> sl2;
@@ -337,36 +329,36 @@ int main()
     // sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3)
     sl2 = sigc::bind(&egon, sigc::ref(guest_book));
     sl2();
-    check_result("egon(string 'karl')");
+    util->check_result(result_stream, "egon(string 'karl')");
 
     //std::cout << static_cast<std::string&>(guest_book) << std::endl;
     result_stream << static_cast<std::string&>(guest_book);
-    check_result("egon was here");
+    util->check_result(result_stream, "egon was here");
 
   } // auto-disconnect
 
   sl2();
-  check_result("");
+  util->check_result(result_stream, "");
 
   // same functionality as hide
   //std::cout << (sigc::group(&foo, _1, _2)) (1,2,3) << std::endl;
   result_stream << std::bind(&foo, std::placeholders::_1, std::placeholders::_2)(1,2,3);
-  check_result("foo(int 1, int 2)6");
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
 
   //(sigc::group(sigc::ptr_fun(&foo_void), _2)) (1, 2);
   std::bind(&foo_void, std::placeholders::_2)(1, 2);
-  check_result("foo_void(int 2)");
+  util->check_result(result_stream, "foo_void(int 2)");
 
   // same functionality as compose
   //std::cout << (sigc::group(&foo, sigc::group(&foo, _1, _2), _3)) (1,2,3) << std::endl;
   result_stream << std::bind(&foo, std::bind(&foo, std::placeholders::_1, std::placeholders::_2),
     std::placeholders::_3)(1,2,3);
-  check_result("foo(int 1, int 2)foo(int 6, int 3)27");
+  util->check_result(result_stream, "foo(int 1, int 2) foo(int 6, int 3) 27");
 
   // same functionality as retype
   //std::cout << (sigc::group(&foo, sigc::static_cast_<int>(_1), 2)) (1.234) << std::endl;
   result_stream << ([] (double x) -> int { return foo(static_cast<int>(x), 2); }(1.234));
-  check_result("foo(int 1, int 2)6");
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
 
   // Code examples with C++11 lambda expressions and std::bind, which can replace
   // libsigc++ examples in the documentation of libsigc++ lambdas and sigc::group.
@@ -376,19 +368,19 @@ int main()
 
   //std::cout << sigc::_1(10,20,30); // returns 10
   result_stream << ([] (int x, int, int) -> int { return x; }(10,20,30));
-  check_result("10");
+  util->check_result(result_stream, "10");
 
   //std::cout << sigc::_2(10,20,30); // returns 20
   result_stream << ([] (int, int y, int) -> int { return y; }(10,20,30));
-  check_result("20");
+  util->check_result(result_stream, "20");
 
   //std::cout << (sigc::_1 + 5)(3); // returns (3 + 5)
   result_stream << ([] (int x) -> int { return x + 5; }(3));
-  check_result("8");
+  util->check_result(result_stream, "8");
 
   //std::cout << (sigc::_1 * sigc::_2)(7,10); // returns (7 * 10)
   result_stream << ([] (int x, int y) -> int { return x * y; }(7,10));
-  check_result("70");
+  util->check_result(result_stream, "70");
 
   //int main(int argc, char* argv[])
   //{
@@ -411,11 +403,11 @@ int main()
 
     data = 3;
     result_stream << readValue();
-    check_result("3");
+    util->check_result(result_stream, "3");
 
     data = 5;
     result_stream << readValue();
-    check_result("5");
+    util->check_result(result_stream, "5");
   }
 
   //--- sigc++/adaptors/lambda/macros/group.h.m4
@@ -423,31 +415,31 @@ int main()
   // argument binding ...
   //sigc::group(&foo,10,sigc::_1)(20); //fixes the first argument and calls foo(10,20)
   std::bind(&foo_group1, 10, std::placeholders::_1)(20);
-  check_result("foo_group1(int 10, int 20)");
+  util->check_result(result_stream, "foo_group1(int 10, int 20)");
 
   //sigc::group(&foo,sigc::_1,30)(40); //fixes the second argument and calls foo(40,30)
   std::bind(&foo_group1, std::placeholders::_1, 30)(40);
-  check_result("foo_group1(int 40, int 30)");
+  util->check_result(result_stream, "foo_group1(int 40, int 30)");
 
   // argument reordering ...
   //sigc::group(&foo,sigc::_2,sigc::_1)(1,2); //calls foo(2,1)
   std::bind(&foo_group1, std::placeholders::_2, std::placeholders::_1)(1,2);
-  check_result("foo_group1(int 2, int 1)");
+  util->check_result(result_stream, "foo_group1(int 2, int 1)");
 
   // argument hiding ...
   //sigc::group(&foo,sigc::_1,sigc::_2)(1,2,3); //calls foo(1,2)
   std::bind(&foo_group1, std::placeholders::_1, std::placeholders::_2)(1,2,3);
-  check_result("foo_group1(int 1, int 2)");
+  util->check_result(result_stream, "foo_group1(int 1, int 2)");
 
   // functor composition ...
   //sigc::group(&foo,sigc::_1,sigc::group(&bar,sigc::_2))(1,2); //calls foo(1,bar(2))
   std::bind(&foo_group1,  std::placeholders::_1, std::bind(&bar_group1, std::placeholders::_2))(1,2);
-  check_result("bar_group1(int 2)foo_group1(int 1, int 4)");
+  util->check_result(result_stream, "bar_group1(int 2) foo_group1(int 1, int 4)");
 
   // algebraic expressions ...
   // sigc::group(&foo,sigc::_1*sigc::_2,sigc::_1/sigc::_2)(6,3); //calls foo(6*3,6/3)
   [] (int x, int y) { foo_group1(x*y, x/y); }(6,3);
-  check_result("foo_group1(int 18, int 2)");
+  util->check_result(result_stream, "foo_group1(int 18, int 2)");
 
   {
     sigc::signal<void,int,int> some_signal;
@@ -455,7 +447,7 @@ int main()
     //some_signal.connect(std::bind(&foo_group2, std::placeholders::_2)); // does not compile (gcc 4.6.3)
     some_signal.connect([](int, int y) { foo_group2(y); });
     some_signal.emit(1,2);
-    check_result("foo_group2(int 2)");
+    util->check_result(result_stream, "foo_group2(int 2)");
   }
 
   {
@@ -466,8 +458,8 @@ int main()
     //some_signal.connect(sigc::bind(&foo_group3, sigc::ref(some_int))); // compiles, but we prefer std::bind() or C++11 lambda
     some_signal.connect([&some_int](){ foo_group3(some_int); });
     some_signal.emit();
-    result_stream << some_int;
-    check_result("foo_group3(int 0)1");
+    result_stream << " " << some_int;
+    util->check_result(result_stream, "foo_group3(int 0) 1");
   }
 
   {
@@ -480,15 +472,15 @@ int main()
       //some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
       some_signal.connect(sigc::bind(&foo_group4, sigc::ref(some_bar)));
       some_signal.emit();
-      check_result("foo_group4(bar_group4&)");
+      util->check_result(result_stream, "foo_group4(bar_group4&)");
     }
     some_signal.emit();
-    check_result("");
+    util->check_result(result_stream, "");
   }
 
 #else // not USING_CPP11_LAMBDA_EXPRESSIONS
   std::cout << "The compiler capabilities don't allow test of C++11 lambda expressions." << std::endl;
 #endif
 
-  return result_ok ? EXIT_SUCCESS : EXIT_FAILURE;
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_custom.cc b/tests/test_custom.cc
index 93164f9..5d9be6d 100644
--- a/tests/test_custom.cc
+++ b/tests/test_custom.cc
@@ -2,9 +2,26 @@
 // and execute your test code against the exact same library that you are
 // currently hacking.
 
+#include "testutilities.h"
+#include <sstream>
+#include <cstdlib>
 #include <sigc++/sigc++.h>
 
-int main(int, char**)
+namespace
 {
-  return 0;
+std::ostringstream result_stream;
+
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
+{
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  result_stream << "Example result string";
+  util->check_result(result_stream, "Example result string");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_deduce_result_type.cc b/tests/test_deduce_result_type.cc
index c6d52c0..d8ddf93 100644
--- a/tests/test_deduce_result_type.cc
+++ b/tests/test_deduce_result_type.cc
@@ -3,46 +3,63 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
-#include <iostream>
+#include "testutilities.h"
+#include <sstream>
+#include <cstdlib>
 #include <sigc++/sigc++.h>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-
 namespace
 {
+std::ostringstream result_stream;
 
 template <class T>
 void bar(T)
-{ std::cout << "unknown" << std::endl; }
+{
+  result_stream << "unknown";
+}
 
 template <>
 void bar<int>(int)
-{ std::cout << "int" << std::endl; }
+{
+  result_stream << "int";
+}
 
 template <>
 void bar<double>(double)
-{ std::cout << "double" << std::endl; }
+{
+  result_stream << "double";
+}
 
 struct foo : public sigc::functor_base
 {
   typedef double result_type;
-  int operator()(int i=1);
-  double operator()(const int&,int);
+
+  int operator()(int i = 1);
+  double operator()(const int&, int);
 };
 
 struct foo2 :public foo
 {};
 
-} // anonymous namespace
+} // end anonymous namespace
 
-int main(int, char**)
+int main(int argc, char* argv[])
 {
-  bar(sigc::deduce_result_type<foo2,long>::type());
-  bar(sigc::deduce_result_type<foo2,int,int>::type());
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  bar(sigc::deduce_result_type<foo2, long>::type());
+  util->check_result(result_stream, "double");
+
+  bar(sigc::deduce_result_type<foo2, int, int>::type());
+  util->check_result(result_stream, "double");
+
 #ifdef FAIL
-  bar(sigc::deduce_result_type<foo2,int,int,int>::type());
+  bar(sigc::deduce_result_type<foo2, int, int, int>::type());
+  util->check_result(result_stream, "double");
 #endif
 
-  return 0;
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_disconnect.cc b/tests/test_disconnect.cc
index baca390..745c5de 100644
--- a/tests/test_disconnect.cc
+++ b/tests/test_disconnect.cc
@@ -3,56 +3,89 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/trackable.h>
 #include <sigc++/signal.h>
 #include <sigc++/connection.h>
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/functors/mem_fun.h>
-#include <iostream>
+#include <sstream>
+#include <cstdlib>
 
 //The Tru64 compiler seems to need this to avoid an unresolved symbol
 //See bug #161503
 #include <new>
 SIGC_USING_STD(new)
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
+
+int foo(int i)
+{
+  result_stream << "foo(" << i << ") ";
+  return 1;
+}
 
-int foo(int i)    { std::cout << "foo: " << i << std::endl; return 1;}
-int bar(double i) { std::cout << "bar: " << i << std::endl; return 1;}
+int bar(double i)
+{
+  result_stream << "bar(" << i << ") ";
+  return 1;
+}
 
-struct A : public sigc::trackable 
+struct A : public sigc::trackable
 {
-  int foo(int i) { std::cout << "A::foo: " << i << std::endl; return 1;}
+  int foo(int i)
+  {
+    result_stream << "A::foo(" << i << ") ";
+    return 1;
+  }
 };
 
-void good_bye_world() { std::cout << "Good bye world!" << std::endl; }
+void good_bye_world()
+{
+  result_stream << "Good bye world!";
+}
 
 struct B : public sigc::trackable
 {
   B()
-    {
-      sig.connect(sigc::mem_fun(this, &B::destroy));
-      sig.connect(sigc::mem_fun(this, &B::boom));
-      sig.connect(sigc::ptr_fun(&good_bye_world));
-    }
+  {
+    sig.connect(sigc::mem_fun(this, &B::destroy));
+    sig.connect(sigc::mem_fun(this, &B::boom));
+    sig.connect(sigc::ptr_fun(&good_bye_world));
+  }
 
-  void destroy()     // Calling destroy() during signal emission seems weird!
-    { delete this; } // However, if this works, anything will work!
+  void destroy()   // Calling destroy() during signal emission seems weird!
+  {                // However, if this works, anything will work!
+    delete this;
+  }
 
   void boom()
-    { std::cout << "boom!" << std::endl; }
+  {
+    result_stream << "boom!";
+  }
 
   void emit()
-    { sig.emit(); }
+  {
+    sig.emit();
+  }
 
   sigc::signal<void> sig;
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
-  sigc::signal<int,int> sig;
-  sigc::signal<int,int>::iterator confoo, conbar;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  sigc::signal<int, int> sig;
+  sigc::signal<int, int>::iterator confoo;
+  sigc::signal<int, int>::iterator conbar;
   sigc::connection cona;  // connection objects are safe to use beyond the life time of a signal.
 
   {
@@ -60,33 +93,44 @@ int main()
     sig.connect(sigc::mem_fun1(&a, &A::foo));
     confoo = sig.connect(sigc::ptr_fun1(&foo));
     conbar = sig.connect(sigc::ptr_fun1(&bar));
-    std::cout << "sig is connected to A::foo, foo, bar (size=" << sig.size() << "): " << std::endl;
+    result_stream << "sig is connected to A::foo, foo, bar (size=" << sig.size() << "): ";
     sig(1);
+    util->check_result(result_stream,
+      "sig is connected to A::foo, foo, bar (size=3): A::foo(1) foo(1) bar(1) ");
   }                     // auto disconnection! iterators stay valid after disconnections.
 
-  std::cout << "sig is connected to foo, bar (size=" << sig.size() << "): " << std::endl;
+  result_stream << "sig is connected to foo, bar (size=" << sig.size() << "): ";
   sig(2);
+  util->check_result(result_stream, "sig is connected to foo, bar (size=2): foo(2) bar(2) ");
 
   A a;                  // iterators stay valid after further connections.
   cona = sig.slots().insert(conbar, sigc::mem_fun1(&a, &A::foo));
-  std::cout << "sig is connected to foo, A::foo, bar (size=" << sig.size() << "): " << std::endl;
+  result_stream << "sig is connected to foo, A::foo, bar (size=" << sig.size() << "): ";
   sig(3);
+  util->check_result(result_stream,
+    "sig is connected to foo, A::foo, bar (size=3): foo(3) A::foo(3) bar(3) ");
 
   conbar->disconnect(); // manual disconnection
-  std::cout << "sig is connected to foo, A::foo (size=" << sig.size() << "): " << std::endl;
+  result_stream << "sig is connected to foo, A::foo (size=" << sig.size() << "): ";
   sig(4);
+  util->check_result(result_stream, "sig is connected to foo, A::foo (size=2): foo(4) A::foo(4) ");
 
   confoo->disconnect(); // manual disconnection
-  std::cout << "sig is connected to A::foo (size=" << sig.size() << "): " << std::endl;
+  result_stream << "sig is connected to A::foo (size=" << sig.size() << "): ";
   sig(5);
+  util->check_result(result_stream, "sig is connected to A::foo (size=1): A::foo(5) ");
 
   cona.disconnect();    // manual disconnection
-  std::cout << "sig is empty (size=" << sig.size() << "): " << std::endl;
+  result_stream << "sig is empty (size=" << sig.size() << "): ";
   sig(6);
+  util->check_result(result_stream, "sig is empty (size=0): ");
 
   cona.disconnect();    // already disconnected -> legal with connection objects, however, nothing happens ...
 
-  std::cout << "deleting a signal during emission..." << std::endl;
+  result_stream << "deleting a signal during emission... ";
   B* b = new B;
   b->emit();
+  util->check_result(result_stream, "deleting a signal during emission... Good bye world!");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_disconnect_during_emit.cc b/tests/test_disconnect_during_emit.cc
index 735fa05..d49d9df 100644
--- a/tests/test_disconnect_during_emit.cc
+++ b/tests/test_disconnect_during_emit.cc
@@ -3,15 +3,18 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/trackable.h>
 #include <sigc++/signal.h>
 #include <sigc++/connection.h>
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/functors/mem_fun.h>
-#include <iostream>
+#include <sstream>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
 
 sigc::connection connection;
 
@@ -20,17 +23,26 @@ class HandlerClass : public sigc::trackable
 public:
   void handler()
   {
-    std::cout << "handler called" << std::endl;
+    result_stream << "handler called";
     connection.disconnect();
   }
 };
-  
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   HandlerClass instance;
-  
+
   sigc::signal<void> signal_test;
-  signal_test.connect( sigc::mem_fun(instance, &HandlerClass::handler) );
+  connection = signal_test.connect(sigc::mem_fun(instance, &HandlerClass::handler));
   signal_test.emit();
+  util->check_result(result_stream, "handler called");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_exception_catch.cc b/tests/test_exception_catch.cc
index 8c6fa0d..c048f29 100644
--- a/tests/test_exception_catch.cc
+++ b/tests/test_exception_catch.cc
@@ -3,58 +3,83 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/exception_catch.h>
-#include <iostream>
+#include <sstream>
 #include <stdexcept>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(cerr)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(exception)
+namespace
+{
+std::ostringstream result_stream;
 
 struct f : public sigc::functor_base
 {
   typedef int result_type;
-  int operator()(int i) 
-    {std::cout << "f(int "<<i<< ")"<< std::endl; 
-     throw std::range_error("out of range");}
+
+  int operator()(int i)
+  {
+    result_stream << "f(int " << i << ") ";
+    throw std::range_error("out of range ");
+  }
 };
 
 struct g : public sigc::functor_base
 {
   typedef int result_type;
-  int operator()() 
-    {std::cout << "g()" << std::endl;
-     throw std::range_error("out of range");}
+
+  int operator()()
+  {
+    result_stream << "g() ";
+    throw std::range_error("out of range ");
+  }
 };
 
 struct g_void : public sigc::functor_base
 {
   typedef void result_type;
+
   void operator()()
-    {std::cout << "g_void()" << std::endl;
-     throw std::range_error("out of range");}
+  {
+    result_stream << "g_void() ";
+    throw std::range_error("out of range ");
+  }
 };
 
-
 struct my_catch
 {
   int operator()()
   {
-    try { throw; } 
+    try
+    {
+      throw;
+    }
     catch (std::range_error e) // catch what types we know
-      {
-        std::cerr << "caught "<< e.what() <<std::endl;
-      }
+    {
+      result_stream << "caught " << e.what();
+    }
     return 1;
     // all else continues out.
   }
 };
 
+} // end anonymous namespace
 
-int main()
+int main(int argc, char* argv[])
 {
-  std::cout << sigc::exception_catch(f(), my_catch())(1) << std::endl;
-  std::cout << sigc::exception_catch(g(), my_catch())() << std::endl;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  result_stream << sigc::exception_catch(f(), my_catch())(2);
+  util->check_result(result_stream, "f(int 2) caught out of range 1");
+
+  result_stream << sigc::exception_catch(g(), my_catch())();
+  util->check_result(result_stream, "g() caught out of range 1");
+
   sigc::exception_catch(g_void(), my_catch())(); // void test
+  util->check_result(result_stream, "g_void() caught out of range ");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_functor_trait.cc b/tests/test_functor_trait.cc
index 3a0fb0b..c324b67 100644
--- a/tests/test_functor_trait.cc
+++ b/tests/test_functor_trait.cc
@@ -3,20 +3,21 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
-#include <iostream>
+#include "testutilities.h"
+#include <sstream>
+#include <cstdlib>
 #include <sigc++/adaptors/bind.h>
 #include <sigc++/adaptors/compose.h>
 #include <sigc++/functors/mem_fun.h>
 #include <sigc++/functors/ptr_fun.h>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-
 namespace
 {
+std::ostringstream result_stream;
 
 class trackable {};
-struct A: public trackable { A() {} };
+
+struct A : public trackable { A() {} };
 
 template <class T_type, bool I_derived = sigc::is_base_and_derived<trackable,T_type>::value>
 struct with_trackable;
@@ -25,27 +26,42 @@ template <class T_type>
 struct with_trackable<T_type,false>
 {
   static void perform(const T_type&)
-  { std::cout << "other" <<std::endl; }
+  {
+    result_stream << "other ";
+  }
 };
 
 template <class T_type>
 struct with_trackable<T_type,true>
 {
   static void perform(const T_type&)
-  { std::cout << "trackable" << std::endl; }
+  {
+    result_stream << "trackable ";
+  }
+
   static void perform(T_type*)
-  { std::cout << "trackable*" << std::endl; }
+  {
+    result_stream << "trackable* ";
+  }
+
   static void perform(const T_type*)
-  { std::cout << "const trackable*" << std::endl; }
+  {
+    result_stream << "const trackable* ";
+  }
 };
 
 struct print
 {
   void operator()(int i) const
-    { std::cout << "int: "<< i << std::endl; }
+  {
+    result_stream << "int: " << i;
+  }
+
   template <class T>
   void operator()(const T& t) const
-    { with_trackable<T>::perform(t); }
+  {
+    with_trackable<T>::perform(t);
+  }
 };
 
 void foo(int, int, int)
@@ -54,16 +70,30 @@ void foo(int, int, int)
 void bar(int)
 {}
 
-} // anonymous namespace
+} // end anonymous namespace
 
-int main(int, char**)
+int main(int argc, char* argv[])
 {
-  int i = 1, j = 2, k = 3;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  int i = 1;
+  int j = 2;
+  int k = 3;
   A a;
-  std::cout << "hit all targets" << std::endl;
+  result_stream << "hit all targets: ";
   sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), i), sigc::ptr_fun1(&bar)));
-  std::cout << "hit all ints" << std::endl;
+  util->check_result(result_stream, "hit all targets: other other ");
+
+  result_stream << "hit all ints: ";
   sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j),sigc::ptr_fun1(&bar)));
-  std::cout << "hit all trackable" << std::endl;
+  util->check_result(result_stream, "hit all ints: ");
+
+  result_stream << "hit all trackable: ";
   sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), k),sigc::ptr_fun1(&bar)));
+  util->check_result(result_stream, "hit all trackable: ");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_hide.cc b/tests/test_hide.cc
index 1d3149b..f2bfa30 100644
--- a/tests/test_hide.cc
+++ b/tests/test_hide.cc
@@ -3,37 +3,68 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/hide.h>
-#include <iostream>
+#include <sstream>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
 
 struct foo : public sigc::functor_base
 {
   // choose a type that can hold all return values
   typedef int result_type;
+
   int operator()()
-    {std::cout << "foo()"<<std::endl; return true;}
-  int operator()(int j) 
-    {std::cout << "foo(int "<<j<<")"<<std::endl; return 1+j;}
+  {
+    result_stream << "foo() ";
+    return true;
+  }
+
+  int operator()(int j)
+  {
+    result_stream << "foo(int " << j << ") ";
+    return 1 + j;
+  }
 };
 
 struct foo_void : public sigc::functor_base
 {
   typedef void result_type;
+
   void operator()()
-    {std::cout << "foo_void()"<<std::endl;}
+  {
+    result_stream << "foo_void()";
+  }
 };
 
-namespace sigc { SIGC_FUNCTOR_TRAIT(foo,bool) }
+} // end anonymous namespace
 
+namespace sigc { SIGC_FUNCTOR_TRAIT(foo,bool) }
 
-int main()
+int main(int argc, char* argv[])
 {
-  std::cout << sigc::hide<0>(foo())(1,2) << std::endl;
-  std::cout << sigc::hide<1>(foo())(1,2) << std::endl;
-  std::cout << sigc::hide<-1>(foo())(1) << std::endl;
-  std::cout << sigc::hide(foo())(1) << std::endl;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  result_stream << sigc::hide<0>(foo())(1, 2);
+  util->check_result(result_stream, "foo(int 2) 3");
+
+  result_stream << sigc::hide<1>(foo())(1, 2);
+  util->check_result(result_stream, "foo(int 1) 2");
+
+  result_stream << sigc::hide<-1>(foo())(1);
+  util->check_result(result_stream, "foo() 1");
+
+  result_stream << sigc::hide(foo())(1);
+  util->check_result(result_stream, "foo() 1");
+
   sigc::hide(foo_void())(1); // void test
+  util->check_result(result_stream, "foo_void()");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_lambda.cc b/tests/test_lambda.cc
index fd844ec..f155c4c 100644
--- a/tests/test_lambda.cc
+++ b/tests/test_lambda.cc
@@ -3,16 +3,13 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
-#include <iostream>
+#include "testutilities.h"
+#include <sstream>
 #include <string>
+#include <cstdlib>
 #include <sigc++/functors/functors.h>
 #include <sigc++/adaptors/lambda/lambda.h>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(string)
-SIGC_USING_STD(ostream)
-
 using sigc::_1;
 using sigc::_2;
 using sigc::_3;
@@ -24,107 +21,203 @@ using sigc::_7;
 // other template libraries (e.g. boost::lambda) have similar hacks built in
 // to make lambda shift operators work with streams
 namespace sigc {
+// There is no std::basic_ostringstream<>& std::basic_ostringstream<>::operator<<(T_arg a1).
+// "my_ostringstream << xyz;" invokes std::basic_ostream<>& std::basic_ostream<>::operator<<(T_arg a1),
+// which returns std::basic_ostream<>&.
+template <class T_arg>
+struct lambda_action_deduce_result_type<bitwise<leftshift>, std::ostringstream&, T_arg>
+{
+  typedef std::ostream& type;
+};
+
 template <class T_arg>
 struct lambda_action_deduce_result_type<bitwise<leftshift>, std::ostream&, T_arg>
 {
   typedef std::ostream& type;
 };
-}
+} // end namespace sigc
+
+namespace
+{
+std::ostringstream result_stream;
 
 int foo(int i, int j)
-  {std::cout << "foo(int "<<i<<", int "<<j<<")" << std::endl; return 4*i+j;}
+{
+  result_stream << "foo(int " << i << ", int " << j << ") ";
+  return 4*i + j;
+}
 
 void foo_void(int i)
-  {std::cout << "foo_void(int "<<i<<")" << std::endl;}
+{
+  result_stream << "foo_void(int " << i << ")";
+}
 
 struct bar
 {
   int test(int i, int j)
-    {std::cout << "bar::test(int "<<i<<", int "<<j<<")" << std::endl; return 4*i+j;}
+  {
+    result_stream << "bar::test(int " << i << ", int " << j << ") ";
+    return 4*i + j;
+  }
+
   void test_void(int i)
-    {std::cout << "bar::test_void(int "<<i<<")" << std::endl;}
+  {
+    result_stream << "bar::test_void(int " << i << ")";
+  }
 };
 
 void egon(std::string& str)
-  {std::cout << "egon(string '"<<str<<"')" << std::endl; str="egon was here";}
+{
+  result_stream << "egon(string '" << str << "')";
+  str = "egon was here";
+}
 
 struct book : public sigc::trackable
 {
-  book(const std::string& name) : name_(name) {}
-  operator std::string& () {return name_;}
+  explicit book(const std::string& name) : name_(name) {}
+  operator std::string& () { return name_; }
   std::string name_;
 };
 
-inline std::ostream& operator << (std::ostream& s, const book& b) { s << b.name_; return s; }
+inline std::ostringstream& operator << (std::ostringstream& s, const book& b)
+{
+  s << b.name_;
+  return s;
+}
 
+} // end anonymous namespace
 
-int main()
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   // test lambda operators
   int a = 1;
-  std::cout << "(_1 + _2) (3,4):    " << (_1 + _2) (3,4)      << std::endl;
-  std::cout << "(_1 + 1)  (3,4):    " << (_1 + 1)  (3,4)      << std::endl;
-  std::cout << "(_2 + 1)  (3,4):    " << (_2 + 1)  (3,4)      << std::endl;
-  std::cout << "(2 + _1)  (3,4):    " << (2 + _1)  (3,4)      << std::endl;
-  std::cout << "(2 + _2)  (3,4):    " << (2 + _2)  (3,4)      << std::endl;
-  std::cout << "(_1+_2*_3)(1,2,3):  " << (_1+_2*_3)(1,2,3)    << std::endl;
-  std::cout << "((++_1)*2)(1):      " << ((++_1)*2)(1)        << std::endl;
-  std::cout << "((++_1)*2)(a):      " << ((++_1)*2)(a);
-  std::cout << "; a: "                << a                    << std::endl;
+  result_stream << "(_1 + _2) (3,4):    " << (_1 + _2) (3,4);
+  util->check_result(result_stream, "(_1 + _2) (3,4):    7");
+
+  result_stream << "(_1 + 1)  (3,4):    " << (_1 + 1)  (3,4);
+  util->check_result(result_stream, "(_1 + 1)  (3,4):    4");
+
+  result_stream << "(_2 + 1)  (3,4):    " << (_2 + 1)  (3,4);
+  util->check_result(result_stream, "(_2 + 1)  (3,4):    5");
+
+  result_stream << "(2 + _1)  (3,4):    " << (2 + _1)  (3,4);
+  util->check_result(result_stream, "(2 + _1)  (3,4):    5");
+
+  result_stream << "(2 + _2)  (3,4):    " << (2 + _2)  (3,4);
+  util->check_result(result_stream, "(2 + _2)  (3,4):    6");
+
+  result_stream << "(_1+_2*_3)(1,2,3):  " << (_1+_2*_3)(1,2,3);
+  util->check_result(result_stream, "(_1+_2*_3)(1,2,3):  7");
+
+  result_stream << "((++_1)*2)(1):      " << ((++_1)*2)(1);
+  util->check_result(result_stream, "((++_1)*2)(1):      4");
+
+  result_stream << "((++_1)*2)(a):      " << ((++_1)*2)(a);
+  result_stream << "; a: "                << a;
+  util->check_result(result_stream, "((++_1)*2)(a):      4; a: 1");
+
 // gcc can't compile lambda functions with sigc::ref() parameters.
 // See https://bugzilla.gnome.org/show_bug.cgi?id=669128
 // TODO: Can the compilation problems be fixed?
-//  std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(sigc::ref(a));
-//  std::cout << "; a: "                << a                    << std::endl;
-  std::cout << "((++(*_1))*2)(&a):  " << ((++(*_1))*2)(&a);
-  std::cout << "; a: "                << a                    << std::endl;
-//  std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(sigc::ref(a));
-//  std::cout << "; a: "                << a                    << std::endl;
-  std::cout << "(-_1)     (-5):     " << (-_1)     (-5)       << std::endl;
-  std::cout << "(var(&a)[0])():     " << (sigc::var(&a)[0])() << std::endl;
-  std::cout << "(_1[_2])    (&a,0): " << (_1[_2])    (&a,0)   << std::endl;
-  std::cout << "(*_1=_2)    (&a,1): " << (*_1=_2)    (&a,1)   << std::endl;
+//  result_stream << "((++_1)*2)(ref(a)): " << ((++_1)*2)(sigc::ref(a));
+//  result_stream << "; a: "                << a;
+//  util->check_result(result_stream, "((++_1)*2)(ref(a)): 4; a: 2");
+
+  result_stream << "((++(*_1))*2)(&a):  " << ((++(*_1))*2)(&a);
+  result_stream << "; a: "                << a;
+  util->check_result(result_stream, "((++(*_1))*2)(&a):  4; a: 2");
+
+//  result_stream << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(sigc::ref(a));
+//  result_stream << "; a: "                << a;
+//  util->check_result(result_stream, "((--(*(&_1)))*2)(ref(a)): 4; a: 2");
+
+  result_stream << "(-_1)     (-5):     " << (-_1)     (-5);
+  util->check_result(result_stream, "(-_1)     (-5):     5");
+
+  result_stream << "(var(&a)[0])():     " << (sigc::var(&a)[0])();
+  util->check_result(result_stream, "(var(&a)[0])():     2");
+
+  result_stream << "(_1[_2])    (&a,0): " << (_1[_2])    (&a,0);
+  util->check_result(result_stream, "(_1[_2])    (&a,0): 2");
+
+  result_stream << "(*_1=_2)    (&a,1): " << (*_1=_2)    (&a,1);
+  util->check_result(result_stream, "(*_1=_2)    (&a,1): 1");
 
   // Comma operator, https://bugzilla.gnome.org/show_bug.cgi?id=342911
   a = -1;
   int b = -1;
   int c = -1;
-  std::cout << "(var(c) = (var(a) = _1, var(b) = _2))(2,3): "
-            << (sigc::var(c) = (sigc::var(a) = _1, sigc::var(b) = _2))(2,3);
-  std::cout << "; a: " << a << "; b: " << b << "; c: " << c << std::endl;
-
-       // c++ restrictions:
-       // - ref() must be used to indicate that the value shall not be copied
-       // - constant() is used to create a lambda and delay execution of "std::cout << 1"
-       // - var() is used to create a lambda that holds a reference and is interchangable with ref() in lambda operator expressions
-       // - cannot use std::endl without much hackery because it is defined as a template function
-       // - cannot use "\n" without var() because arrays cannot be copied
-//  (sigc::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))();
-  (sigc::ref(std::cout) << _1 << std::string("\n"))("hello world");
-  (sigc::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234);
-//  (sigc::var(std::cout) << 1 << sigc::var("\n"))();
-  (sigc::var(std::cout) << _1 << std::string("\n"))("hello world");
+  result_stream << "(var(c) = (var(a) = _1, var(b) = _2))(2,3): "
+                << (sigc::var(c) = (sigc::var(a) = _1, sigc::var(b) = _2))(2,3);
+  result_stream << "; a: " << a << "; b: " << b << "; c: " << c;
+  util->check_result(result_stream, "(var(c) = (var(a) = _1, var(b) = _2))(2,3): 3; a: 2; b: 3; c: 3");
+
+  // c++ restrictions:
+  // - ref() must be used to indicate that the value shall not be copied
+  // - constant() is used to create a lambda and delay execution of "result_stream << 1"
+  // - var() is used to create a lambda that holds a reference and is interchangable
+  //   with ref() in lambda operator expressions
+  // - cannot use std::endl without much hackery because it is defined as a template function
+  // - cannot use "\n" without var() because arrays cannot be copied
+
+// sigc::constant was removed 2004-08-21 by commit
+// http://git.gnome.org/browse/libsigc++2/commit/?id=4a09791de9fa79d5f9ec8fbe76bf53ca1cc57ea6
+//  (sigc::ref(result_stream) << sigc::constant(1) << sigc::var("\n"))();
+//  util->check_result(result_stream, "1\n");
+
+  (sigc::ref(result_stream) << _1 << std::string("\n"))("hello world");
+  util->check_result(result_stream, "hello world\n");
+
+  (sigc::ref(result_stream) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234);
+  util->check_result(result_stream, "1\n");
+
+  (sigc::var(result_stream) << 1 << sigc::var("\n"))();
+  util->check_result(result_stream, "1\n");
+
+  (sigc::var(result_stream) << _1 << std::string("\n"))("hello world");
+  util->check_result(result_stream, "hello world\n");
 
   // auto-disconnect
-  sigc::slot<void*> sl1; // TODO: why does the compiler demand void* ?
+  //
+  // The functor returns std::ostream&, but the compiler dislikes both
+  // slot<std::ostream>, slot<std::ostream&> and slot<std::ostream*>.
+  // std::ostream can be implicitly converted to bool, because it has either
+  // operator void*() (before C++11) or operator bool() (since C++11).
+  sigc::slot<bool> sl1;
   {
     book guest_book("karl");
-//    sl1 = (sigc::var(std::cout) << sigc::ref(guest_book) << sigc::var("\n"));
+    sl1 = (sigc::var(result_stream) << sigc::ref(guest_book) << sigc::var("\n"));
     sl1();
-  }    // auto-disconnect // TODO: "Bus error" => fix bug !
+    util->check_result(result_stream, "karl\n");
+  } // auto-disconnect
   sl1(); // :-)
+  util->check_result(result_stream, "");
 
-
-  // test grp adaptor
+  // test group adaptor
   bar the_bar;
-  std::cout << (sigc::group(&foo, _1, _2)) (1, 2) << std::endl;
-  std::cout << (sigc::group(&foo, _2, _1)) (1, 2) << std::endl;
-  std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (sigc::ref(the_bar), 1, 2) << std::endl;
+  result_stream << (sigc::group(&foo, _1, _2)) (1, 2);
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
+
+  result_stream << (sigc::group(&foo, _2, _1)) (1, 2);
+  util->check_result(result_stream, "foo(int 2, int 1) 9");
+
+  result_stream << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (sigc::ref(the_bar), 1, 2);
+  util->check_result(result_stream, "bar::test(int 1, int 2) 6");
 
   // same functionality as bind
-  std::cout << (sigc::group(&foo, _1, 2))  (1)    << std::endl;
-  std::cout << (sigc::group(&foo, 1, 2))   ()     << std::endl;
+  result_stream << (sigc::group(&foo, _1, 2))  (1);
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
+
+  result_stream << (sigc::group(&foo, 1, 2))   ();
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
+
   (sigc::group(sigc::ptr_fun(&foo_void), 1)) ();
+  util->check_result(result_stream, "foo_void(int 1)");
 
   // auto-disconnect
   sigc::slot<void> sl2;
@@ -132,19 +225,29 @@ int main()
     book guest_book("karl");
     sl2 = sigc::group(&egon, sigc::ref(guest_book));
     sl2();
-    std::cout << static_cast<std::string&>(guest_book) << std::endl;
-  }    // auto-disconnect
+    util->check_result(result_stream, "egon(string 'karl')");
+
+    result_stream << static_cast<std::string&>(guest_book);
+    util->check_result(result_stream, "karl");
+
+  } // auto-disconnect
   sl2(); // :-)
+  util->check_result(result_stream, "");
 
   // same functionality as hide
-  std::cout << (sigc::group(&foo, _1, _2)) (1,2,3) << std::endl;
+  result_stream << (sigc::group(&foo, _1, _2)) (1,2,3);
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
+
   (sigc::group(sigc::ptr_fun(&foo_void), _2)) (1, 2);
+  util->check_result(result_stream, "foo_void(int 2)");
 
   // same functionality as compose
-  std::cout << (sigc::group(&foo, sigc::group(&foo, _1, _2), _3)) (1,2,3) << std::endl;
+  result_stream << (sigc::group(&foo, sigc::group(&foo, _1, _2), _3)) (1,2,3);
+  util->check_result(result_stream, "foo(int 1, int 2) foo(int 6, int 3) 27");
 
   // same functionality as retype
-  std::cout << (sigc::group(&foo, sigc::static_cast_<int>(_1), 2)) (1.234) << std::endl;
+  result_stream << (sigc::group(&foo, sigc::static_cast_<int>(_1), 2)) (1.234);
+  util->check_result(result_stream, "foo(int 1, int 2) 6");
 
-  return 0;
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_limit_reference.cc b/tests/test_limit_reference.cc
index 5df3e71..4fe9060 100644
--- a/tests/test_limit_reference.cc
+++ b/tests/test_limit_reference.cc
@@ -1,7 +1,11 @@
+#include "testutilities.h"
 #include <sigc++/sigc++.h>
+#include <sstream>
+#include <cstdlib>
 
 namespace
 {
+std::ostringstream result_stream;
 
 class Base
   : virtual public sigc::trackable
@@ -21,20 +25,41 @@ class Derived
 {
 public:
   void method()
-  {}
+  {
+    result_stream << "method()";
+  }
 };
 
-} // anonymous namespace
+} // end anonymous namespace
 
-int main(int, char**)
+int main(int argc, char* argv[])
 {
-  Derived *instance = new Derived();
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  Derived* instance = new Derived();
   sigc::slot<void> handler = sigc::mem_fun(instance, &Derived::method);
+  handler();
+  util->check_result(result_stream, "method()");
+
   sigc::slot<void> param =
-    sigc::bind(sigc::slot<void, Derived &>(), sigc::ref(*instance));
+    sigc::bind(sigc::slot<void, Derived&>(), sigc::ref(*instance));
+  param();
+  util->check_result(result_stream, "");
+
   sigc::slot<Derived> ret =
     sigc::bind_return(sigc::slot<void>(), sigc::ref(*instance));
+  ret();
+  util->check_result(result_stream, "");
+
   delete instance;
 
-  return 0;
+  handler();
+  param();
+  ret();
+  util->check_result(result_stream, "");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc
index 5a07495..7a3bb11 100644
--- a/tests/test_mem_fun.cc
+++ b/tests/test_mem_fun.cc
@@ -3,88 +3,160 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
-//#include <sigc++/functors/mem_fun.h>
+#include "testutilities.h"
 #include <sigc++/sigc++.h>
-#include <iostream>
+#include <sstream>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+//TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ... #endif around:
+#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
+
+namespace
+{
+std::ostringstream result_stream;
 
 struct test
 {
-void foo(short i1)
-  {std::cout << "const test::foo(short "<< i1<< ')' <<std::endl; }
-void foo_const(int i1) const
-  {std::cout << "const test::foo(int "<< i1<< ')' <<std::endl; }
-void foo_volatile(float i1) volatile
-  {std::cout << "const test::foo(float "<< i1<< ')' <<std::endl; }
-void foo_const_volatile(double i1) const volatile
-  {std::cout << "const test::foo(double "<< i1<< ')' <<std::endl; }
-
-void foo_overloaded(char i1)
-  {std::cout << "const test::foo(char "<< int(i1)<< ')' <<std::endl; }
-/* TODO: put something like #ifndef FORTE ... #endif around:
-void foo_overloaded(short i1)
-  {std::cout << "const test::foo(char "<< (int)i1<< ')' <<std::endl; } */
-double foo_overloaded(int i1,int i2)
-  {std::cout << "test::foo("<<i1<<','<<i2<< ')' <<std::endl; return 1.0;}
+  void foo(short i1)
+  {
+    result_stream << "test::foo(short " << i1 << ')';
+  }
+
+  void foo_const(int i1) const
+  {
+    result_stream << "test::foo_const(int " << i1 << ')';
+  }
+
+  void foo_volatile(float i1) volatile
+  {
+    result_stream << "test::foo_volatile(float " << i1 << ')';
+  }
+
+  void foo_const_volatile(double i1) const volatile
+  {
+    result_stream << "test::foo_const_volatile(double " << i1 << ')';
+  }
+
+  void foo_overloaded(char i1)
+  {
+    result_stream << "test::foo_overloaded(char " << int(i1) << ')';
+  }
+
+#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
+  void foo_overloaded(short i1)
+  {
+    result_stream << "test::foo_overloaded(short " << (int)i1 << ')';
+  }
+#endif
+
+  double foo_overloaded(int i1, int i2)
+  {
+    result_stream << "test::foo_overloaded(int " << i1 << ", int " << i2 << ')';
+    return 1.0;
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
-   { /* test non-const */
-     test t;
-     sigc::mem_fun(&test::foo)(t, 1);  // on reference
-     sigc::mem_fun(&test::foo)(&t, 1); // on pointer
-   }
-   { /* test const */
-     test t;
-     sigc::mem_fun(&test::foo_const)(t, 2);
-     sigc::mem_fun(&test::foo_const)(&t, 2);
-   }
-   { /* test const with const object */
-     const test t=test();
-     sigc::mem_fun(&test::foo_const)(t, 3);
-     sigc::mem_fun(&test::foo_const)(&t, 3);
-   }
-   { /* test non-const volatile */
-     test t;
-     sigc::mem_fun(&test::foo_volatile)(t, 4);  // on reference
-     sigc::mem_fun(&test::foo_volatile)(&t, 4); // on pointer
-   }
-   { /* test const volatile */
-     test t;
-     sigc::mem_fun(&test::foo_const_volatile)(t, 5);  // on reference
-     sigc::mem_fun(&test::foo_const_volatile)(&t, 5); // on pointer
-   }
-   { /* test const volatile with const object */
-     const test t=test();
-     sigc::mem_fun(&test::foo_const_volatile)(t, 6);  // on reference
-     sigc::mem_fun(&test::foo_const_volatile)(&t, 6); // on pointer
-   }
-   { /* test overloaded */
-//     test t;
-/* TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ... #endif around:
-     sigc::mem_fun1<char>(&test::foo_overloaded)(&t,7);
-     sigc::mem_fun1<short>(&test::foo_overloaded)(&t,7); and: */
-     
-/*
-     sigc::mem_fun1(&test::foo_overloaded)(&t, 7);
-     sigc::mem_fun2(&test::foo_overloaded)(&t, 7, 8);
-*/
-   }
-   { /* test bound */
-     test t;
-     sigc::mem_fun(t,&test::foo)(9);
-     sigc::mem_fun(&t,&test::foo)(9);
-     sigc::mem_fun(t,&test::foo_const)(9);
-     sigc::mem_fun(&t,&test::foo_const)(9);
-     sigc::mem_fun(t,&test::foo_volatile)(9);
-     sigc::mem_fun(&t,&test::foo_volatile)(9);
-     
-/* TODO: put something like #ifndef AIX xlC ... #else ... #endif around:
-     sigc::mem_fun2(t,&test::foo_overloaded)(9, 10);
-     sigc::mem_fun2(&t,&test::foo_overloaded)(9, 10);
-*/
-   }
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  { /* test non-const */
+    test t;
+    sigc::mem_fun(&test::foo)(t, 1);  // on reference
+    util->check_result(result_stream, "test::foo(short 1)");
+
+    sigc::mem_fun(&test::foo)(&t, 1); // on pointer
+    util->check_result(result_stream, "test::foo(short 1)");
+  }
+  { /* test const */
+    test t;
+    sigc::mem_fun(&test::foo_const)(t, 2);
+    util->check_result(result_stream, "test::foo_const(int 2)");
+
+    sigc::mem_fun(&test::foo_const)(&t, 2);
+    util->check_result(result_stream, "test::foo_const(int 2)");
+  }
+  { /* test const with const object */
+    const test t = test();
+    sigc::mem_fun(&test::foo_const)(t, 3);
+    util->check_result(result_stream, "test::foo_const(int 3)");
+
+    sigc::mem_fun(&test::foo_const)(&t, 3);
+    util->check_result(result_stream, "test::foo_const(int 3)");
+  }
+  { /* test non-const volatile */
+    test t;
+    sigc::mem_fun(&test::foo_volatile)(t, 4);  // on reference
+    util->check_result(result_stream, "test::foo_volatile(float 4)");
+
+    sigc::mem_fun(&test::foo_volatile)(&t, 4); // on pointer
+    util->check_result(result_stream, "test::foo_volatile(float 4)");
+  }
+  { /* test const volatile */
+    test t;
+    sigc::mem_fun(&test::foo_const_volatile)(t, 5);  // on reference
+    util->check_result(result_stream, "test::foo_const_volatile(double 5)");
+
+    sigc::mem_fun(&test::foo_const_volatile)(&t, 5); // on pointer
+    util->check_result(result_stream, "test::foo_const_volatile(double 5)");
+  }
+  { /* test const volatile with const object */
+    const test t = test();
+    sigc::mem_fun(&test::foo_const_volatile)(t, 6);  // on reference
+    util->check_result(result_stream, "test::foo_const_volatile(double 6)");
+
+    sigc::mem_fun(&test::foo_const_volatile)(&t, 6); // on pointer
+    util->check_result(result_stream, "test::foo_const_volatile(double 6)");
+  }
+#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
+  { /* test overloaded */
+    test t;
+    sigc::mem_fun1<char>(&test::foo_overloaded)(&t, 7);
+    util->check_result(result_stream, "test::foo_overloaded(char 7)");
+
+    sigc::mem_fun1<short>(&test::foo_overloaded)(&t, 7);
+    util->check_result(result_stream, "test::foo_overloaded(short 7)");
+
+    //sigc::mem_fun1(&test::foo_overloaded)(&t, 7);
+    //util->check_result(result_stream, "test::foo_overloaded(short 7)");
+
+    sigc::mem_fun2(&test::foo_overloaded)(&t, 7, 8);
+    util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)");
+  }
+#endif
+  { /* test bound */
+    test t;
+    sigc::mem_fun(t, &test::foo)(9);
+    util->check_result(result_stream, "test::foo(short 9)");
+
+    sigc::mem_fun(&t, &test::foo)(9);
+    util->check_result(result_stream, "test::foo(short 9)");
+
+    sigc::mem_fun(t, &test::foo_const)(9);
+    util->check_result(result_stream, "test::foo_const(int 9)");
+
+    sigc::mem_fun(&t, &test::foo_const)(9);
+    util->check_result(result_stream, "test::foo_const(int 9)");
+
+    sigc::mem_fun(t, &test::foo_volatile)(9);
+    util->check_result(result_stream, "test::foo_volatile(float 9)");
+
+    sigc::mem_fun(&t, &test::foo_volatile)(9);
+    util->check_result(result_stream, "test::foo_volatile(float 9)");
+
+#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
+    sigc::mem_fun2(t, &test::foo_overloaded)(9, 10);
+    util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
+
+    sigc::mem_fun2(&t, &test::foo_overloaded)(9, 10);
+    util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
+#endif
+  }
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_ptr_fun.cc b/tests/test_ptr_fun.cc
index ca2f8ef..ed809de 100644
--- a/tests/test_ptr_fun.cc
+++ b/tests/test_ptr_fun.cc
@@ -3,38 +3,86 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
-#include <iostream>
-//#include <sigc++/functors/ptr_fun.h>
+#include "testutilities.h"
+#include <sstream>
 #include <sigc++/sigc++.h>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+//TODO: put something like #ifndef FORTE ... #else ... #endif around:
+#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
+
+namespace
+{
+std::ostringstream result_stream;
 
 int foo()
-  {std::cout << "foo()" << std::endl; return 1;}
+{
+  result_stream << "foo()";
+  return 1;
+}
+
 void foo(int i1)
-  {std::cout << "foo(int "<<i1<<")" << std::endl;}
+{
+  result_stream << "foo(int " << i1 << ")";
+}
 
-/* TODO: put something like #ifndef FORTE ... #endif around:
+#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
 void bar(char i1)
-  {std::cout << "foo(char "<<(int)i1<<")" << std::endl;} */
+{
+  result_stream << "bar(char " << (int)i1 << ")";
+}
+#endif
+
 void bar(float i1)
-  {std::cout << "foo(float "<<i1<<")" << std::endl;}
-double bar(int i1,int i2)
-  {std::cout << "foo(int "<<i1<<", int "<<i2<< ")" <<std::endl; return 1.0f;}
+{
+  result_stream << "bar(float " << i1 << ")";
+}
 
-struct test {
-  static void foo() {std::cout << "test::foo()" <<std::endl;}
+double bar(int i1, int i2)
+{
+  result_stream << "bar(int " << i1 << ", int " << i2 << ")";
+  return 1.0f;
+}
+
+struct test
+{
+  static void foo()
+  {
+    result_stream << "test::foo()";
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   sigc::ptr_fun0(&foo)();
+  util->check_result(result_stream, "foo()");
+
   sigc::ptr_fun1(&foo)(1);
-/* TODO: put something like #ifndef FORTE ... #else ... #endif around:
+  util->check_result(result_stream, "foo(int 1)");
+
+#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
   sigc::ptr_fun1<char>(&bar)(2);
-  sigc::ptr_fun1<float>(&bar)(2.0f); and: */
+  util->check_result(result_stream, "bar(char 2)");
+
+  sigc::ptr_fun1<float>(&bar)(2.0f);
+  util->check_result(result_stream, "bar(float 2)");
+#else
   sigc::ptr_fun1(&bar)(2.0f);
-  sigc::ptr_fun2(&bar)(3,5);
+  util->check_result(result_stream, "bar(float 2)");
+#endif
+
+  sigc::ptr_fun2(&bar)(3, 5);
+  util->check_result(result_stream, "bar(int 3, int 5)");
+
   sigc::ptr_fun(&test::foo)();
+  util->check_result(result_stream, "test::foo()");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_retype.cc b/tests/test_retype.cc
index d7a84f1..7c20e07 100644
--- a/tests/test_retype.cc
+++ b/tests/test_retype.cc
@@ -3,45 +3,69 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/retype.h>
-#include <iostream>
+#include <sstream>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
 
 struct foo : public sigc::trackable
 {
-  float test_int(int i) 
+  float test_int(int i)
   {
-    std::cout << "foo(int " << i << ")" << std::endl;
+    result_stream << "foo::test_int(int " << i << ") ";
     return i * 1.5f;
   }
+
   float test_float(float f)
   {
-    std::cout << "foo(float " << f << ")" << std::endl;
+    result_stream << "foo::test_float(float " << f << ") ";
     return f * 5;
   }
 };
 
 void bar(short s)
 {
-  std::cout << "bar(short " << s << ")" << std::endl;
+  result_stream << "bar(short " << s << ")";
 }
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   foo foo_;
-  std::cout << sigc::retype(sigc::mem_fun(foo_, &foo::test_int))(1.234f) << std::endl;
-  std::cout << sigc::retype(sigc::mem_fun(foo_, &foo::test_float))(5) << std::endl;
+  result_stream << sigc::retype(sigc::mem_fun(foo_, &foo::test_int))(1.234f);
+  util->check_result(result_stream, "foo::test_int(int 1) 1.5");
+
+  result_stream << sigc::retype(sigc::mem_fun(foo_, &foo::test_float))(5);
+  util->check_result(result_stream, "foo::test_float(float 5) 25");
+
   sigc::retype(sigc::ptr_fun(&bar))(6.789f);
+  util->check_result(result_stream, "bar(short 6)");
 
   sigc::slot<float,float> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
   sigc::slot<float,int>   s2 = sigc::retype(sigc::mem_fun(foo_, &foo::test_float));
   sigc::slot<void,double> s3 = sigc::retype(sigc::ptr_fun(&bar));
-  std::cout << s1(1.234f) << std::endl;
-  std::cout << s2(5) << std::endl;
+  result_stream << s1(1.234f);
+  util->check_result(result_stream, "foo::test_int(int 1) 1.5");
+
+  result_stream << s2(5);
+  util->check_result(result_stream, "foo::test_float(float 5) 25");
+
   s3(6.789);
+  util->check_result(result_stream, "bar(short 6)");
 
   s2 = sigc::retype(s1);
-  std::cout << s2(5) << std::endl;
+  result_stream << s2(5);
+  util->check_result(result_stream, "foo::test_int(int 5) 7.5");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_retype_return.cc b/tests/test_retype_return.cc
index 89b5627..0125327 100644
--- a/tests/test_retype_return.cc
+++ b/tests/test_retype_return.cc
@@ -3,25 +3,29 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/adaptors/retype_return.h>
 #include <sigc++/functors/slot.h>
-#include <iostream>
+#include <sstream>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
 
 struct foo : public sigc::functor_base
 {
   typedef float result_type;
-  float operator()(int i) 
+
+  float operator()(int i)
   {
-    std::cout << "foo(int " << i << ")" << std::endl;
+    result_stream << "foo(int " << i << ") ";
     return i;
   }
 
-  float operator()(float i) 
+  float operator()(float i)
   {
-    std::cout << "foo(float " << i << ")" << std::endl;
+    result_stream << "foo(float " << i << ") ";
     return i * 5;
   }
 };
@@ -29,22 +33,36 @@ struct foo : public sigc::functor_base
 struct bar : public sigc::trackable, public sigc::functor_base
 {
   typedef int result_type;
+
   int operator()(int i)
   {
-    std::cout << "bar(int " << i << ")" << std::endl;
+    result_stream << "bar(int " << i << ")";
     return i;
   }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   // retype_return<int>
-  std::cout << sigc::retype_return<int>(foo())(1.234f) << std::endl;
+  result_stream << sigc::retype_return<int>(foo())(1.234f);
+  util->check_result(result_stream, "foo(float 1.234) 6");
 
   // retype_return<void> / hide_return
   sigc::slot<void, int> sl;
   sl = sigc::retype_return<void>(bar());
   sl(5);
+  util->check_result(result_stream, "bar(int 5)");
+
   sl = sigc::hide_return(bar());
   sl(6);
+  util->check_result(result_stream, "bar(int 6)");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_signal.cc b/tests/test_signal.cc
index 82bd25b..f8ccae0 100644
--- a/tests/test_signal.cc
+++ b/tests/test_signal.cc
@@ -3,33 +3,60 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/trackable.h>
 #include <sigc++/signal.h>
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/functors/mem_fun.h>
-#include <iostream>
 #include <string>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(string)
+namespace
+{
+std::ostringstream result_stream;
+
+int foo(int i)
+{
+  result_stream << "foo(int " << i << ") ";
+  return 1;
+}
 
-int foo(int i)   {std::cout << "foo(int "<<i<<")" << std::endl; return 1;}
-int bar(float i) {std::cout << "bar(float "<<i<<")" << std::endl; return 1;}
+int bar(float i)
+{
+  result_stream << "bar(float " << i << ") ";
+  return 1;
+}
 
 struct A : public sigc::trackable
 {
-  int  foo(int i)            {std::cout << "A::foo(int "<<i<<")" << std::endl; return 1;}
-  void bar(std::string& str) {std::cout << "A::foo(string '"<<str<<"')" << std::endl; str="foo was here";}
+  int foo(int i)
+  {
+    result_stream << "A::foo(int " << i << ") ";
+    return 1;
+  }
+
+  void bar(std::string& str)
+  {
+    result_stream << "A::foo(string '" << str << "') ";
+    str = "foo was here";
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   // signal
   sigc::signal<int,int> sig;
 
   // emit empty signal
   sig(0);
+  util->check_result(result_stream, "");
 
   // connect some slots before emitting & test auto-disconnection
   {
@@ -38,10 +65,14 @@ int main()
     sig.connect(sigc::mem_fun1(&a, &A::foo));
     sig.connect(sigc::ptr_fun1(&bar));
     sig(1);
-    std::cout << sig.size() << std::endl;
+    result_stream << sig.size();
+    util->check_result(result_stream, "foo(int 1) A::foo(int 1) bar(float 1) 3");
+
   } // a dies => auto-disconnect
-  std::cout << sig.size() << std::endl;
+
   sig(2);
+  result_stream << sig.size();
+  util->check_result(result_stream, "foo(int 2) bar(float 2) 2");
 
   // test reference
   A a;
@@ -49,11 +80,15 @@ int main()
   sigc::signal<void,std::string&> sigstr;
   sigstr.connect(sigc::mem_fun(&a, &A::bar));
   sigstr(str);
-  std::cout << str << std::endl;
+  result_stream << str;
+  util->check_result(result_stream, "A::foo(string 'guest book') foo was here");
 
   // test make_slot()
   sig.connect(sigc::ptr_fun1(&foo));
   sigc::signal<int,int> sig2;
   sig2.connect(sig.make_slot());
   sig2(3);
+  util->check_result(result_stream, "foo(int 3) bar(float 3) foo(int 3) ");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_size.cc b/tests/test_size.cc
index a7188e9..ce1f197 100644
--- a/tests/test_size.cc
+++ b/tests/test_size.cc
@@ -3,33 +3,49 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/sigc++.h>
 #include <iostream>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+// The correct result of this test may be implementation-dependent.
+// No attempt is made to decide if the result is correct.
+// The test will succeed, unless it's started with erroneous command arguments.
+// "./test_size --verbose" shows the sizes.
 
-struct A {
+namespace
+{
+struct A
+{
   void foo();
 };
+} // end anonymous namespace
 
-
-int main()
+int main(int argc, char* argv[])
 {
-  std::cout << "sizes of public classes:" << std::endl;
-
-  std::cout << "  trackable:               " << sizeof(sigc::trackable) << std::endl;
-  std::cout << "  slot<void>:              " << sizeof(sigc::slot<void>) << std::endl;
-  std::cout << "  signal<void>:            " << sizeof(sigc::signal<void>) << std::endl;
-  std::cout << "  signal<void>::iterator:  " << sizeof(sigc::signal<void>::iterator) << std::endl;
-  std::cout << "  connection:              " << sizeof(sigc::connection) << std::endl;
-
-  std::cout << std::endl << "sizes of internal classes:" << std::endl;
-
-  std::cout << "  trackable_callback:      " << sizeof(sigc::internal::trackable_callback) << std::endl;
-  std::cout << "  trackable_callback_list: " << sizeof(sigc::internal::trackable_callback_list) << std::endl;
-  std::cout << "  slot_rep:                " << sizeof(sigc::internal::slot_rep) << std::endl;
-  std::cout << "  typed_slot_rep<mem_functor0<void,A> >: "
-            << sizeof(sigc::internal::typed_slot_rep<sigc::mem_functor0<void,A> >) << std::endl;
-  std::cout << "  signal_impl:             " << sizeof(sigc::internal::signal_impl) << std::endl;
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  if (util->get_verbose())
+  {
+    std::cout << "sizes of public classes:" << std::endl;
+
+    std::cout << "  trackable:               " << sizeof(sigc::trackable) << std::endl;
+    std::cout << "  slot<void>:              " << sizeof(sigc::slot<void>) << std::endl;
+    std::cout << "  signal<void>:            " << sizeof(sigc::signal<void>) << std::endl;
+    std::cout << "  signal<void>::iterator:  " << sizeof(sigc::signal<void>::iterator) << std::endl;
+    std::cout << "  connection:              " << sizeof(sigc::connection) << std::endl;
+
+    std::cout << std::endl << "sizes of internal classes:" << std::endl;
+
+    std::cout << "  trackable_callback:      " << sizeof(sigc::internal::trackable_callback) << std::endl;
+    std::cout << "  trackable_callback_list: " << sizeof(sigc::internal::trackable_callback_list) << std::endl;
+    std::cout << "  slot_rep:                " << sizeof(sigc::internal::slot_rep) << std::endl;
+    std::cout << "  typed_slot_rep<mem_functor0<void,A> >: "
+              << sizeof(sigc::internal::typed_slot_rep<sigc::mem_functor0<void,A> >) << std::endl;
+    std::cout << "  signal_impl:             " << sizeof(sigc::internal::signal_impl) << std::endl;
+  }
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_slot.cc b/tests/test_slot.cc
index 3066663..da1afa2 100644
--- a/tests/test_slot.cc
+++ b/tests/test_slot.cc
@@ -3,44 +3,70 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/functors/slot.h>
-#include <iostream>
+#include <sstream>
 #include <string>
+#include <cstdlib>
 
 //The Tru64 compiler seems to need this to avoid an unresolved symbol
 //See bug #161503
 #include <new>
 SIGC_USING_STD(new)
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(string)
+namespace
+{
+std::ostringstream result_stream;
 
 class foo
 {
-  public:
-  void operator()(int i)            {std::cout << "foo(int "<<i<<")" << std::endl;}
-  void operator()(std::string& str) {std::cout << "foo(string '"<<str<<"')" << std::endl; str="foo was here";}
-  void operator()(int,int)          {std::cout << "foo(int,int)" << std::endl;}
+public:
+  void operator()(int i)
+  {
+    result_stream << "foo(int " << i << ")";
+  }
+
+  void operator()(std::string& str)
+  {
+    result_stream << "foo(string '" << str << "') ";
+    str="foo was here";
+  }
+
+  void operator()(int, int)
+  {
+    result_stream << "foo(int, int)";
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   // simple test
   sigc::slot<void,int> s1 = foo();
   s1(1);
+  util->check_result(result_stream, "foo(int 1)");
+
   s1 = foo();
   s1(2);
+  util->check_result(result_stream, "foo(int 2)");
 
   // test implicit conversion
   sigc::slot<void,char> s2 = foo();
   s2(3);
+  util->check_result(result_stream, "foo(int 3)");
 
   // test reference
   sigc::slot<void,std::string&> sl1 = foo();
   std::string str("guest book");
   sl1(str);
-  std::cout << str << std::endl;
+  result_stream << str;
+  util->check_result(result_stream, "foo(string 'guest book') foo was here");
 
   // test operator=
   str = "guest book";
@@ -48,8 +74,13 @@ int main()
   sl2 = sl1;
   sl1 = sl2;
   sl1(str);
-  std::cout << str << std::endl;
+  result_stream << str;
+  util->check_result(result_stream, "foo(string 'guest book') foo was here");
 
   // test copy ctor
   sigc::slot<void,int> s1_clone(s1);
+  s1_clone(4);
+  util->check_result(result_stream, "foo(int 4)");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_slot_disconnect.cc b/tests/test_slot_disconnect.cc
index d7f1dc5..515c0aa 100644
--- a/tests/test_slot_disconnect.cc
+++ b/tests/test_slot_disconnect.cc
@@ -3,35 +3,47 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
+#include "testutilities.h"
 #include <sigc++/functors/slot.h>
-#include <iostream>
+#include <sstream>
 #include <string>
+#include <cstdlib>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
-SIGC_USING_STD(string)
+namespace
+{
+std::ostringstream result_stream;
 
+void Foo()
+{
+  result_stream << "Foo";
+}
 
-void Foo() { std::cout << "Foo" << std::endl; }
-void Bar() { std::cout << "Bar" << std::endl; }
+void Bar()
+{
+  result_stream << "Bar";
+}
 
+} // end anonymous namespace
 
-int main(void)
+int main(int argc, char* argv[])
 {
-   //sigc::slot<void> nullSlot;
-   
-   sigc::slot<void> theSlot(sigc::ptr_fun(&Foo)); //Note that sigc::ptr_fun() creates a sig::pointer_functor0.
-   theSlot(); //This should output "Foo"
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
-   theSlot.disconnect(); // This seems to do nothing. (because rep::parent_ is 0).
-   theSlot(); //This should cause no output.
+  //Note that sigc::ptr_fun() creates a sig::pointer_functor0.
+  sigc::slot<void> theSlot(sigc::ptr_fun(&Foo));
+  theSlot();
+  util->check_result(result_stream, "Foo");
 
-   theSlot = sigc::ptr_fun(&Bar); // ... but this works.
-   theSlot(); //This should output "Bar".
+  theSlot.disconnect();
+  theSlot();
+  util->check_result(result_stream, "");
 
-   // Expected output:
-   // Foo
-   // Bar
+  theSlot = sigc::ptr_fun(&Bar);
+  theSlot();
+  util->check_result(result_stream, "Bar");
 
-   return 0;
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_trackable.cc b/tests/test_trackable.cc
index 8a9633d..7093ce7 100644
--- a/tests/test_trackable.cc
+++ b/tests/test_trackable.cc
@@ -3,30 +3,48 @@
  *  Assigned to public domain.  Use as you wish without restriction.
  */
 
-#include <iostream>
+#include "testutilities.h"
+#include <sstream>
+#include <cstdlib>
 #include <sigc++/trackable.h>
 #include <sigc++/functors/slot.h>
 #include <sigc++/functors/mem_fun.h>
 
-SIGC_USING_STD(cout)
-SIGC_USING_STD(endl)
+namespace
+{
+std::ostringstream result_stream;
 
 class my_class: public sigc::trackable
 {
 public:
   int i;
-  void foo() { std::cout << i << std::endl; }
+
+  void foo()
+  {
+    result_stream << i;
+  }
 };
 
-int main()
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
 {
+  TestUtilities* util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
   sigc::slot<void> sl;
   {
     my_class t;
     t.i = 10;
     sl = sigc::mem_fun0(&t, &my_class::foo);
     sl();
+    util->check_result(result_stream, "10");
   }
 
   sl();
+  util->check_result(result_stream, "");
+
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/testutilities.cc b/tests/testutilities.cc
new file mode 100644
index 0000000..b5d3d4c
--- /dev/null
+++ b/tests/testutilities.cc
@@ -0,0 +1,92 @@
+/* Copyright (C) 2012 The libsigc++ Development Team
+ *
+ * This file is part of libsigc++.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "testutilities.h"
+
+#include <iostream>
+#include <cstring>
+
+TestUtilities* TestUtilities::instance_ = 0;
+
+TestUtilities::TestUtilities()
+: verbose_(false), result_ok_(true), test_number_(0)
+{
+}
+
+//static
+TestUtilities* TestUtilities::get_instance()
+{
+  if (!instance_)
+    instance_ = new TestUtilities;
+
+  return instance_;
+}
+
+bool TestUtilities::check_command_args(int argc, char* argv[])
+{
+  bool go_on = true; // Whether the caller shall continue program execution.
+  bool print_help = false;
+  for (int argi = 1; argi < argc; ++argi)
+  {
+    if (std::strcmp(argv[argi], "-v") == 0 || std::strcmp(argv[argi], "--verbose") == 0)
+    {
+      verbose_ = true;
+    }
+    else
+    {
+      print_help = true;
+      go_on = false;
+      if (!(std::strcmp(argv[argi], "-h") == 0 || std::strcmp(argv[argi], "--help") == 0))
+      {
+        result_ok_ = false;
+        std::cout << "Unknown command argument: " << argv[argi] << std::endl;
+      }
+    }
+  }
+
+  if (print_help)
+    std::cout << "Usage: " << argv[0] << " [-h|--help] [-v|--verbose]" << std::endl;
+
+  return go_on;
+}
+
+void TestUtilities::check_result(std::ostringstream& result_stream,
+                                 const std::string& expected_result)
+{
+  if (verbose_)
+    std::cout << result_stream.str() << std::endl;
+
+  ++test_number_;
+  if (expected_result != result_stream.str())
+  {
+    std::cerr << "   Test " << test_number_ << std::endl;
+    std::cerr << "Expected \"" << expected_result << "\"" << std::endl;
+    std::cerr << "Got      \"" << result_stream.str() << "\"" << std::endl;
+    result_ok_ = false;
+  }
+  result_stream.str("");
+}
+
+//static
+bool TestUtilities::get_result_and_delete_instance()
+{
+  const bool result = instance_ ? instance_->result_ok_ : true;
+  delete instance_;
+  instance_ = 0;
+  return result;
+}
diff --git a/tests/testutilities.h b/tests/testutilities.h
new file mode 100644
index 0000000..bb7a9a7
--- /dev/null
+++ b/tests/testutilities.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2012 The libsigc++ Development Team
+ *
+ * This file is part of libsigc++.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string>
+#include <sstream>
+
+// Functions used in several test cases in libsigc++.
+// This is a singleton class.
+class TestUtilities
+{
+public:
+  static TestUtilities* get_instance();
+  bool check_command_args(int argc, char* argv[]);
+  void check_result(std::ostringstream& result_stream, const std::string& expected_result);
+  bool get_verbose() const { return verbose_; }
+  bool get_result() const { return result_ok_; }
+
+  // When you are searching for memory leaks with valgrind or a similar program,
+  // you avoid a harmless warning by deleting the instance when you're done with it.
+  static bool get_result_and_delete_instance();
+
+private:
+  // Not copyable. These are not implemented.
+  TestUtilities(const TestUtilities&);
+  TestUtilities& operator=(const TestUtilities&);
+
+  TestUtilities();
+
+  static TestUtilities* instance_;
+  bool verbose_;
+  bool result_ok_;
+  int test_number_;
+};



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]