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.

The class SourceLine
Figure C-12. The class SourceLine

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 TRUE if SourceLine is initialized (the filename is not empty).

int lineNumber( ) const

Returns the line number.

Protected/Private Methods

RepeatedTest(const RepeatedTest &)

A copy constructor declared private to prevent its use.

void operator=(const RepeatedTest &)

A copy operator declared private to prevent its use. ...

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.