/usr/include/cppunit/extensions/TestSuiteBuilderContext.h is in libcppunit-dev 1.14.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | #ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
#define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
#include <cppunit/Portability.h>
#include <map>
#include <string>
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( push )
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
#endif
CPPUNIT_NS_BEGIN
class TestSuite;
class TestFixture;
class TestFixtureFactory;
class TestNamer;
/*! \brief Context used when creating test suite in HelperMacros.
*
* Base class for all context used when creating test suite. The
* actual context type during test suite creation is TestSuiteBuilderContext.
*
* \sa CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_ADD_TEST,
* CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS.
*/
class CPPUNIT_API TestSuiteBuilderContextBase
{
public:
/*! \brief Constructs a new context.
*
* You should not use this. The context is created in
* CPPUNIT_TEST_SUITE().
*/
TestSuiteBuilderContextBase( TestSuite &suite,
const TestNamer &namer,
TestFixtureFactory &factory );
virtual ~TestSuiteBuilderContextBase();
/*! \brief Adds a test to the fixture suite.
*
* \param test Test to add to the fixture suite. Must not be \c NULL.
*/
void addTest( Test *test );
/*! \brief Returns the fixture name.
* \return Fixture name. It is the name used to name the fixture
* suite.
*/
std::string getFixtureName() const;
/*! \brief Returns the name of the test for the specified method.
*
* \param testMethodName Name of the method that implements a test.
* \return A string that is the concatenation of the test fixture name
* (returned by getFixtureName()) and\a testMethodName,
* separated using '::'. This provides a fairly unique name for a given
* test.
*/
std::string getTestNameFor( const std::string &testMethodName ) const;
/*! \brief Returns the name of the test for the specified method with the corresponding parameter.
*
* \param testMethodName Name (including a parameter) of the method that implements a test.
* \return A string that is the concatenation of the test fixture name
* (returned by getFixtureName()), \a testMethodName,
* separated using '::' and the parameter. This provides a fairly unique name for a given
* test. The parameter must be convertable to std::string through operator<<
* or a specialization of CPPUNIT_NS::StringHelper::toString needs to exist.
*/
template<typename T>
std::string getTestNameFor( const std::string &testMethodName, const T& value ) const
{
return m_namer.getTestNameFor(testMethodName, value);
}
/*! \brief Adds property pair.
* \param key PropertyKey string to add.
* \param value PropertyValue string to add.
*/
void addProperty( const std::string &key,
const std::string &value );
/*! \brief Returns property value assigned to param key.
* \param key PropertyKey string.
*/
const std::string getStringProperty( const std::string &key ) const;
protected:
TestFixture *makeTestFixture() const;
// Notes: we use a vector here instead of a map to work-around the
// shared std::map in dll bug in VC6.
// See http://www.dinkumware.com/vc_fixes.html for detail.
typedef std::pair<std::string,std::string> Property;
typedef std::vector<Property> Properties;
TestSuite &m_suite;
const TestNamer &m_namer;
TestFixtureFactory &m_factory;
private:
Properties m_properties;
};
/*! \brief Type-sage context used when creating test suite in HelperMacros.
*
* \sa TestSuiteBuilderContextBase.
*/
template<class Fixture>
class TestSuiteBuilderContext : public TestSuiteBuilderContextBase
{
public:
typedef Fixture FixtureType;
TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase )
: TestSuiteBuilderContextBase( contextBase )
{
}
/*! \brief Returns a new TestFixture instance.
* \return A new fixture instance. The fixture instance is returned by
* the TestFixtureFactory passed on construction. The actual type
* is that of the fixture on which the static method suite()
* was called.
*/
FixtureType *makeFixture() const
{
return CPPUNIT_STATIC_CAST( FixtureType *,
TestSuiteBuilderContextBase::makeTestFixture() );
}
};
CPPUNIT_NS_END
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( pop )
#endif
#endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
|