[glom/import_csv_refactored] tests/import/: Small cleanup.



commit 7e20776f46dab691f0364581c5f6b81dfeb0f028
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Sep 25 15:20:07 2009 +0200

    tests/import/: Small cleanup.
    
    * tests/import/test_parsing.cc:
    * tests/import/utils.[h|cc]: Use a sigc::slot instead of the ugly
    (because not typedefed) function pointer type.

 ChangeLog                    |    8 ++++++++
 tests/import/test_parsing.cc |    1 +
 tests/import/utils.cc        |    7 +++++--
 tests/import/utils.h         |    4 +++-
 4 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1112cf5..842b146 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-09-25  Murray Cumming  <murrayc murrayc com>
 
+	tests/import/: Small cleanup.
+
+	* tests/import/test_parsing.cc:
+	* tests/import/utils.[h|cc]: Use a sigc::slot instead of the ugly 
+	(because not typedefed) function pointer type.
+
+2009-09-25  Murray Cumming  <murrayc murrayc com>
+
 	Removed some debug output.
 
 	* glom/libglom/data_structure/glomconversions.cc: parse_time():
diff --git a/tests/import/test_parsing.cc b/tests/import/test_parsing.cc
index b6f83b4..4eeb3d0 100644
--- a/tests/import/test_parsing.cc
+++ b/tests/import/test_parsing.cc
@@ -97,6 +97,7 @@ int main(int argc, char* argv[])
   {
     const char raw[] = "\"a \"\"quoted\"\" token\",\"sans quotes\"\n";
     const bool finished_parsing = ImportTests::run_parser_from_buffer(&connect_signals, raw, sizeof(raw));
+    g_assert(finished_parsing);
 
     const bool passed = (finished_parsing &&
                    check_tokens("^(a \"quoted\" token|sans quotes)$") &&
diff --git a/tests/import/utils.cc b/tests/import/utils.cc
index 2f3abd4..0ab410e 100644
--- a/tests/import/utils.cc
+++ b/tests/import/utils.cc
@@ -50,7 +50,9 @@ void on_mainloop_killed_by_watchdog()
   get_mainloop_instance()->quit();
 }
 
-bool run_parser_from_buffer(void (*connect_parser_signals)(Glom::CsvParser& parser), const char* input, guint size)
+typedef sigc::slot<void, Glom::CsvParser&> FuncConnectParserSignals;
+
+bool run_parser_from_buffer(const FuncConnectParserSignals& connect_parser_signals, const char* input, guint size)
 {
     get_result_instance() = true;
 
@@ -60,12 +62,13 @@ bool run_parser_from_buffer(void (*connect_parser_signals)(Glom::CsvParser& pars
     Glom::CsvParser parser("UTF-8");
 
     parser.signal_finished_parsing().connect(sigc::mem_fun(*get_mainloop_instance().operator->(), &Glib::MainLoop::quit));
+
     // Install a watchdog for the mainloop, no test should need longer than 3
     // seconds. Also, we need to guard against being stuck in the mainloop.
     // Infinitely running tests are useless.
     get_mainloop_instance()->get_context()->signal_timeout().connect_seconds_once(sigc::ptr_fun(&on_mainloop_killed_by_watchdog), 3);
 
-    (*connect_parser_signals)(parser);
+    connect_parser_signals(parser);
 
     const std::string file_name = create_file_from_buffer(input, size);
     parser.set_file_and_start_parsing(file_name);
diff --git a/tests/import/utils.h b/tests/import/utils.h
index 76cc14a..ee24b85 100644
--- a/tests/import/utils.h
+++ b/tests/import/utils.h
@@ -2,6 +2,7 @@
 #define TEST_IMPORT_UTILS_H
 
 #include <glom/import_csv/csv_parser.h>
+//#include <sigc++/sigc++.h>
 #include <iostream>
 #include <unistd.h>
 #include <errno.h>
@@ -17,7 +18,8 @@ void set_parser_contents(Glom::CsvParser& parser, const char* input, guint size)
 // Returns the file name of the temporary created file, which will contain the buffer's contents.
 std::string create_file_from_buffer(const char* input, guint size);
 
-bool run_parser_from_buffer(void (*connect_parser_signals)(Glom::CsvParser& parser), const char* input, guint size);
+typedef sigc::slot<void, Glom::CsvParser&> FuncConnectParserSignals;
+bool run_parser_from_buffer(const FuncConnectParserSignals& connect_parser_signals, const char* input, guint size);
 
 void on_mainloop_killed_by_watchdog();
 Glib::RefPtr<Glib::MainLoop>& get_mainloop_instance();



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