1#ifndef CPPUNIT_SOURCELINE_H 2#define CPPUNIT_SOURCELINE_H 3 4#include <cppunit/Portability.h> 5#include <string> 6 7/*! \brief Constructs a SourceLine object initialized with the location where the macro is expanded. 8 * \ingroup CreatingNewAssertions 9 * \relates CppUnit::SourceLine 10 * Used to write your own assertion macros. 11 * \see Asserter for example of usage. 12 */ 13#define CPPUNIT_SOURCELINE() ::CppUnit::SourceLine( __FILE__, __LINE__ ) 14 15 16namespace CppUnit 17{ 18 19/*! \brief Represents a source line location. 20 * \ingroup CreatingNewAssertions 21 * \ingroup BrowsingCollectedTestResult 22 * 23 * Used to capture the failure location in assertion. 24 * 25 * Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when 26 * writing an assertion macro in association with Asserter. 27 * 28 * \see Asserter. 29 */ 30class CPPUNIT_API SourceLine 31{ 32public: 33 SourceLine(); 34 35 SourceLine( const std::string &fileName, 36 int lineNumber ); 37 38 /// Destructor. 39 virtual ~SourceLine(); 40 41 bool isValid() const; 42 43 int lineNumber() const; 44 45 std::string fileName() const; 46 47 bool operator ==( const SourceLine &other ) const; 48 bool operator !=( const SourceLine &other ) const; 49 50private: 51 std::string m_fileName; 52 int m_lineNumber; 53}; 54 55 56} // namespace CppUnit 57 58 59 60#endif // CPPUNIT_SOURCELINE_H 61