[cig-commits] r12903 - in cs/cigma/trunk: . tests tests/simple

luis at geodynamics.org luis at geodynamics.org
Wed Sep 17 01:11:45 PDT 2008


Author: luis
Date: 2008-09-17 01:11:45 -0700 (Wed, 17 Sep 2008)
New Revision: 12903

Added:
   cs/cigma/trunk/tests/
   cs/cigma/trunk/tests/Makefile.am
   cs/cigma/trunk/tests/main.cpp
   cs/cigma/trunk/tests/simple/
   cs/cigma/trunk/tests/simple/SimpleTest.cpp
   cs/cigma/trunk/tests/simple/SimpleTest.h
   cs/cigma/trunk/tests/test_registry.cpp
Log:
Simplest possible unit test

Next, we verify that buildbot correctly executes "make check"

Added: cs/cigma/trunk/tests/Makefile.am
===================================================================
--- cs/cigma/trunk/tests/Makefile.am	                        (rev 0)
+++ cs/cigma/trunk/tests/Makefile.am	2008-09-17 08:11:45 UTC (rev 12903)
@@ -0,0 +1,25 @@
+# -*- Makefile -*-
+#
+
+# Compile this as part of make check
+check_PROGRAMS = cigma-test
+
+# Also run the tests as part of make check
+TESTS = $(check_PROGRAMS)
+
+#############################
+## Compiler/Linker Options ##
+#############################
+
+cigma_test_SOURCES = $(test_sources)
+
+cigma_test_CXXFLAGS = @CPPUNIT_CFLAGS@
+cigma_test_LDADD = @CPPUNIT_LIBS@
+
+test_sources = \
+	simple/SimpleTest.h \
+	simple/SimpleTest.cpp \
+	test_registry.cpp \
+	main.cpp
+
+# vim:foldmethod=marker foldlevel=0

Added: cs/cigma/trunk/tests/main.cpp
===================================================================
--- cs/cigma/trunk/tests/main.cpp	                        (rev 0)
+++ cs/cigma/trunk/tests/main.cpp	2008-09-17 08:11:45 UTC (rev 12903)
@@ -0,0 +1,19 @@
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/TestResult.h>
+
+int main(int argc, char *argv[])
+{
+    CPPUNIT_NS::TextUi::TestRunner runner;
+    CPPUNIT_NS::TestFactoryRegistry &registry = CPPUNIT_NS::TestFactoryRegistry::getRegistry();
+    runner.addTest(registry.makeTest());
+
+    // Shows a message as each test starts
+    CPPUNIT_NS::BriefTestProgressListener listener;
+    runner.eventManager().addListener(&listener);
+
+    bool wasSuccessful = runner.run("", false);
+
+    return !wasSuccessful;
+}

Added: cs/cigma/trunk/tests/simple/SimpleTest.cpp
===================================================================
--- cs/cigma/trunk/tests/simple/SimpleTest.cpp	                        (rev 0)
+++ cs/cigma/trunk/tests/simple/SimpleTest.cpp	2008-09-17 08:11:45 UTC (rev 12903)
@@ -0,0 +1,9 @@
+#include "SimpleTest.h"
+
+using namespace cigma;
+
+void SimpleTest::testOnePlusOneEqualsTwo()
+{
+    CPPUNIT_ASSERT( 1 + 1 == 2 );
+}
+

Added: cs/cigma/trunk/tests/simple/SimpleTest.h
===================================================================
--- cs/cigma/trunk/tests/simple/SimpleTest.h	                        (rev 0)
+++ cs/cigma/trunk/tests/simple/SimpleTest.h	2008-09-17 08:11:45 UTC (rev 12903)
@@ -0,0 +1,24 @@
+#ifndef __SIMPLE_TEST_H__
+#define __SIMPLE_TEST_H__
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace cigma{
+
+    class SimpleTest : public CPPUNIT_NS::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( SimpleTest );
+        CPPUNIT_TEST( testOnePlusOneEqualsTwo );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+        SimpleTest() {}
+        virtual ~SimpleTest() {}
+    
+        void testOnePlusOneEqualsTwo();
+    };
+
+}
+
+#endif

Added: cs/cigma/trunk/tests/test_registry.cpp
===================================================================
--- cs/cigma/trunk/tests/test_registry.cpp	                        (rev 0)
+++ cs/cigma/trunk/tests/test_registry.cpp	2008-09-17 08:11:45 UTC (rev 12903)
@@ -0,0 +1,8 @@
+//
+// All CppUnit tests are registered in here so we can disable them
+// and enable them easily in one place.
+//
+
+#include <simple/SimpleTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION(cigma::SimpleTest);
+



More information about the cig-commits mailing list