[cig-commits] r11244 - in cs/benchmark/cigma/trunk: . tests

luis at geodynamics.org luis at geodynamics.org
Tue Feb 26 04:51:54 PST 2008


Author: luis
Date: 2008-02-26 04:51:54 -0800 (Tue, 26 Feb 2008)
New Revision: 11244

Added:
   cs/benchmark/cigma/trunk/tests/
   cs/benchmark/cigma/trunk/tests/Makefile
   cs/benchmark/cigma/trunk/tests/hello.cpp
Log:
Added simple cppunit test case


Added: cs/benchmark/cigma/trunk/tests/Makefile
===================================================================
--- cs/benchmark/cigma/trunk/tests/Makefile	                        (rev 0)
+++ cs/benchmark/cigma/trunk/tests/Makefile	2008-02-26 12:51:54 UTC (rev 11244)
@@ -0,0 +1,21 @@
+CPPUNIT_PREFIX = /usr
+
+CXX = g++
+FLAGS += -Wall
+LIBS += -lcppunit -ldl
+LDFLAGS += -L$(CPPUNIT_PREFIX)/lib
+LDFLAGS += $(LIBS)
+
+default: hello
+
+hello.o: hello.cpp
+	$(CXX) $(FLAGS) -c $^ -o $@
+
+hello: hello.o
+	$(CXX) $(FLAGS) $(LDFLAGS) $^ -o $@
+
+clean:
+	rm -f hello
+	rm -f hello.o
+
+.PHONY: clean

Added: cs/benchmark/cigma/trunk/tests/hello.cpp
===================================================================
--- cs/benchmark/cigma/trunk/tests/hello.cpp	                        (rev 0)
+++ cs/benchmark/cigma/trunk/tests/hello.cpp	2008-02-26 12:51:54 UTC (rev 11244)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <cppunit/TestRunner.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+class Test : public CPPUNIT_NS::TestCase
+{
+CPPUNIT_TEST_SUITE(Test);
+CPPUNIT_TEST(testHelloWorld);
+CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp(void) {}
+    void tearDown(void) {}
+
+protected:
+    void testHelloWorld(void)
+    {
+        //std::cout << "Hello, World!" << std::endl;
+    }
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+int main(int ac, char **av)
+{
+    //--- Create the event manager and test controller
+    CPPUNIT_NS::TestResult controller;
+
+    //--- Add a listener that collects the test results
+    CPPUNIT_NS::TestResultCollector result;
+    controller.addListener(&result);
+
+    //--- Add a listener tha tprints dots as test runs
+    CPPUNIT_NS::BriefTestProgressListener progress;
+    controller.addListener(&progress);
+
+    //--- Add the top suite to the test runner
+    CPPUNIT_NS::TestRunner runner;
+    runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
+    runner.run(controller);
+
+    return result.wasSuccessful() ? 0 : 1;
+}



More information about the cig-commits mailing list