[Mockpp-commits] mockpp/mockpp/tests And_test.cpp,1.13,1.14 Exception_test.cpp,1.14,1.15 Makefile.am
Brought to you by:
ewald-arnold
|
From: Ewald A. <ewa...@us...> - 2005-12-10 15:18:42
|
Update of /cvsroot/mockpp/mockpp/mockpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13151/mockpp/tests Modified Files: And_test.cpp Exception_test.cpp Makefile.am mock_test.cpp SelectFramework.h Log Message: first tests with cxxtest Index: SelectFramework.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/SelectFramework.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SelectFramework.h 9 Dec 2005 18:56:20 -0000 1.2 +++ SelectFramework.h 10 Dec 2005 15:18:34 -0000 1.3 @@ -1,49 +1 @@ -/*************************************************************************** - SelectFramework.h - setup for unittest framework in use - ------------------- - begin : Fri Dec 9 2005 - copyright : (C) 2002-2005 by Ewald Arnold - email : mockpp at ewald-arnold dot de - - $Id$ - - ***************************************************************************/ - -/************************************************************************** - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - ***************************************************************************/ - -#ifndef MOCKPP_SELECTFRAMEWORK_H -#define MOCKPP_SELECTFRAMEWORK_H - -#if defined(HAVE_CXXTEST) - -# define MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK /**/ - -#elif defined(HAVE_CPPUNIT) - -# include <cppunit/extensions/HelperMacros.h> -# define MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK : public CppUnit::TestFixture - -#else - -# pragma message ("No unittest framework available at compile time") -# define MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK /**/ - -#endif // frameworks - -#endif // MOCKPP_SELECTFRAMEWORK_H +#include <mockpp/SelectUnittestFramework.h> Index: And_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/And_test.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- And_test.cpp 9 Dec 2005 18:56:20 -0000 1.13 +++ And_test.cpp 10 Dec 2005 15:18:34 -0000 1.14 @@ -37,7 +37,6 @@ #include <mockpp/constraint/IsNothing.h> - class And_test MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK { public: @@ -64,6 +63,10 @@ #if defined (HAVE_CXXTEST) +MOCKPP_CXXTEST_SUITE_REGISTRATION( And_test ); +MOCKPP_CXXTEST( And_test , test_invoke); +MOCKPP_CXXTEST( And_test , test_describe); + #elif defined(HAVE_CPPUNIT) CPPUNIT_TEST_SUITE_REGISTRATION (And_test); Index: mock_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/mock_test.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- mock_test.cpp 9 Dec 2005 18:56:20 -0000 1.25 +++ mock_test.cpp 10 Dec 2005 15:18:34 -0000 1.26 @@ -36,7 +36,22 @@ #include <iostream> #include <ctime> -#ifdef HAVE_CPPUNIT +#include "SelectFramework.h" + +#if defined(HAVE_CXXTEST) + +#include <cxxtest/TestRunner.h> + +#ifdef GUI +#include <cxxtest/StdioPrinter.h> +//#include <cxxtest/QtGui.h> +//#include <cxxtest/X11Gui.h> +//#include <cxxtest/Win32Gui.h> +#else +#include <cxxtest/ErrorPrinter.h> +#endif + +#elif defined(HAVE_CPPUNIT) # include <cppunit/extensions/TestFactoryRegistry.h> # include <cppunit/ui/text/TestRunner.h> @@ -46,6 +61,7 @@ # include <cppunit/TestFailure.h> # include <cppunit/CompilerOutputter.h> +#endif #ifndef _MSC_VER using std::time; @@ -53,6 +69,19 @@ #endif +#if defined(HAVE_CXXTEST) + +int run_cxxtest(int argc, char **argv) +{ +#ifdef GUI + return CxxTest::GuiTuiRunner<CxxTest::QtGui, CxxTest::StdioPrinter>( argc, argv ).run(); +#else + return CxxTest::ErrorPrinter().run(); +#endif +} + +#elif defined(HAVE_CPPUNIT) + class MyListener : public CppUnit::TextTestProgressListener { time_t starttime; @@ -94,17 +123,37 @@ } }; -#endif - -int main(int argc, char **argv) +int run_cppunit(int argc, char **argv) { int ret = 1; -#ifdef HAVE_CPPUNIT CppUnit::TextUi::TestRunner runner; CppUnit::TestFactory ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); + + MyListener *listener = 0; + for (int i1 = 1; i1 < argc; ++i1) + if (strcmp (argv[1], "--show-name") == 0) + runner.eventManager().addListener(listener = new MyListener()); + +#ifndef __BORLANDC__ // @todo + for (int i2 = 1; i2 < argc; ++i2) + if (strcmp (argv[i2], "--compiler-output") == 0) + runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr ) ); +#endif + + ret = runner.run() ? 0 : 1; + delete listener; + return ret; +} + +#endif + + +int main(int argc, char **argv) +{ + int ret = 1; std::cout << "starting tests..\n"; #ifdef MOCKPP_PTI_WEAKNESS @@ -120,25 +169,16 @@ std::cout << " --compiler-output output similar to compilers\n"; std::cout << "\n"; - MyListener *listener = 0; - for (int i1 = 1; i1 < argc; ++i1) - if (strcmp (argv[1], "--show-name") == 0) - runner.eventManager().addListener(listener = new MyListener()); +#if defined(HAVE_CXXTEST) -#ifndef __BORLANDC__ // @todo - for (int i2 = 1; i2 < argc; ++i2) - if (strcmp (argv[i2], "--compiler-output") == 0) - runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr ) ); -#endif + ret = run_cxxtest(argc, argv); - ret = runner.run() ? 0 : 1; - delete listener; +#elif defined(HAVE_CPPUNIT) + + ret = run_cppunit(argc, argv); - std::cout << "Result: " << ret << std::endl; -#else - std::cout << "CppUnit was not available at compile time!\n"; - std::cout << "No unit test are performed.\n"; - ret = 1; #endif + + std::cout << "Result: " << ret << std::endl << std::endl; return ret; } Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/Makefile.am,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- Makefile.am 9 Dec 2005 18:56:20 -0000 1.92 +++ Makefile.am 10 Dec 2005 15:18:34 -0000 1.93 @@ -17,14 +17,18 @@ ########################################################################### +if BUILTIN_CXXTEST +cxxtest_lib=$(top_builddir)/3party/cxxtest/cxxtest/libmockpp_cxxtest.la +endif + mock_test_LDADD = $(top_builddir)/mockpp/libmockpp.la \ - $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) + $(cxxtest_lib) $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) jmock_test_LDADD = $(top_builddir)/mockpp/libmockpp.la \ - $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) + $(cxxtest_lib) $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) readability_test_LDADD = $(top_builddir)/mockpp/libmockpp.la \ - $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) + $(cxxtest_lib) $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) check_inst_LDADD = $(top_builddir)/mockpp/libmockpp.la \ $(LIBDL) -lstdc++ $(EA_EXTRA_LIB) $(LIBCPPUNIT) Index: Exception_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/Exception_test.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Exception_test.cpp 9 Dec 2005 18:56:20 -0000 1.14 +++ Exception_test.cpp 10 Dec 2005 15:18:34 -0000 1.15 @@ -57,7 +57,10 @@ }; - #if defined (HAVE_CXXTEST) +#if defined (HAVE_CXXTEST) + +MOCKPP_CXXTEST_SUITE_REGISTRATION( Exception_test ); +MOCKPP_CXXTEST(Exception_test, test_file_line); #elif defined(HAVE_CPPUNIT) |