SourceLine

   
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 .

Figure C-12. The class SourceLine
figs/utf_ac12.gif

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.

Attributes


string m_fileName

The source filename ( private ).


int m_lineNumber

The source file line number ( private ).



Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net