winIDEA SDK
isys::CTestLocation Class Reference

Description

This class defines location in source code.

Location can be given either as line number in file, or line number in function. Line numbers in files are 1-based, because this convention is used by most text editors. Line numbers in function are 0-based, because it is easy to see the line number of zeroth function line in editor, and line number of the line where we want to set a test point, and simply subtract them. Furthermore, most developers in embedded world use C language, which is 0-based.

(Note: We can also find reasoning to have file line numbers 0-based or function relative line numbers 1-based, so whatever decision is made, it will be wrong from some other point of view. See also: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html)

#include <CTestPoint.h>

Inheritance diagram for isys::CTestLocation:
isys::CTestBase

Public Types

enum  ETestLocationSections
 Ids of test specification sections.
 

Public Member Functions

 CTestLocation (const CTestBaseSPtr &parent)
 Initializes new instance. More...
 
std::string getRuntimeLocation ()
 Returns location as calculated during runtime - file name and line number. More...
 
bool isMerged () const
 Returns true, if the CTestSpecification section containing this object is merged. More...
 
CLineDescription::EResourceType getResourceType ()
 Returns type of resource for which location is given.
 
std::string getResourceName ()
 Returns name of resource where test point is located.
 
CLineDescription::EFileLocation getSrcFileLocation ()
 Returns location of source files - local host running test case or remote host running winIDEA.
 
int getLine ()
 Returns line number, where test point is set, or where search range starts (if pattern is defined). More...
 
iconnect::ETristate isSearch ()
 Returns true, if search is to be performed. More...
 
int getLinesRange ()
 Returns the number of lines, which are searched for pattern. More...
 
CLineDescription::ESearchContext getSearchContext ()
 Returns search context for pattern.
 
CLineDescription::EMatchingType getMatchingType ()
 Returns matching type for pattern.
 
std::string getSearchPattern ()
 Returns search pattern. More...
 
int getLineOffset ()
 Returns the number of lines, which are added to line found by search pattern above.
 
int getNumSteps ()
 Returns the number of single execution steps to be performed before logging/evaluations/assignments take place.
 
void setResourceType (CLineDescription::EResourceType resourceType)
 Sets type of resource for which location is given.
 
void setResourceName (const std::string &resourceName)
 Sets name of resource where test point is located.
 
void setSrcFileLocation (CLineDescription::EFileLocation srcFileLoc)
 Sets source file location.
 
void setLine (int lineNumber)
 Sets line number, where test point is set, or where search range starts (if pattern is defined). More...
 
void setSearch (iconnect::ETristate isSearch)
 Sets the way to determine line number for test point. More...
 
void setLinesRange (int numLines)
 Sets the number of lines, which are searched for pattern. More...
 
void setSearchContext (CLineDescription::ESearchContext searchContext)
 Sets search context for pattern.
 
void setMatchingType (CLineDescription::EMatchingType matchingType)
 Sets matching type for pattern.
 
void setSearchPattern (const std::string &searchPattern)
 Sets search pattern. More...
 
void setLineOffset (int offset)
 Sets the number of lines, which are added to line found by search pattern above. More...
 
void setNumSteps (int numSteps)
 Sets the number of single execution steps (step over in source code) to be performed before logging/evaluations/assignments take place. More...
 
std::string validate ()
 Validates consistency of data in object.
 
isys::CLineDescriptionSPtr getLineDescription ()
 Returns adapter for this class, which can be used in CAddressController.
 
virtual bool isEmpty () const
 This method returns true, if the object contains no data.
 
virtual void serialize (const isys::IEmitterSPtr &emitter)
 Sends contents of this class to emitter.
 
virtual std::string toString ()
 Returns object data as YAML string.
 

Static Public Member Functions

static CTestLocationSPtr cast (const CTestBaseSPtr &testBase)
 Casts the given object to this class. More...
 

Protected Member Functions

void setStaticTagsAsConst ()
 This method is called by all objects which are immediately contained in CTestSpecification, for example CTestCoverage, CTestHIL, ...
 

Constructor & Destructor Documentation

◆ CTestLocation()

isys::CTestLocation::CTestLocation ( const CTestBaseSPtr parent)

Initializes new instance.

Parameters
parentan instance of parent CTestPoint class.

Member Function Documentation

◆ cast()

static CTestLocationSPtr isys::CTestLocation::cast ( const CTestBaseSPtr testBase)
static

Casts the given object to this class.

Returns NULL if input is NULL.

Exceptions
IllegalArgumentExceptionif input object is not instance of this class.

◆ getLine()

int isys::CTestLocation::getLine ( )

Returns line number, where test point is set, or where search range starts (if pattern is defined).

Lines for file are 1-based, while lines for function are 0 based and can also be negative.

◆ getLinesRange()

int isys::CTestLocation::getLinesRange ( )

Returns the number of lines, which are searched for pattern.

Value 0 means till the end of file.

◆ getRuntimeLocation()

std::string isys::CTestLocation::getRuntimeLocation ( )

Returns location as calculated during runtime - file name and line number.

This information is available only after test execution, and is not stored to iyaml file. If runtime location has not been set yet, an empty string is returned.

◆ getSearchPattern()

std::string isys::CTestLocation::getSearchPattern ( )

Returns search pattern.

If this item is not defined (empty string is returned), then test point is located in line returned by getLine(). No search is performed. Num lines, search context, and matching type are ignored.

◆ isMerged()

bool isys::CTestLocation::isMerged ( ) const
virtual

Returns true, if the CTestSpecification section containing this object is merged.


Reimplemented from isys::CTestBase.

◆ isSearch()

iconnect::ETristate isys::CTestLocation::isSearch ( )

Returns true, if search is to be performed.

Otherwise the line number returned by getLine() is used to set a test point.

◆ setLine()

void isys::CTestLocation::setLine ( int  lineNumber)

Sets line number, where test point is set, or where search range starts (if pattern is defined).

Lines are 1-based.

◆ setLineOffset()

void isys::CTestLocation::setLineOffset ( int  offset)

Sets the number of lines, which are added to line found by search pattern above.

Use this setting when the actual line has no specific pattern to search for, while the line before it can be identified more reliably.

◆ setLinesRange()

void isys::CTestLocation::setLinesRange ( int  numLines)

Sets the number of lines, which are searched for pattern.

Value 0 means till the end of file.

◆ setNumSteps()

void isys::CTestLocation::setNumSteps ( int  numSteps)

Sets the number of single execution steps (step over in source code) to be performed before logging/evaluations/assignments take place.

This setting may be useful when we want to log/evaluate/assign a variable after the current line is executed. May also be used when test point is set at function start, and we want to execute function prolog, so that local variables and parameters are visible.

◆ setSearch()

void isys::CTestLocation::setSearch ( iconnect::ETristate  isSearch)

Sets the way to determine line number for test point.

Parameters
isSearchif E_FALSE or E_DEFAULT, no search is done - then line returned by getLine() is used as test point location.

◆ setSearchPattern()

void isys::CTestLocation::setSearchPattern ( const std::string &  searchPattern)

Sets search pattern.

If this item is not defined (empty string is specified), then test point is located in line returned by getLine(). No search is performed. Num lines, search context, and matching type are ignored.

Parameters
searchPatterndepending on the value of matching type (see setMatchingType() ) this pattern represents either exact text to be found or regular expression.