Name
SourceLine
Description
The class SourceLine
(see Figure C-12)
represents a location in a source code file. It is used to capture
the location of an assertion failure. A SourceLine
usually is created using the macro CPPUNIT_SOURCELINE(
), which uses the preprocessor directives _ _FILE_
_ and __LINE_ _ to obtain the filename
and line number of the location where it’s invoked:
#define CPPUNIT_SOURCELINE( ) ::CppUnit::SourceLine( __FILE__, __LINE_ _ )
SourceLine belongs to the namespace
CppUnit. It is declared in
SourceLine.h and implemented in
SourceLine.cpp.
![]() |
Declaration
class SourceLine
Constructors/Destructors
-
SourceLine(string &fileName, int lineNumber) A constructor taking a filename and line number.
-
SourceLine( ) A default constructor creating an uninitialized
SourceLine.-
virtual ~SourceLine( ) A destructor.
Public Methods
-
bool operator==(const SourceLine &other) const A comparison operator.
-
bool operator!=(const SourceLine &other) const An inequality operator.
-
string fileName( ) const Returns the filename.
-
bool isValid( ) const Returns
TRUEifSourceLineis initialized (the filename is not empty).-
int lineNumber( ) const Returns the line number.
Protected/Private Methods
-
RepeatedTest(const RepeatedTest &) A copy constructor declared
privateto prevent its use.-
void operator=(const RepeatedTest &) A copy operator declared
privateto prevent its use. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
