diff options
| author | Bastiaan Bakker <bastiaan.bakker@lifeline.nl> | 2001-04-29 13:09:16 +0000 |
|---|---|---|
| committer | Bastiaan Bakker <bastiaan.bakker@lifeline.nl> | 2001-04-29 13:09:16 +0000 |
| commit | b08ecaecc1e39b7b01e02b7b73559d8b34ff46a5 (patch) | |
| tree | bf1ed1e3680cb0256e73336e22fb70c692524fcb /include/cppunit/extensions | |
| parent | 5ce1a68589aa3ea4f9ee255cfecc94cc1730c6fa (diff) | |
| download | cppunit-b08ecaecc1e39b7b01e02b7b73559d8b34ff46a5.tar.gz | |
Merged Baptiste Lepilleurs CppUnitW 1.2.
Some differences:
TypeInfo stuff (in TestSuite) compiled in only if USE_TYPEINFO is set.
TestSuite.getTests now returns a const ref instead of taking a ref as param.
Removed auto_ptr stuff from TestFactoryRegistry: auto_ptr cannot be used in
containers.
Diffstat (limited to 'include/cppunit/extensions')
| -rw-r--r-- | include/cppunit/extensions/AbstractTestFactory.h | 25 | ||||
| -rw-r--r-- | include/cppunit/extensions/AutoRegisterSuite.h | 47 | ||||
| -rw-r--r-- | include/cppunit/extensions/HelperMacros.h | 164 | ||||
| -rw-r--r-- | include/cppunit/extensions/Makefile | 247 | ||||
| -rw-r--r-- | include/cppunit/extensions/Makefile.am | 8 | ||||
| -rw-r--r-- | include/cppunit/extensions/Makefile.in | 247 | ||||
| -rw-r--r-- | include/cppunit/extensions/TestFactoryRegistry.h | 80 | ||||
| -rw-r--r-- | include/cppunit/extensions/TestSuiteBuilder.h | 55 | ||||
| -rw-r--r-- | include/cppunit/extensions/TestSuiteFactory.h | 25 |
9 files changed, 897 insertions, 1 deletions
diff --git a/include/cppunit/extensions/AbstractTestFactory.h b/include/cppunit/extensions/AbstractTestFactory.h new file mode 100644 index 0000000..14a27c8 --- /dev/null +++ b/include/cppunit/extensions/AbstractTestFactory.h @@ -0,0 +1,25 @@ +#ifndef CPPUNIT_ABSTRACTTESTFACTORY_H +#define CPPUNIT_ABSTRACTTESTFACTORY_H + + + +namespace CppUnit { + + class Test; + + /** This class represents an abstract Test factory. + */ + class AbstractTestFactory + { + public: + virtual ~AbstractTestFactory() {} + + /** Makes a new test. + * \return A new Test. + */ + virtual Test *makeTest() =0; + }; + +} // namespace CppUnit + +#endif // CPPUNIT_ABSTRACTTESTFACTORY_H diff --git a/include/cppunit/extensions/AutoRegisterSuite.h b/include/cppunit/extensions/AutoRegisterSuite.h new file mode 100644 index 0000000..a9fb117 --- /dev/null +++ b/include/cppunit/extensions/AutoRegisterSuite.h @@ -0,0 +1,47 @@ +#ifndef CPPUNIT_AUTOREGISTERSUITE_H +#define CPPUNIT_AUTOREGISTERSUITE_H + +#include <string> + +#include "TestSuiteFactory.h" +#include "TestFactoryRegistry.h" + + +namespace CppUnit { + + /** Automatically register the test suite of the specified type. + * + * This object will register the test returned by TestCaseType::suite() + * when constructed to the test registry. + * + * This object is intented to be used as a static variable. + * + * \param TestCaseType Type of the test case which suite is registered. + * \see CU_TEST_SUITE_REGISTRATION. + */ + template<class TestCaseType> + class AutoRegisterSuite + { + public: + /** Auto-register the suite factory in the global registry. + */ + AutoRegisterSuite() + { + AbstractTestFactory *factory = new TestSuiteFactory<TestCaseType>(); + TestFactoryRegistry::getRegistry().registerFactory( factory ); + } + + /** Auto-register the suite factory in the specified registry. + * \param name Name of the registry. + */ + AutoRegisterSuite( const std::string &name ) + { + TestSuiteFactory *factory = new TestSuiteFactory<TestCaseType>(); + TestFactoryRegistry::getRegistry( name ).registerFactory( factory ); + } + }; + +} // namespace CppUnit + + +#endif // CPPUNIT_AUTOREGISTERSUITE_H diff --git a/include/cppunit/extensions/HelperMacros.h b/include/cppunit/extensions/HelperMacros.h new file mode 100644 index 0000000..7c725c5 --- /dev/null +++ b/include/cppunit/extensions/HelperMacros.h @@ -0,0 +1,164 @@ +// ////////////////////////////////////////////////////////////////////////// +// Header file AutoRegisterTests.h for class AutoRegisterTests +// (c)Copyright 2000, Baptiste Lepilleur. +// Created: 2001/04/15 +// ////////////////////////////////////////////////////////////////////////// +#ifndef CPPUNIT_HELPERMACROS_H +#define CPPUNIT_HELPERMACROS_H + +#include "AutoRegisterSuite.h" +#include "TestSuiteBuilder.h" + + +/** Begins the declaration of the test suite + * + * The CU_TEST_XXX macros are helper to define test suite that are + * automatically registered to the TestRegistry. + * + * You just need to add a set of macro to declare the unit test method. + * Those macros will create a template method named registerTests + * with adds the test methods using TestCaller to the suite. + * + * This macro will also define a static method named suite() that + * return a pointer on the suite associated to the test case type. + * The method signature is: \code static CppUnit::TestSuite *suite().\endcode + * + * Notes that you must directly inherit from CppUnit::TestCase when using + * this macro. See CU_TEST_SUB_SUITE if you need to declare a suite + * for a sub-class inheriting a test case that use CU_TEST_SUITE. + * + * \code + * #include <cppunit/AutoRegisterTests.h> + * class MyTest : public CppUnit::TestCase { + * CU_TEST_SUITE( MyTest ); + * CU_TEST( testEquality ); + * CU_TEST( testSetName ); + * CU_TEST_SUITE_END(); + * public: + * void testEquality(); + * void testSetName(); + * }; + * \endcode + * + * Somewhere in an implementation file: + * + * \code + * CU_TEST_SUITE_REGISTRATION( MyTest ); + * \encode + * + * The great thing about that is that you can even used it on template test case. + * You only need to specify the full qualified name of the class. For example: + * + * \code + * template<class CharType> + * class StringTest : public CppUnit::Testcase { + * CU_TEST_SUITE( StringTest<CharType> ); + * CU_TEST( testAppend ); + * CU_TEST_SUITE_END(); + * public: + * ... + * }; + * \endcode + * + * And you need to add in an implementation file: + * + * \code + * CU_TEST_SUITE_REGISTRATION( String<char> ); + * CU_TEST_SUITE_REGISTRATION( String<wchar_t> ); + * \encode + * + * \param ATestCaseType Type of the test case class. + * \see CU_TEST_SUB_SUITE, CU_TEST, CU_TEST_SUITE_END, CU_TEST_SUITE_REGISTRATION. + */ +#define CU_TEST_SUITE( ATestCaseType ) \ + private: \ + typedef ATestCaseType __ThisTestCaseType; \ + public: \ + typedef CppUnit::AutoRegisterSuite<__ThisTestCaseType> AutoRegisterSuite; \ + static CppUnit::Test *suite() \ + { \ + __ThisTestCaseType *test =NULL; \ + CppUnit::TestSuiteBuilder<__ThisTestCaseType> suite; \ + __ThisTestCaseType::registerTests( suite, test ); \ + return suite.takeSuite(); \ + } \ + template<class TestCaseType> \ + static void \ + registerTests( CppUnit::TestSuiteBuilder<TestCaseType> &suite, \ + TestCaseType *test ) \ + { + + +/** Begins the declaration of the test suite + * + * This macro works just the same as CU_TEST_SUITE, but allow you to specify + * the base class. When the test are registered, the base class test + * defined using the CU_TEST_SUITE macro or CU_TEST_SUB_SUITE macro are + * added to the suite. + * + * Here is an example: + * + * \code + * #include <cppunit/AutoRegisterTests.h> + * class MySubTest : public MyTest { + * CU_TEST_SUB_SUITE( MySubTest, MyTest ); + * CU_TEST( testAdd ); + * CU_TEST( testSub ); + * CU_TEST_SUITE_END(); + * public: + * void testAdd(); + * void testSub(); + * }; + * \endcode + * + * \param ATestCaseType Type of the test case class. + * \see CU_TEST_SUITE. + */ +#define CU_TEST_SUB_SUITE( ATestCaseType, ASuperClass ) \ + private: \ + typedef ASuperClass __ThisSuperClassType; \ + CU_TEST_SUITE( ATestCaseType ); \ + __ThisSuperClassType::registerTests( suite, test ) + +/** Adds a method to the suite. + * \param testMethod Name of the method of the test case to add to the + * suite. The signature of the method must be of + * type: void testMethod(); + * \see CU_TEST_SUITE. + */ +#define CU_TEST( testMethod ) \ + suite.addTestCaller( #testMethod, testMethod ) + +/** Ends the declaration of the test suite and automatically register + * the test suite in the TestRegistry. + * + * After this macro, member access is set to "private". + * + * \see TestRegistry. + * \see CU_TEST_SUITE. + */ +#define CU_TEST_SUITE_END() \ +} \ + private: + +#define CU_CONCATENATE_DIRECT( s1, s2 ) s1##s2 +#define CU_CONCATENATE( s1, s2 ) CU_CONCATENATE_DIRECT( s1, s2 ) + +/** Decorates the specified string with the line number to obtain a unique name; + * @param str String to decorate. + */ +#define CU_MAKE_UNIQUE_NAME( str ) CU_CONCATENATE( str, __LINE__ ) + +/** Implementation of the auto-registration of test into the TestRegistry. + * Should be placed in the cpp file. + * @param ATestCaseType Type of the test case class. + * \warning This macro should be used only once per line of code (the line + * number is used to name a hidden static variable). + * \see CU_TEST_SUITE, CppUnit::AutoRegisterSuite. + */ +#define CU_TEST_SUITE_REGISTRATION( ATestCaseType ) \ + static ATestCaseType::AutoRegisterSuite \ + CU_MAKE_UNIQUE_NAME(__autoRegisterSuite ) + + +#endif // CPPUNIT_HELPERMACROS_H diff --git a/include/cppunit/extensions/Makefile b/include/cppunit/extensions/Makefile new file mode 100644 index 0000000..fa40700 --- /dev/null +++ b/include/cppunit/extensions/Makefile @@ -0,0 +1,247 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = ../../.. +prefix = /usr/local +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/cppunit +pkglibdir = $(libdir)/cppunit +pkgincludedir = $(includedir)/cppunit + +top_builddir = ../../.. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = i686-pc-linux +host_triplet = i686-pc-linux-gnu +AS = @AS@ +CC = gcc +CPPUNIT_BINARY_AGE = 0 +CPPUNIT_INTERFACE_AGE = 0 +CPPUNIT_MAJOR_VERSION = 1 +CPPUNIT_MICRO_VERSION = 4 +CPPUNIT_MINOR_VERSION = 5 +CPPUNIT_VERSION = 1.5.4 +CXX = c++ +DLLTOOL = @DLLTOOL@ +DOT = /usr/bin/dot +DOXYGEN = /usr/bin/doxygen +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LN_S = ln -s +LT_AGE = 0 +LT_CURRENT = 4 +LT_RELEASE = 1.5 +LT_REVISION = 0 +MAKEINFO = makeinfo +OBJDUMP = @OBJDUMP@ +PACKAGE = cppunit +RANLIB = ranlib +VERSION = 1.5.4 +enable_dot = yes +enable_html_docs = yes +enable_latex_docs = no + +libcppunitincludedir = $(includedir)/cppunit/extensions + +libcppunitinclude_HEADERS = AbstractTestFactory.h AutoRegisterSuite.h HelperMacros.h Orthodox.h RepeatedTest.h TestDecorator.h TestFactoryRegistry.h TestSetup.h TestSuiteBuilder.h TestSuiteFactory.h + +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = ../../../include/config.h +CONFIG_CLEAN_FILES = +HEADERS = $(libcppunitinclude_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu include/cppunit/extensions/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +install-libcppunitincludeHEADERS: $(libcppunitinclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libcppunitincludedir) + @list='$(libcppunitinclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libcppunitincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libcppunitincludedir)/$$p; \ + done + +uninstall-libcppunitincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(libcppunitinclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libcppunitincludedir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = include/cppunit/extensions + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu include/cppunit/extensions/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-libcppunitincludeHEADERS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libcppunitincludeHEADERS +uninstall: uninstall-am +all-am: Makefile $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libcppunitincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-tags clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-tags distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: uninstall-libcppunitincludeHEADERS \ +install-libcppunitincludeHEADERS tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/include/cppunit/extensions/Makefile.am b/include/cppunit/extensions/Makefile.am index 1388d9d..1173df7 100644 --- a/include/cppunit/extensions/Makefile.am +++ b/include/cppunit/extensions/Makefile.am @@ -1,7 +1,13 @@ libcppunitincludedir = $(includedir)/cppunit/extensions libcppunitinclude_HEADERS = \ + AbstractTestFactory.h \ + AutoRegisterSuite.h \ + HelperMacros.h \ Orthodox.h \ RepeatedTest.h \ TestDecorator.h \ - TestSetup.h + TestFactoryRegistry.h \ + TestSetup.h \ + TestSuiteBuilder.h \ + TestSuiteFactory.h diff --git a/include/cppunit/extensions/Makefile.in b/include/cppunit/extensions/Makefile.in new file mode 100644 index 0000000..13d34ba --- /dev/null +++ b/include/cppunit/extensions/Makefile.in @@ -0,0 +1,247 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CPPUNIT_BINARY_AGE = @CPPUNIT_BINARY_AGE@ +CPPUNIT_INTERFACE_AGE = @CPPUNIT_INTERFACE_AGE@ +CPPUNIT_MAJOR_VERSION = @CPPUNIT_MAJOR_VERSION@ +CPPUNIT_MICRO_VERSION = @CPPUNIT_MICRO_VERSION@ +CPPUNIT_MINOR_VERSION = @CPPUNIT_MINOR_VERSION@ +CPPUNIT_VERSION = @CPPUNIT_VERSION@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +DOT = @DOT@ +DOXYGEN = @DOXYGEN@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +enable_dot = @enable_dot@ +enable_html_docs = @enable_html_docs@ +enable_latex_docs = @enable_latex_docs@ + +libcppunitincludedir = $(includedir)/cppunit/extensions + +libcppunitinclude_HEADERS = AbstractTestFactory.h AutoRegisterSuite.h HelperMacros.h Orthodox.h RepeatedTest.h TestDecorator.h TestFactoryRegistry.h TestSetup.h TestSuiteBuilder.h TestSuiteFactory.h + +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = ../../../include/config.h +CONFIG_CLEAN_FILES = +HEADERS = $(libcppunitinclude_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu include/cppunit/extensions/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +install-libcppunitincludeHEADERS: $(libcppunitinclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libcppunitincludedir) + @list='$(libcppunitinclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libcppunitincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libcppunitincludedir)/$$p; \ + done + +uninstall-libcppunitincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(libcppunitinclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libcppunitincludedir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = include/cppunit/extensions + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu include/cppunit/extensions/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-libcppunitincludeHEADERS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libcppunitincludeHEADERS +uninstall: uninstall-am +all-am: Makefile $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libcppunitincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-tags clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-tags distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: uninstall-libcppunitincludeHEADERS \ +install-libcppunitincludeHEADERS tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/include/cppunit/extensions/TestFactoryRegistry.h b/include/cppunit/extensions/TestFactoryRegistry.h new file mode 100644 index 0000000..fac97ec --- /dev/null +++ b/include/cppunit/extensions/TestFactoryRegistry.h @@ -0,0 +1,80 @@ +#ifndef CPPUNIT_TESTFACTORYREGISTRY_H +#define CPPUNIT_TESTFACTORYREGISTRY_H + +#include <map> +#include <string> +#include "cppunit/extensions/AbstractTestFactory.h" + +namespace CppUnit { + + class TestSuite; + + /** This class implements a registry for test factory. + * + * Note that the registry assume lifetime control for any registered test. + */ + class TestFactoryRegistry : public AbstractTestFactory + { + public: + /** Constructs the registry with the specified name. + * \param name Name of the registry. + */ + TestFactoryRegistry( std::string name = "All Tests" ); + + /// Destructor. + virtual ~TestFactoryRegistry(); + + /** Makes a suite containing all the registered test. + * \return A new suite containing all the registered test. + */ + virtual Test *makeTest(); + + /** Returns the registry. + * \return Registry. + */ + static TestFactoryRegistry &getRegistry(); + + /** Returns a named registry. + * \param name Name of the registry to return. + * \return Registry. If the registry does not exist, it is created. + */ + static TestFactoryRegistry &getRegistry( const std::string &name ); + + /** Adds the registered test to the specified suite. + * \param suite Suite the test are added to. + */ + void addTestToSuite( TestSuite *suite ); + + /** Registers a test factory with the specified name. + * \param name Name associated to the factory. + * \param factory Factory to register. + */ + void registerFactory( const std::string &name, + AbstractTestFactory *factory ); + +#ifdef USE_TYPEINFO + /** Registers a test factory using its class name. + * \param factory Factory to register. + */ + void registerFactory( AbstractTestFactory *factory ); +#endif // USE_TYPEINFO + + private: + TestFactoryRegistry( const TestFactoryRegistry © ); + void operator =( const TestFactoryRegistry © ); + + private: + typedef std::map<std::string, AbstractTestFactory*> Factories; + Factories m_factories; + + typedef std::map<std::string, TestFactoryRegistry*> NamedRegistries; + + std::string m_name; + }; + + + +} // namespace CppUnit + + +#endif // CPPUNIT_TESTFACTORYREGISTRY_H diff --git a/include/cppunit/extensions/TestSuiteBuilder.h b/include/cppunit/extensions/TestSuiteBuilder.h new file mode 100644 index 0000000..981fde9 --- /dev/null +++ b/include/cppunit/extensions/TestSuiteBuilder.h @@ -0,0 +1,55 @@ +#ifndef CPPUNIT_TESTSUITEBUILDER_H +#define CPPUNIT_TESTSUITEBUILDER_H + +#include <memory> + +#include "cppunit/TestSuite.h" +#include "cppunit/TestCaller.h" + +namespace CppUnit { + + template<class Fixture> + class TestSuiteBuilder + { + public: + typedef void (Fixture::*TestMethod)(); + + TestSuiteBuilder( TestSuite *suite ) : m_suite( suite ) + { + } + +#ifdef USE_TYPEINFO + TestSuiteBuilder() : m_suite( new TestSuite( typeid( Fixture) ) ) + { + } +#endif // USE_TYPEINFO + + TestSuite *suite() const + { + return m_suite.get(); + } + + TestSuite *takeSuite() + { + return m_suite.release(); + } + + void addTest( Test *test ) + { + m_suite->addTest( test ); + } + + void addTestCaller( std::string name, TestMethod testMethod ) + { + Test *test = makeTestCaller( m_suite->getName() + "." + name, + testMethod ); + addTest( test ); + } + + private: + std::auto_ptr<TestSuite> m_suite; + }; + +} // namespace CppUnit + +#endif // CPPUNIT_TESTSUITEBUILDER_H diff --git a/include/cppunit/extensions/TestSuiteFactory.h b/include/cppunit/extensions/TestSuiteFactory.h new file mode 100644 index 0000000..b438fe4 --- /dev/null +++ b/include/cppunit/extensions/TestSuiteFactory.h @@ -0,0 +1,25 @@ +#ifndef CPPUNIT_TESTSUITEFACTORY_H +#define CPPUNIT_TESTSUITEFACTORY_H + +#ifndef CPPUNIT_ABSTRACTTESTFACTORY_H +#include "AbstractTestFactory.h" +#endif + + +namespace CppUnit { + + class Test; + + template<class TestCaseType> + class TestSuiteFactory : public AbstractTestFactory + { + public: + virtual Test *makeTest() + { + return TestCaseType::suite(); + } + }; + +} // namespace CppUnit + +#endif // CPPUNIT_TESTSUITEFACTORY_H |
