[Opal-commits] opal/src/external/quicktest Makefile.am,NONE,1.1 Makefile.in,NONE,1.1 quicktest.h,NON
Status: Inactive
Brought to you by:
tylerstreeter
|
From: Olex <ole...@us...> - 2005-11-06 17:41:49
|
Update of /cvsroot/opal/opal/src/external/quicktest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12151/src/external/quicktest Added Files: Makefile.am Makefile.in quicktest.h Log Message: Added KDevelop project files. Added skeleton for unit tests. Added quicktest to external headers. --- NEW FILE: Makefile.in --- # Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 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. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../../.. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/external/quicktest DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ F77 = @F77@ FFLAGS = @FFLAGS@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ prefix = @prefix@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ INCLUDES = $(all_includes) METASOURCES = AUTO noinst_HEADERS = quicktest.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/external/quicktest/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/external/quicktest/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-libtool \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool ctags distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-info-am # 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: --- NEW FILE: Makefile.am --- INCLUDES = $(all_includes) METASOURCES = AUTO noinst_HEADERS = quicktest.h --- NEW FILE: quicktest.h --- /************************************************************************* * * * QuickTest * * Copyright (C) 2005 * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: quicktest.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library 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 files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // Credits: // Thanks to Noel Llopis for his helpful comparison of various C++ unit // testing frameworks and ideas for an ideal simple testing framework: // http://www.gamesfromwithin.com/articles/0412/000061.html Thanks to // Michael Feathers for developing CppUnitLite. Many of the macros in // Quicktest were modeled after those in CppUnitLite. #ifndef QUICK_TEST_H #define QUICK_TEST_H #include <string> #include <sstream> #include <vector> #include <iostream> // ----------------------------------------------------------------------- // Design Notes // ----------------------------------------------------------------------- // * Each test automatically registers itself by accessing the TestManager // singleton. // // * There are no formal fixtures. Fixtures are simply user-defined // objects. setup and teardown occur in the user-defined object's // constructor and destructor. Tests that need fixtures should staticly // allocate one of these objects at the beginning of the test. This method // is flexible and conceptually simple. namespace quicktest { typedef std::vector<std::string> TestResult; class Test { public: Test(const std::string& testGroup, const std::string& testName) { mTestName = testName; mTestGroup = testGroup; } const std::string & getGroup() { return mTestGroup; } virtual void run(TestResult& result) = 0; protected: void recordFailure(TestResult& result, const std::string& file, unsigned long int line, const std::string& message) { // If the full filename is too long, only use the last part. std::string fileStr = file; size_t maxLength = 40; size_t fileLength = file.size(); if (fileLength > maxLength) { // Get the last maxLength characters - 3 (leave room for // three ellipses at the beginning). fileStr = "..."; fileStr += file.substr(fileLength - maxLength + 3, fileLength - 1); } std::ostringstream oss; oss << fileStr << "(" << line << "): '" << mTestName << " from " << mTestGroup << " ' FAILED: " << message; result.push_back(oss.str()); } /// The unique name of this test. std::string mTestName; /// The group name of this test std::string mTestGroup; }; class TestManager { public: static TestManager& instance() { static TestManager self; return self; } void addTest(Test* test) { mTests.push_back(test); } void setOutputStream(std::ostream* stream) { mOutputStream = stream; } std::ostream* getOutputStream() { return mOutputStream; } void runTests() { unsigned int numFailures = 0; *getOutputStream() << "[---------------- RUNNING TESTS ----------------]" << std::endl; unsigned int numLocalFailures = 0; unsigned int numLocalSuccesses = 0; std::string currentGroup; std::vector<Test*>::iterator iter; for (iter = mTests.begin(); iter != mTests.end(); ++iter) { if ( currentGroup != (*iter)->getGroup() ) { if ( !currentGroup.empty() ) { *getOutputStream() << "Group results: " << numLocalSuccesses << " succeeded, " << numLocalFailures << " failed" << std::endl; } currentGroup = (*iter)->getGroup(); *getOutputStream() << "Group: " << (*iter)->getGroup() << std::endl; numLocalFailures = 0; numLocalSuccesses = 0; } (*iter)->run(mResult); bool testFailed = false; size_t size = mResult.size(); for (size_t i = 0; i < size; ++i) { *getOutputStream() << mResult.at(i) << std::endl; testFailed = true; } mResult.clear(); if (testFailed) { ++numFailures; ++numLocalFailures; } else { ++numLocalSuccesses; } } if ( !currentGroup.empty() ) { *getOutputStream() << "Group results: " << numLocalSuccesses << " succeeded, " << numLocalFailures << " failed" << std::endl; } *getOutputStream() << "Overall results: " << (unsigned int)mTests.size() - numFailures << " succeeded, " << numFailures << " failed" << std::endl; *getOutputStream() << "[---------------- TESTS FINISHED ---------------]" << std::endl; } private: TestManager() { mOutputStream = &std::cout; } ~TestManager() { } /// List of pointers to Tests. All tests are staticly allocated, /// so we don't need to destroy them manually. std::vector<Test*> mTests; std::ostream* mOutputStream; TestResult mResult; }; } /// Macro to define a single test without using a fixture. #define QT_TEST(testName)\ class testName##Test : public quicktest::Test\ {\ public:\ testName##Test()\ : Test(__FILE__, #testName)\ {\ quicktest::TestManager::instance().addTest(this);\ }\ void run(quicktest::TestResult& result);\ }testName##Instance;\ void testName##Test::run(quicktest::TestResult& result) /// Macro that runs all tests. #define QT_RUN_TESTS quicktest::TestManager::instance().runTests() /// Macro that sets the output stream to use. #define QT_SET_OUTPUT(stream)\ quicktest::TestManager::instance().setOutputStream(stream) /// Checks whether the given condition is true. #define QT_CHECK(condition)\ {\ if (!(condition))\ {\ recordFailure(result, __FILE__, __LINE__, #condition);\ }\ } /// Checks whether the first parameter is equal to the second. #define QT_CHECK_EQUAL(value1, value2)\ {\ if ((value1) != (value2))\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should equal "\ << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Checks whether the first parameter is not equal to the second. #define QT_CHECK_NOT_EQUAL(value1, value2)\ {\ if ((value1) == (value2))\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should not equal "\ << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Checks whether the first parameter is within the given tolerance from /// the second parameter. This is useful for comparing floating point /// values. #define QT_CHECK_CLOSE(value1, value2, tolerance)\ {\ if (abs((value1)-(value2)) > tolerance)\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should be close to "\ << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Checks whether the first parameter is less than the second. #define QT_CHECK_LESS(value1, value2)\ {\ if ((value1) >= (value2))\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should be less than "\ << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Checks whether the first parameter is less than or equal to the second. #define QT_CHECK_LESS_OR_EQUAL(value1, value2)\ {\ if ((value1) > (value2))\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should be less than or "\ << "equal to " << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Checks whether the first parameter is greater than the second. #define QT_CHECK_GREATER(value1, value2)\ {\ if ((value1) <= (value2))\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should be greater than "\ << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Checks whether the first parameter is greater than or equal to the /// second. #define QT_CHECK_GREATER_OR_EQUAL(value1, value2)\ {\ if ((value1) < (value2))\ {\ std::ostringstream oss;\ oss << "value1 (" << (value1) << ") should be greater than or "\ << "equal to " << "value2 (" << (value2) << ")";\ recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } /// Fails unconditionally and prints the given message. #define QT_FAIL(message)\ {\ recordFailure(result, __FILE__, __LINE__, (message));\ }\ /// Prints the given message, followed by a carriage return. #define QT_PRINT(message)\ {\ *(quicktest::TestManager::instance().getOutputStream()) << (message)\ << std::endl;\ }\ #endif |