[gnome-commander/CppUnit: 11/16] Utilize CPPUnit test framework in gcmd
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/CppUnit: 11/16] Utilize CPPUnit test framework in gcmd
- Date: Sat, 3 Oct 2015 22:30:36 +0000 (UTC)
commit 5da39e7c0498f905d36d760b1471afeda398f919
Author: Uwe Scholz <uwescholz src gnome org>
Date: Sat Oct 3 15:03:10 2015 +0200
Utilize CPPUnit test framework in gcmd
tests/Makefile.am | 8 +++++++
tests/gcmd_tests_main.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d323033..0dafa0d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,11 @@
SUBDIRS =
-include $(top_srcdir)/git.mk
+
+# Rules for the test code (use `make check` to execute)
+TESTS = gcmd_tests
+check_PROGRAMS = $(TESTS)
+gcmd_tests_SOURCES = \
+ gcmd_tests_main.cc
+gcmd_tests_CXXFLAGS = $(CPPUNIT_CFLAGS)
+gcmd_tests_LDFLAGS = $(CPPUNIT_LIBS) -ldl
diff --git a/tests/gcmd_tests_main.cc b/tests/gcmd_tests_main.cc
new file mode 100644
index 0000000..0e7b2a2
--- /dev/null
+++ b/tests/gcmd_tests_main.cc
@@ -0,0 +1,50 @@
+/**
+ * @file gcmd_tests_main.cc
+ * @copyright (C) 2015 Uwe Scholz\n
+ *
+ * @copyright This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * @copyright This program 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 General Public License for more details.
+ *
+ * @copyright You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TestRunner.h>
+#include <cppunit/BriefTestProgressListener.h>
+
+int main (int argc, char* argv[])
+{
+ // Inform the test listener about test results
+ CPPUNIT_NS :: TestResult testresult;
+
+ // Register the listener for collecting test results
+ CPPUNIT_NS :: TestResultCollector collectedresults;
+ testresult.addListener (&collectedresults);
+
+ // Listener for output of results of seperate tests
+ CPPUNIT_NS :: BriefTestProgressListener progress;
+ testresult.addListener (&progress);
+
+ // Incluce the test suite through the registry into the test runner
+ CPPUNIT_NS :: TestRunner testrunner;
+ testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry :: getRegistry ().makeTest ());
+ testrunner.run (testresult);
+
+ // Output of test results in compiler format
+ CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
+ compileroutputter.write ();
+
+ // Have the tests been successfull?
+ return collectedresults.wasSuccessful () ? 0 : 1;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]