summaryrefslogtreecommitdiff
path: root/include/cppunit
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-07-14 18:48:32 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-07-14 18:48:32 +0000
commit251c1ff8aecaa608ef9e6041c2691d369430bf7b (patch)
tree183795a04e06a8a94a64214afc2a1cc8a12a5486 /include/cppunit
parent0807889cb53679c5a9e741e8dedc3668ef59729b (diff)
downloadcppunit-251c1ff8aecaa608ef9e6041c2691d369430bf7b.tar.gz
CodingGuideLines.
CodingGuideLines.txt: added. CppUnit's coding guidelines for portability. * include/cppunit/portability/CppUnitStack.h: added. wrapper for std::stack. * include/cppunit/portability/CppUnitSet.h: added. wrapper for std::set. * include/cppunit/ui/text/TestRunner.h: fixed namespace definition for deprecated TestRunner. * include/cppunit/TestAssert.h: * src/cppunit/TestAssert.cpp: removed old deprecated functions that did not use SourceLine. Moved assertEquals() and assertDoubleEquals() into CppUnit namespace. * src/cppunit/TestFactoryRegistry.cpp: use CppUnitMap instead of std::map. * src/DllPlugInTester/CommandLineParser.h: use CppUnitDeque instead std::deque. * examples/cppunittest/*.h: * examples/cppunittest/*.cpp: removed all usage of CppUnitTest namespace. Everything is now in global space. * examples/*/*.h: * examples/*/*.cpp: replaced usage of CppUnit:: with CPPUNIT_NS::. * examples/ClockerPlugIn/ClockerModel.h: use CppUnit STL wrapper instead of STL container.
Diffstat (limited to 'include/cppunit')
-rw-r--r--include/cppunit/TestAssert.h106
-rw-r--r--include/cppunit/TextTestRunner.h14
-rw-r--r--include/cppunit/XmlOutputter.h4
-rw-r--r--include/cppunit/config/config-msvc6.h5
-rw-r--r--include/cppunit/extensions/TestFactoryRegistry.h4
-rw-r--r--include/cppunit/plugin/TestPlugIn.h3
-rw-r--r--include/cppunit/portability/CppUnitDeque.h4
-rw-r--r--include/cppunit/portability/CppUnitMap.h4
-rw-r--r--include/cppunit/portability/CppUnitSet.h27
-rw-r--r--include/cppunit/portability/CppUnitStack.h26
-rw-r--r--include/cppunit/portability/CppUnitVector.h4
-rw-r--r--include/cppunit/portability/Makefile.am6
-rw-r--r--include/cppunit/ui/text/TestRunner.h19
-rw-r--r--include/cppunit/ui/text/TextTestRunner.h1
14 files changed, 115 insertions, 112 deletions
diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h
index ba30e9c..87510df 100644
--- a/include/cppunit/TestAssert.h
+++ b/include/cppunit/TestAssert.h
@@ -49,66 +49,34 @@ struct assertion_traits
};
-namespace TestAssert
+/*! \brief (Implementation) Asserts that two objects of the same type are equals.
+ * Use CPPUNIT_ASSERT_EQUAL instead of this function.
+ * \sa assertion_traits, Asserter::failNotEqual().
+ */
+template <class T>
+void assertEquals( const T& expected,
+ const T& actual,
+ SourceLine sourceLine,
+ const std::string &message ="" )
{
-#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
- void CPPUNIT_API assertImplementation( bool condition,
- std::string conditionExpression = "",
- long lineNumber,
- std::string fileName );
-
- void CPPUNIT_API assertNotEqualImplementation( std::string expected,
- std::string actual,
- long lineNumber,
- std::string fileName );
-
-
- template <class T>
- void assertEquals( const T& expected,
- const T& actual,
- long lineNumber,
- std::string fileName )
+ if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
{
- if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
- {
- assertNotEqualImplementation( assertion_traits<T>::toString(expected),
- assertion_traits<T>::toString(actual),
- lineNumber,
- fileName );
- }
+ Asserter::failNotEqual( assertion_traits<T>::toString(expected),
+ assertion_traits<T>::toString(actual),
+ sourceLine,
+ message );
}
-
- void CPPUNIT_API assertEquals( double expected,
- double actual,
- double delta,
- long lineNumber,
- std::string fileName );
-
-#else // using SourceLine
-
- template <class T>
- void assertEquals( const T& expected,
- const T& actual,
- SourceLine sourceLine,
- const std::string &message ="" )
- {
- if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
- {
- Asserter::failNotEqual( assertion_traits<T>::toString(expected),
- assertion_traits<T>::toString(actual),
- sourceLine,
- message );
- }
- }
-
- void CPPUNIT_API assertDoubleEquals( double expected,
- double actual,
- double delta,
- SourceLine sourceLine );
-
-#endif
}
+/*! \brief (Implementation) Asserts that two double are equals given a tolerance.
+ * Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function.
+ * \sa Asserter::failNotEqual().
+ */
+void CPPUNIT_API assertDoubleEquals( double expected,
+ double actual,
+ double delta,
+ SourceLine sourceLine );
+
/* A set of macros which allow us to get the line number
* and file name at the point of an error.
@@ -155,9 +123,9 @@ namespace TestAssert
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
/// Generalized macro for primitive value comparisons
#define CPPUNIT_ASSERT_EQUAL(expected,actual) \
- ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \
- (actual), \
- __LINE__, __FILE__ ) )
+ ( CPPUNIT_NS::assertEquals( (expected), \
+ (actual), \
+ __LINE__, __FILE__ ) )
#else
/** Asserts that two values are equals.
* \ingroup Assertions
@@ -176,9 +144,9 @@ namespace TestAssert
* removed by specializing the CppUnit::assertion_traits.
*/
#define CPPUNIT_ASSERT_EQUAL(expected,actual) \
- ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \
- (actual), \
- CPPUNIT_SOURCELINE() ) )
+ ( CPPUNIT_NS::assertEquals( (expected), \
+ (actual), \
+ CPPUNIT_SOURCELINE() ) )
/** Asserts that two values are equals, provides additional messafe on failure.
* \ingroup Assertions
@@ -199,20 +167,20 @@ namespace TestAssert
* removed by specializing the CppUnit::assertion_traits.
*/
#define CPPUNIT_ASSERT_EQUAL_MESSAGE(message,expected,actual) \
- ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \
- (actual), \
- CPPUNIT_SOURCELINE(), \
- (message) ) )
+ ( CPPUNIT_NS::assertEquals( (expected), \
+ (actual), \
+ CPPUNIT_SOURCELINE(), \
+ (message) ) )
#endif
/*! \brief Macro for primitive value comparisons
* \ingroup Assertions
*/
#define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \
- ( CPPUNIT_NS::TestAssert::assertDoubleEquals( (expected), \
- (actual), \
- (delta), \
- CPPUNIT_SOURCELINE() ) )
+ ( CPPUNIT_NS::assertDoubleEquals( (expected), \
+ (actual), \
+ (delta), \
+ CPPUNIT_SOURCELINE() ) )
// Backwards compatibility
diff --git a/include/cppunit/TextTestRunner.h b/include/cppunit/TextTestRunner.h
index 28c2513..23890e0 100644
--- a/include/cppunit/TextTestRunner.h
+++ b/include/cppunit/TextTestRunner.h
@@ -3,18 +3,4 @@
#include <cppunit/ui/text/TextTestRunner.h>
-
-#if !defined(CPPUNIT_NO_NAMESPACE)
-namespace TextUi
-{
-
- /*! Text TestRunner (DEPRECATED).
- * \deprecated Use TextTestRunner instead.
- */
- typedef TextTestRunner TestRunner;
-
-}
-#endif
-
-
#endif // CPPUNIT_TEXTTESTRUNNER_H
diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h
index b28b727..fafffa2 100644
--- a/include/cppunit/XmlOutputter.h
+++ b/include/cppunit/XmlOutputter.h
@@ -10,8 +10,8 @@
#include <cppunit/Outputter.h>
#include <cppunit/portability/CppUnitDeque.h>
+#include <cppunit/portability/CppUnitMap.h>
#include <iostream>
-#include <map>
CPPUNIT_NS_BEGIN
@@ -76,7 +76,7 @@ public:
virtual void setStyleSheet( const std::string &styleSheet );
- typedef std::map<Test *,TestFailure*> FailedTests;
+ typedef CppUnitMap<Test *,TestFailure*> FailedTests;
/*! Sets the root element and adds its children.
*
diff --git a/include/cppunit/config/config-msvc6.h b/include/cppunit/config/config-msvc6.h
index eea5cf6..2c48a92 100644
--- a/include/cppunit/config/config-msvc6.h
+++ b/include/cppunit/config/config-msvc6.h
@@ -56,8 +56,9 @@
// Uncomment to turn on STL wrapping => use this to test compilation.
// This will make CppUnit subclass std::vector & co to provide default
// parameter.
-#define CPPUNIT_STD_NEED_ALLOCATOR 1
-#define CPPUNIT_STD_ALLOCATOR std::allocator<T>
+//#define CPPUNIT_STD_NEED_ALLOCATOR 1
+//#define CPPUNIT_STD_ALLOCATOR std::allocator<T>
+#define CPPUNIT_NO_NAMESPACE 1
/* _INCLUDE_CPPUNIT_CONFIG_MSVC6_H */
diff --git a/include/cppunit/extensions/TestFactoryRegistry.h b/include/cppunit/extensions/TestFactoryRegistry.h
index 1164bf3..8109d40 100644
--- a/include/cppunit/extensions/TestFactoryRegistry.h
+++ b/include/cppunit/extensions/TestFactoryRegistry.h
@@ -8,8 +8,8 @@
#pragma warning( disable: 4251) // X needs to have dll-interface to be used by clients of class Z
#endif
+#include <cppunit/portability/CppUnitSet.h>
#include <cppunit/extensions/TestFactory.h>
-#include <set>
#include <string>
CPPUNIT_NS_BEGIN
@@ -165,7 +165,7 @@ private:
void operator =( const TestFactoryRegistry &copy );
private:
- typedef std::set<TestFactory *> Factories;
+ typedef CppUnitSet<TestFactory *> Factories;
Factories m_factories;
std::string m_name;
diff --git a/include/cppunit/plugin/TestPlugIn.h b/include/cppunit/plugin/TestPlugIn.h
index d206d79..06e0888 100644
--- a/include/cppunit/plugin/TestPlugIn.h
+++ b/include/cppunit/plugin/TestPlugIn.h
@@ -14,7 +14,8 @@ class Test;
class TestFactoryRegistry;
class TestResult;
class XmlOutputter;
-}
+
+CPPUNIT_NS_END
/*! \file
*/
diff --git a/include/cppunit/portability/CppUnitDeque.h b/include/cppunit/portability/CppUnitDeque.h
index 781c43e..fac09d6 100644
--- a/include/cppunit/portability/CppUnitDeque.h
+++ b/include/cppunit/portability/CppUnitDeque.h
@@ -9,16 +9,12 @@
#if CPPUNIT_STD_NEED_ALLOCATOR
-CPPUNIT_NS_BEGIN
-
template<class T>
class CppUnitDeque : public std::deque<T,CPPUNIT_STD_ALLOCATOR>
{
public:
};
-CPPUNIT_NS_END
-
#else // CPPUNIT_STD_NEED_ALLOCATOR
#define CppUnitDeque std::deque
diff --git a/include/cppunit/portability/CppUnitMap.h b/include/cppunit/portability/CppUnitMap.h
index 24df4a5..3073e6f 100644
--- a/include/cppunit/portability/CppUnitMap.h
+++ b/include/cppunit/portability/CppUnitMap.h
@@ -10,8 +10,6 @@
#if CPPUNIT_STD_NEED_ALLOCATOR
-CPPUNIT_NS_BEGIN
-
template<class Key, class T>
class CppUnitMap : public std::map<Key
,T
@@ -21,8 +19,6 @@ class CppUnitMap : public std::map<Key
public:
};
-CPPUNIT_NS_END
-
#else // CPPUNIT_STD_NEED_ALLOCATOR
#define CppUnitMap std::map
diff --git a/include/cppunit/portability/CppUnitSet.h b/include/cppunit/portability/CppUnitSet.h
new file mode 100644
index 0000000..a6c0a8f
--- /dev/null
+++ b/include/cppunit/portability/CppUnitSet.h
@@ -0,0 +1,27 @@
+#ifndef CPPUNIT_PORTABILITY_CPPUNITSET_H
+#define CPPUNIT_PORTABILITY_CPPUNITSET_H
+
+// The technic used is similar to the wrapper of STLPort.
+
+#include <cppunit/Portability.h>
+#include <functional>
+#include <set>
+
+
+#if CPPUNIT_STD_NEED_ALLOCATOR
+
+template<class T>
+class CppUnitSet : public std::set<T
+ ,std::less<T>
+ ,CPPUNIT_STD_ALLOCATOR>
+{
+public:
+};
+
+#else // CPPUNIT_STD_NEED_ALLOCATOR
+
+#define CppUnitSet std::set
+
+#endif
+
+#endif // CPPUNIT_PORTABILITY_CPPUNITSET_H \ No newline at end of file
diff --git a/include/cppunit/portability/CppUnitStack.h b/include/cppunit/portability/CppUnitStack.h
new file mode 100644
index 0000000..bc7785b
--- /dev/null
+++ b/include/cppunit/portability/CppUnitStack.h
@@ -0,0 +1,26 @@
+#ifndef CPPUNIT_PORTABILITY_CPPUNITSTACK_H
+#define CPPUNIT_PORTABILITY_CPPUNITSTACK_H
+
+// The technic used is similar to the wrapper of STLPort.
+
+#include <cppunit/Portability.h>
+#include <deque>
+#include <stack>
+
+
+#if CPPUNIT_STD_NEED_ALLOCATOR
+
+template<class T>
+class CppUnitStack : public std::stack<T
+ ,std::deque<T,CPPUNIT_STD_ALLOCATOR> >
+{
+public:
+};
+
+#else // CPPUNIT_STD_NEED_ALLOCATOR
+
+#define CppUnitStack std::stack
+
+#endif
+
+#endif // CPPUNIT_PORTABILITY_CPPUNITSTACK_H \ No newline at end of file
diff --git a/include/cppunit/portability/CppUnitVector.h b/include/cppunit/portability/CppUnitVector.h
index f3157e6..83525d3 100644
--- a/include/cppunit/portability/CppUnitVector.h
+++ b/include/cppunit/portability/CppUnitVector.h
@@ -9,16 +9,12 @@
#if CPPUNIT_STD_NEED_ALLOCATOR
-CPPUNIT_NS_BEGIN
-
template<class T>
class CppUnitVector : public std::vector<T,CPPUNIT_STD_ALLOCATOR>
{
public:
};
-CPPUNIT_NS_END
-
#else // CPPUNIT_STD_NEED_ALLOCATOR
#define CppUnitVector std::vector
diff --git a/include/cppunit/portability/Makefile.am b/include/cppunit/portability/Makefile.am
index c70aaf0..1fb032e 100644
--- a/include/cppunit/portability/Makefile.am
+++ b/include/cppunit/portability/Makefile.am
@@ -2,5 +2,7 @@ libcppunitincludedir = $(includedir)/cppunit/portability
libcppunitinclude_HEADERS = \
CppUnitDeque.h \
- CppUnitVector.h \
- CppUnitMap.h
+ CppUnitMap.h \
+ CppUnitSet.h \
+ CppUnitStack.h \
+ CppUnitVector.h
diff --git a/include/cppunit/ui/text/TestRunner.h b/include/cppunit/ui/text/TestRunner.h
index c931f66..023eb83 100644
--- a/include/cppunit/ui/text/TestRunner.h
+++ b/include/cppunit/ui/text/TestRunner.h
@@ -3,17 +3,22 @@
#include <cppunit/ui/text/TextTestRunner.h>
-CPPUNIT_NS_BEGIN
+#if defined(CPPUNIT_HAVE_NAMESPACES)
-/*!
- * \brief A text mode test runner.
- * \ingroup ExecutingTest
- * \deprecated Use CppUnit::TextUi::TestRunner instead.
- */
-typedef CPPUNIT_NS::TextUi::TestRunner TextTestRunner;
+CPPUNIT_NS_BEGIN
+namespace TextUi
+{
+ /*! Text TestRunner (DEPRECATED).
+ * \deprecated Use TextTestRunner instead.
+ */
+ typedef TextTestRunner TestRunner;
+}
CPPUNIT_NS_END
+#endif // defined(CPPUNIT_HAVE_NAMESPACES)
+
+
#endif // CPPUNIT_UI_TEXT_TESTRUNNER_H
diff --git a/include/cppunit/ui/text/TextTestRunner.h b/include/cppunit/ui/text/TextTestRunner.h
index dee37a7..76e225e 100644
--- a/include/cppunit/ui/text/TextTestRunner.h
+++ b/include/cppunit/ui/text/TextTestRunner.h
@@ -4,7 +4,6 @@
#include <cppunit/Portability.h>
#include <string>
-#include <vector>
#include <cppunit/TestRunner.h>
CPPUNIT_NS_BEGIN