CppUnit - The Unit Testing Library

CppUnit project page | FAQ

TestNamer.h
Go to the documentation of this file.
1#ifndef CPPUNIT_EXTENSIONS_TESTNAMER_H
2#define CPPUNIT_EXTENSIONS_TESTNAMER_H
3
4#include <cppunit/Portability.h>
5#include <string>
6#include <cppunit/tools/StringHelper.h>
7
8#include <typeinfo>
9
10
11
28# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \
29 CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) )
30
31 CPPUNIT_NS_BEGIN
32
38 class CPPUNIT_API TestNamer
39{
40public:
44 TestNamer( const std::type_info &typeInfo );
45
49 TestNamer( const std::string &fixtureName );
50
51 virtual ~TestNamer();
52
56 virtual std::string getFixtureName() const;
57
65 virtual std::string getTestNameFor( const std::string &testMethodName ) const;
66
67 template<typename E>
68 std::string getTestNameFor( const std::string& testMethodName, const E& val) const
69 {
70 return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val);
71 }
72
73protected:
74 std::string m_fixtureName;
75};
76
77 CPPUNIT_NS_END
78
79#endif // CPPUNIT_EXTENSIONS_TESTNAMER_H
80
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:105
StringHelper.h
TestNamer
Names a test or a fixture suite.
Definition: TestNamer.h:39
TestNamer::m_fixtureName
std::string m_fixtureName
Definition: TestNamer.h:74
TestNamer::getTestNameFor
std::string getTestNameFor(const std::string &testMethodName, const E &val) const
Definition: TestNamer.h:68
StringHelper::toString
std::enable_if<!std::is_enum< T >::value, std::string >::type toString(const T &x)
Definition: StringHelper.h:22

| Send comments to: CppUnit Developers