[glibmm] Actually run all tests, and check some failures.



commit 6edb045a2ec86f67e8a0b3a217c00be6336c05d8
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Feb 24 13:42:57 2011 +0100

    Actually run all tests, and check some failures.
    
    * tests/Makefile.am: Add all tests to TESTS so they are really run during
    make check, instead of just built.
    * tests/giomm_asyncresult_sourceobject/main.cc:
    * tests/giomm_ioerror/main.cc:
    * tests/giomm_simple/main.cc:
    * tests/glibmm_bool_arrayhandle/main.cc:
    * tests/glibmm_bool_vector/main.cc:
    * tests/glibmm_buildfilename/main.cc:
    * tests/glibmm_date/main.cc:
    * tests/glibmm_ustring_compose/main.cc:
    * tests/glibmm_valuearray/main.cc:
    * tests/glibmm_variant/main.cc:
    * tests/glibmm_vector/main.cc: Remove all use of std::cout by default,
    allowing it to be renabled by changing a line.
    Return (or) exit with EXIT_FAILURE after any use of std::cerr, so that
    make check can report it.

 ChangeLog                                    |   21 ++++++
 tests/Makefile.am                            |    2 +-
 tests/giomm_asyncresult_sourceobject/main.cc |   27 ++++++---
 tests/giomm_ioerror/main.cc                  |   12 +++-
 tests/giomm_simple/main.cc                   |   12 +++-
 tests/glibmm_bool_arrayhandle/main.cc        |   16 ++++-
 tests/glibmm_bool_vector/main.cc             |    9 +++-
 tests/glibmm_buildfilename/main.cc           |   17 ++++--
 tests/glibmm_date/main.cc                    |   11 +++-
 tests/glibmm_ustring_compose/main.cc         |   22 +++++--
 tests/glibmm_valuearray/main.cc              |   21 +++++--
 tests/glibmm_variant/main.cc                 |   41 +++++++-----
 tests/glibmm_vector/main.cc                  |   85 ++++++++++++++------------
 13 files changed, 203 insertions(+), 93 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a68e119..4eb6430 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2011-02-24  Murray Cumming  <murrayc murrayc com>
 
+	Actually run all tests, and check some failures.
+
+	* tests/Makefile.am: Add all tests to TESTS so they are really run during 
+	make check, instead of just built.
+	* tests/giomm_asyncresult_sourceobject/main.cc:
+	* tests/giomm_ioerror/main.cc:
+	* tests/giomm_simple/main.cc:
+	* tests/glibmm_bool_arrayhandle/main.cc:
+	* tests/glibmm_bool_vector/main.cc:
+	* tests/glibmm_buildfilename/main.cc:
+	* tests/glibmm_date/main.cc:
+	* tests/glibmm_ustring_compose/main.cc:
+	* tests/glibmm_valuearray/main.cc:
+	* tests/glibmm_variant/main.cc:
+	* tests/glibmm_vector/main.cc: Remove all use of std::cout by default, 
+	allowing it to be renabled by changing a line.
+	Return (or) exit with EXIT_FAILURE after any use of std::cerr, so that 
+	make check can report it.
+
+2011-02-24  Murray Cumming  <murrayc murrayc com>
+
 	Restore the Gio::DBus::Error registration.
 
 	* tools/generate_wrap_init.pl.in: Use a qualified C++ name for the key in 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 66adf20..a1f2aa2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -35,7 +35,7 @@ check_PROGRAMS =				\
 	glibmm_bool_vector/test			\
 	glibmm_bool_arrayhandle/test
 	
-TESTS =	giomm_ioerror_and_iodbuserror/test
+TESTS =	$(check_PROGRAMS)
 
 glibmm_includes = -I$(top_builddir)/glib $(if $(srcdir:.=),-I$(top_srcdir)/glib)
 giomm_includes  = -I$(top_builddir)/gio $(if $(srcdir:.=),-I$(top_srcdir)/gio)
diff --git a/tests/giomm_asyncresult_sourceobject/main.cc b/tests/giomm_asyncresult_sourceobject/main.cc
index 1c9f1a1..9c3bf70 100644
--- a/tests/giomm_asyncresult_sourceobject/main.cc
+++ b/tests/giomm_asyncresult_sourceobject/main.cc
@@ -3,15 +3,24 @@
 
 void on_read_async(const Glib::RefPtr<Gio::AsyncResult>& result)
 {
-  std::cout << "Testing result ... "
-            << (result ? "OK!" : "FAILED!") << std::endl;
-
-  std::cout << "Testing get_source_object from gobj() ... "
-            << (g_async_result_get_source_object(result->gobj()) ? "OK!" : "FAILED!") << std::endl;
-
-  std::cout << "Testing Gio::AsyncResult's get_source_object ... "
-            << (result->get_source_object_base() ? "OK!" : "FAILED!") << std::endl;
-
+  if(!result)
+  {
+    std::cerr << G_STRFUNC << ": result is empty." << std::endl;
+    exit(EXIT_FAILURE);
+  }
+
+  if(!g_async_result_get_source_object(result->gobj()))
+  {
+    std::cerr << G_STRFUNC << ": g_async_result_get_source_object() failed." << std::endl;
+    exit(EXIT_FAILURE);
+  }
+  
+  if(!result->get_source_object_base())
+  {
+    std::cerr << G_STRFUNC << ": result->get_source_object_base() failed." << std::endl;
+    exit(EXIT_FAILURE);
+  }
+ 
   exit(EXIT_SUCCESS);
 }
 
diff --git a/tests/giomm_ioerror/main.cc b/tests/giomm_ioerror/main.cc
index 9875783..c54c427 100644
--- a/tests/giomm_ioerror/main.cc
+++ b/tests/giomm_ioerror/main.cc
@@ -23,11 +23,17 @@ int main(int, char**)
   {
     Glib::RefPtr<Gio::File> file = Gio::File::create_for_path("/etc/fstab");
     if(!file)
+    {
       std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl;
+      return EXIT_FAILURE; 
+    }
 
     Glib::RefPtr<Gio::FileInputStream> stream = file->read();
     if(!stream)
+    {
       std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl;
+      return EXIT_FAILURE; 
+    }
 
     gchar buffer[1000]; //TODO: This is unpleasant.
     memset(buffer, 0, sizeof buffer);
@@ -36,7 +42,10 @@ int main(int, char**)
     if(bytes_read)
       std::cout << "File contents read: " << buffer << std::endl;
     else
+    {
       std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl;
+      return EXIT_FAILURE; 
+    }
   }
   catch(const Gio::Error& ex)
   {
@@ -52,7 +61,8 @@ int main(int, char**)
   }
   catch(const Glib::Exception& ex)
   {
-    std::cerr << "Exception caught: " << ex.what() << std::endl; 
+    std::cerr << "Exception caught: " << ex.what() << std::endl;
+    return EXIT_FAILURE; 
   }
 
   return 0;
diff --git a/tests/giomm_simple/main.cc b/tests/giomm_simple/main.cc
index 0340eb1..f892d0d 100644
--- a/tests/giomm_simple/main.cc
+++ b/tests/giomm_simple/main.cc
@@ -11,11 +11,17 @@ int main(int, char**)
   {
     Glib::RefPtr<Gio::File> file = Gio::File::create_for_path("/etc/fstab");
     if(!file)
+    {
       std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl;
+      return EXIT_FAILURE; 
+    }
 
     Glib::RefPtr<Gio::FileInputStream> stream = file->read();
     if(!stream)
+    {
       std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl;
+      return EXIT_FAILURE; 
+    }
 
     gchar buffer[1000]; //TODO: This is unpleasant.
     memset(buffer, 0, sizeof buffer);
@@ -24,11 +30,15 @@ int main(int, char**)
     if(bytes_read)
       std::cout << "File contents read: " << buffer << std::endl;
     else
+    {
       std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl;
+      return EXIT_FAILURE; 
+    }
   }
   catch(const Glib::Exception& ex)
   {
-    std::cerr << "Exception caught: " << ex.what() << std::endl; 
+    std::cerr << "Exception caught: " << ex.what() << std::endl;
+    return EXIT_FAILURE; 
   }
 
   return 0;
diff --git a/tests/glibmm_bool_arrayhandle/main.cc b/tests/glibmm_bool_arrayhandle/main.cc
index 60c9356..ebf8459 100644
--- a/tests/glibmm_bool_arrayhandle/main.cc
+++ b/tests/glibmm_bool_arrayhandle/main.cc
@@ -21,6 +21,14 @@
 
 #include <glibmm.h>
 
+
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of std::cout:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 const unsigned int magic_limit (5);
 
 void
@@ -54,7 +62,7 @@ c_print_bool_array (gboolean* array)
 {
   for (unsigned int iter (0); iter < magic_limit; ++iter)
   {
-    std::cout << iter << ": " << (array[iter] ? "TRUE" : "FALSE") << "\n";
+    ostr << iter << ": " << (array[iter] ? "TRUE" : "FALSE") << "\n";
   }
 }
 
@@ -78,11 +86,11 @@ int main()
   std::list<bool> l (cxx_get_bool_array ());
   std::deque<bool> d (cxx_get_bool_array ());
 
-  std::cout << "vector:\n";
+  ostr << "vector:\n";
   cxx_print_bool_array (v);
-  std::cout << "list:\n";
+  ostr << "list:\n";
   cxx_print_bool_array (l);
-  std::cout << "deque:\n";
+  ostr << "deque:\n";
   cxx_print_bool_array (d);
 
   return 0;
diff --git a/tests/glibmm_bool_vector/main.cc b/tests/glibmm_bool_vector/main.cc
index d9e3fc6..48085e3 100644
--- a/tests/glibmm_bool_vector/main.cc
+++ b/tests/glibmm_bool_vector/main.cc
@@ -21,6 +21,13 @@
 
 #include <glibmm.h>
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 const unsigned int magic_limit(5);
 
 void
@@ -54,7 +61,7 @@ c_print_bool_array(gboolean* array)
 {
   for(unsigned int iter(0); iter < magic_limit; ++iter)
   {
-    std::cout << iter << ": " <<(array[iter] ? "TRUE" : "FALSE") << "\n";
+    ostr << iter << ": " <<(array[iter] ? "TRUE" : "FALSE") << "\n";
   }
 }
 
diff --git a/tests/glibmm_buildfilename/main.cc b/tests/glibmm_buildfilename/main.cc
index 214a60e..b163d73 100644
--- a/tests/glibmm_buildfilename/main.cc
+++ b/tests/glibmm_buildfilename/main.cc
@@ -2,6 +2,13 @@
 #include <iostream>
 #include <string.h>
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 #define DIR "/dir1/dir_2/dir-3"
 #define FILE "dir/file.ext"
 
@@ -17,20 +24,20 @@ int main(int, char**)
   std::string path;
 
   path = Glib::build_filename(dir_1, file_3);
-  std::cout << "Path 1: " << path << std::endl;
+  ostr << "Path 1: " << path << std::endl;
 
   path = Glib::build_filename(dir_1, dir_2, FILE);
-  std::cout << "Path 2: " << path << std::endl;
+  ostr << "Path 2: " << path << std::endl;
 
   path = Glib::build_filename(dir_1, dir_2, dir_3, FILE);
-  std::cout << "Path 3: " << path << std::endl;
+  ostr << "Path 3: " << path << std::endl;
 
   path = Glib::build_filename(dir_1, dir_2, dir_3, file_1);
-  std::cout << "Path 4: " << path << std::endl;
+  ostr << "Path 4: " << path << std::endl;
 
   path = Glib::build_filename(dir_1, dir_2, dir_1, dir_3, dir_2, dir_3,
     dir_1, dir_2, file_2);
-  std::cout << "Path 5: " << path << std::endl;
+  ostr << "Path 5: " << path << std::endl;
 
   return 0;
 }
diff --git a/tests/glibmm_date/main.cc b/tests/glibmm_date/main.cc
index 3272c85..6dac796 100644
--- a/tests/glibmm_date/main.cc
+++ b/tests/glibmm_date/main.cc
@@ -1,6 +1,13 @@
 #include <glibmm.h>
 #include <iostream>
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 int main(int, char**)
 {
   Glib::Date date;
@@ -9,7 +16,7 @@ int main(int, char**)
   date.subtract_days(1);
   date.add_years(1);
 
-  std::cout << "The date a year and a month from yesterday will be: " <<
+  ostr << "The date a year and a month from yesterday will be: " <<
     date.get_month() << "/" << (int) date.get_day() << "/" << date.get_year() <<
       "." << std::endl;
 
@@ -19,7 +26,7 @@ int main(int, char**)
 
   assigned_date = copy_date;
 
-  std::cout << "The copied date is: " << copy_date.get_month() << "/" <<
+  ostr << "The copied date is: " << copy_date.get_month() << "/" <<
     (int) copy_date.get_day() << "/" << copy_date.get_year() << "." <<
       std::endl;
 
diff --git a/tests/glibmm_ustring_compose/main.cc b/tests/glibmm_ustring_compose/main.cc
index 0fbc9b7..f954733 100644
--- a/tests/glibmm_ustring_compose/main.cc
+++ b/tests/glibmm_ustring_compose/main.cc
@@ -2,24 +2,32 @@
 
 #include <iostream>
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 int main(int, char**)
 {
   Glib::init();
 
+  //TODO: Check the output?
   const char *constant_string = "constant string";
-  std::cout << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
-  std::cout << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
+  ostr << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
+  ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
 
-  std::cout << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
+  ostr << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
 
-  std::cout << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
+  ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
 
-  std::cout << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
+  ostr << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
 
   int i = 1;
-  std::cout << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
+  ostr << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
 
-  std::cout << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
+  ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
 
   //TODO: More tests.
 
diff --git a/tests/glibmm_valuearray/main.cc b/tests/glibmm_valuearray/main.cc
index a905460..b85cdbf 100644
--- a/tests/glibmm_valuearray/main.cc
+++ b/tests/glibmm_valuearray/main.cc
@@ -1,6 +1,13 @@
 #include <glibmm.h>
 #include <iostream>
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 int on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2)
 {
   const Glib::Value<int>& intVal1 = static_cast< const Glib::Value<int>& >(v1);
@@ -33,7 +40,7 @@ int main(int, char**)
     array.prepend(value[i]);
   }
 
-  std::cout << "Array members before sorting:" << std::endl;
+  ostr << "Array members before sorting:" << std::endl;
 
   for(int i = 0; i < VALUES; i++)
   {
@@ -43,18 +50,19 @@ int main(int, char**)
     {
       std::cerr << "Error getting element " << i << " of value array." <<
         std::endl;
+      return EXIT_FAILURE;
       break;
     }
 
     Glib::Value<int> int_val = static_cast< Glib::Value<int>& >(value);
-    std::cout << int_val.get() << " ";
+    ostr << int_val.get() << " ";
   }
-  std::cout << std::endl; // End of line for list of array elements.
+  ostr << std::endl; // End of line for list of array elements.
 
   // Sort array and remove last element:
   array.sort(sigc::ptr_fun(&on_compare)).remove(VALUES - 1);
 
-  std::cout << "Array members after sorting without last element:" <<
+  ostr << "Array members after sorting without last element:" <<
     std::endl;
 
   for(int i = 0; i < VALUES - 1; i++)
@@ -65,13 +73,14 @@ int main(int, char**)
     {
       std::cerr << "Error getting element " << i << " of value array." <<
         std::endl;
+      return EXIT_FAILURE;
       break;
     }
 
     Glib::Value<int> int_val = static_cast< Glib::Value<int>& >(value);
-    std::cout << int_val.get() << " ";
+    ostr << int_val.get() << " ";
   }
-  std::cout << std::endl; // End of line for list of array elements.
+  ostr << std::endl; // End of line for list of array elements.
 
   return 0;
 }
diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc
index 9a69491..257408d 100644
--- a/tests/glibmm_variant/main.cc
+++ b/tests/glibmm_variant/main.cc
@@ -1,6 +1,13 @@
 #include <glibmm.h>
 #include <iostream>
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 int main(int, char**)
 {
   Glib::init();
@@ -10,39 +17,39 @@ int main(int, char**)
   std::vector<int> int_vector(int_list,
     int_list + sizeof(int_list) / sizeof(int));
 
-  std::cout << "The elements of the original vector are:" << std::endl;
+  ostr << "The elements of the original vector are:" << std::endl;
 
   for(guint i = 0; i < int_vector.size(); i++)
-    std::cout << int_vector[i] << std::endl;
+    ostr << int_vector[i] << std::endl;
 
   Glib::Variant< std::vector<int> > integers_variant =
     Glib::Variant< std::vector<int> >::create(int_vector);
 
   std::vector<int> int_vector2 = integers_variant.get();
 
-  std::cout << "The size of the copied vector is " << int_vector2.size() <<
+  ostr << "The size of the copied vector is " << int_vector2.size() <<
     '.' << std::endl;
 
-  std::cout << "The elements of the copied vector are:" << std::endl;
+  ostr << "The elements of the copied vector are:" << std::endl;
 
   for(guint i = 0; i < int_vector2.size(); i++)
-    std::cout << int_vector2[i] << std::endl;
+    ostr << int_vector2[i] << std::endl;
 
-  std::cout << "The number of children in the iterator of the " <<
+  ostr << "The number of children in the iterator of the " <<
     "variant are " << integers_variant.get_iter().get_n_children() <<
     '.' << std::endl;
 
   unsigned index = 4;
-  std::cout << "Element number " << index + 1 << " in the copy is " <<
+  ostr << "Element number " << index + 1 << " in the copy is " <<
     integers_variant.get(index) << '.' << std::endl;
 
-  std::cout << std::endl;
+  ostr << std::endl;
 
   typedef std::pair<Glib::ustring, Glib::ustring> TypeDictEntry;
 
   TypeDictEntry dict_entry("A key", "A value");
 
-  std::cout << "The original dictionary entry is (" << dict_entry.first <<
+  ostr << "The original dictionary entry is (" << dict_entry.first <<
     ", " << dict_entry.second << ")." << std::endl;
 
   Glib::Variant<TypeDictEntry> dict_entry_variant =
@@ -50,10 +57,10 @@ int main(int, char**)
 
   TypeDictEntry copy_entry = dict_entry_variant.get();
 
-  std::cout << "The copy dictionary entry is (" << copy_entry.first <<
+  ostr << "The copy dictionary entry is (" << copy_entry.first <<
     ", " << copy_entry.second << ")." << std::endl;
 
-  std::cout << std::endl;
+  ostr << std::endl;
 
   typedef std::map<unsigned, Glib::ustring> TypeDict;
 
@@ -65,11 +72,11 @@ int main(int, char**)
     orig_dict.insert(std::pair<unsigned, Glib::ustring>(i, x_repeated));
   }
 
-  std::cout << "The original dictionary:" << std::endl;
+  ostr << "The original dictionary:" << std::endl;
 
   for(unsigned i = 0; i < orig_dict.size(); i++)
   {
-    std::cout << "(" << i << ", " << orig_dict[i] << ")." << std::endl;
+    ostr << "(" << i << ", " << orig_dict[i] << ")." << std::endl;
   }
 
   Glib::Variant<TypeDict> orig_dict_variant =
@@ -77,18 +84,18 @@ int main(int, char**)
 
   TypeDict dict_copy = orig_dict_variant.get();
 
-  std::cout << "The copy of the dictionary:" << std::endl;
+  ostr << "The copy of the dictionary:" << std::endl;
 
   for(unsigned i = 0; i < dict_copy.size(); i++)
   {
-    std::cout << "(" << i << ", " << dict_copy[i] << ")." << std::endl;
+    ostr << "(" << i << ", " << dict_copy[i] << ")." << std::endl;
   }
 
   index = 3;
 
   std::pair<unsigned, Glib::ustring> a_pair = orig_dict_variant.get(index);
 
-  std::cout << "Element number " << index + 1 << " in the variant is: (" <<
+  ostr << "Element number " << index + 1 << " in the variant is: (" <<
     a_pair.first << ", " << a_pair.second << ")." << std::endl;
 
 
@@ -96,7 +103,7 @@ int main(int, char**)
 
   if(orig_dict_variant.lookup(index, value))
   {
-    std::cout << "The x's of element number " << index + 1 <<
+    ostr << "The x's of element number " << index + 1 <<
       " in the variant are: " << value << '.' << std::endl;
   }
 
diff --git a/tests/glibmm_vector/main.cc b/tests/glibmm_vector/main.cc
index 77e5f57..db6d2f6 100644
--- a/tests/glibmm_vector/main.cc
+++ b/tests/glibmm_vector/main.cc
@@ -28,6 +28,13 @@
 
 // utilities
 
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of std::cout:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
 const unsigned int magic_limit(5);
 
 GList*
@@ -50,14 +57,14 @@ print_list(GList* list)
 
   for(GList* node(list); node; node = node->next, ++counter)
   {
-    std::cout << counter << ": ";
+    ostr << counter << ": ";
     if(G_IS_CREDENTIALS(node->data))
     {
-      std::cout << node->data << ", ref: " << G_OBJECT(node->data)->ref_count <<"\n";
+      ostr << node->data << ", ref: " << G_OBJECT(node->data)->ref_count <<"\n";
     }
     else
     {
-      std::cout << "no C instance?\n";
+      ostr << "no C instance?\n";
     }
   }
 }
@@ -82,14 +89,14 @@ print_slist(GSList* slist)
 
   for(GSList* node(slist); node; node = node->next, ++counter)
   {
-    std::cout << counter << ": ";
+    ostr << counter << ": ";
     if(G_IS_CREDENTIALS(node->data))
     {
-      std::cout << node->data << ", ref: " << G_OBJECT(node->data)->ref_count <<"\n";
+      ostr << node->data << ", ref: " << G_OBJECT(node->data)->ref_count <<"\n";
     }
     else
     {
-      std::cout << "no C instance?\n";
+      ostr << "no C instance?\n";
     }
   }
 }
@@ -113,14 +120,14 @@ print_array(GCredentials** array)
   {
     GCredentials* credentials(array[iter]);
 
-    std::cout << iter + 1 << ": ";
+    ostr << iter + 1 << ": ";
     if(G_IS_CREDENTIALS(credentials))
     {
-      std::cout << reinterpret_cast<gpointer>(credentials) << ", ref: " << G_OBJECT(credentials)->ref_count << "\n";
+      ostr << reinterpret_cast<gpointer>(credentials) << ", ref: " << G_OBJECT(credentials)->ref_count << "\n";
     }
     else
     {
-      std::cout << "no C instance?\n";
+      ostr << "no C instance?\n";
     }
   }
 }
@@ -161,23 +168,23 @@ print_vector(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
   {
     const Glib::RefPtr<Gio::Credentials>& obj_ptr(v[iter]);
 
-    std::cout << iter + 1 << ": ";
+    ostr << iter + 1 << ": ";
     if(obj_ptr)
     {
       GCredentials* gobj(obj_ptr->gobj());
 
       if(G_IS_CREDENTIALS(gobj))
       {
-        std::cout << static_cast<gpointer>(gobj) << ", ref: " << G_OBJECT(gobj)->ref_count << "\n";
+        ostr << static_cast<gpointer>(gobj) << ", ref: " << G_OBJECT(gobj)->ref_count << "\n";
       }
       else
       {
-        std::cout << "No C instance?\n";
+        ostr << "No C instance?\n";
       }
     }
     else
     {
-      std::cout << "No C++ instance?\n";
+      ostr << "No C++ instance?\n";
     }
   }
 }
@@ -520,63 +527,63 @@ main()
 
   Cache& cache(get_cache());
 
-  std::cout << "Cache list before:\n";
+  ostr << "Cache list before:\n";
   print_list(cache.get_list());
-  std::cout << "Cache slist before:\n";
+  ostr << "Cache slist before:\n";
   print_slist(cache.get_slist());
-  std::cout << "Cache array before:\n";
+  ostr << "Cache array before:\n";
   print_array(cache.get_array());
-  std::cout << "Deep owned list:\n";
+  ostr << "Deep owned list:\n";
   print_vector(cxx_get_deep_owned_list());
-  std::cout << "Shallow owned list:\n";
+  ostr << "Shallow owned list:\n";
   print_vector(cxx_get_shallow_owned_list());
-  std::cout << "Unowned list:\n";
+  ostr << "Unowned list:\n";
   print_vector(cxx_get_unowned_list());
-  std::cout << "Deep owned slist:\n";
+  ostr << "Deep owned slist:\n";
   print_vector(cxx_get_deep_owned_slist());
-  std::cout << "Shallow owned slist:\n";
+  ostr << "Shallow owned slist:\n";
   print_vector(cxx_get_shallow_owned_slist());
-  std::cout << "Unowned slist:\n";
+  ostr << "Unowned slist:\n";
   print_vector(cxx_get_unowned_slist());
-  std::cout << "Deep owned array:\n";
+  ostr << "Deep owned array:\n";
   print_vector(cxx_get_deep_owned_array());
-  std::cout << "Shallow owned array:\n";
+  ostr << "Shallow owned array:\n";
   print_vector(cxx_get_shallow_owned_array());
-  std::cout << "Unowned array:\n";
+  ostr << "Unowned array:\n";
   print_vector(cxx_get_unowned_array());
-  std::cout << "Cache list after:\n";
+  ostr << "Cache list after:\n";
   print_list(cache.get_list());
-  std::cout << "Cache slist after:\n";
+  ostr << "Cache slist after:\n";
   print_slist(cache.get_slist());
-  std::cout << "Cache array after:\n";
+  ostr << "Cache array after:\n";
   print_array(cache.get_array());
 
   std::vector<Glib::RefPtr<Gio::Credentials> > v(cxx_get_unowned_list());
 
-  std::cout << "Gotten vector before:\n";
+  ostr << "Gotten vector before:\n";
   print_vector(v);
   // I am wondering if C functions wrapped by the ones below are not buggy by
   // design. Anyway - it segfaults. Maybe the test case is just wrong.
-  //std::cout << "Take list all:\n";
+  //ostr << "Take list all:\n";
   //cxx_list_take_all(v);
-  //std::cout << "Take list members:\n";
+  //ostr << "Take list members:\n";
   //cxx_list_take_members(v);
-  std::cout << "Take list nothing:\n";
+  ostr << "Take list nothing:\n";
   cxx_list_take_nothing(v);
   // Ditto.
-  //std::cout << "Take slist all:\n";
+  //ostr << "Take slist all:\n";
   //cxx_slist_take_all(v);
-  //std::cout << "Take slist members:\n";
+  //ostr << "Take slist members:\n";
   //cxx_slist_take_members(v);
-  std::cout << "Take slist nothing:\n";
+  ostr << "Take slist nothing:\n";
   cxx_slist_take_nothing(v);
   // Ditto.
-  //std::cout << "Take array all:\n";
+  //ostr << "Take array all:\n";
   //cxx_array_take_all(v);
-  //std::cout << "Take array members:\n";
+  //ostr << "Take array members:\n";
   //cxx_array_take_members(v);
-  std::cout << "Take array nothing:\n";
+  ostr << "Take array nothing:\n";
   cxx_array_take_nothing(v);
-  std::cout << "Gotten vector after:\n";
+  ostr << "Gotten vector after:\n";
   print_vector(v);
 }



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