winIDEA SDK
|
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>
Public Types | |
enum | ETestLocationSections |
Ids of test specification sections. | |
Public Member Functions | |
CTestLocation (const CTestBaseSPtr &parent) | |
Initializes new instance. More... | |
int | getLine () |
Returns line number, where test point is set, or where search range starts (if pattern is defined). More... | |
isys::CLineDescriptionSPtr | getLineDescription () |
Returns adapter for this class, which can be used in CAddressController. | |
int | getLineOffset () |
Returns the number of lines, which are added to line found by search pattern above. | |
int | getLinesRange () |
Returns the number of lines, which are searched for pattern. More... | |
CLineDescription::EMatchingType | getMatchingType () |
Returns matching type for pattern. | |
int | getNumSteps () |
Returns the number of single execution steps to be performed before logging/evaluations/assignments take place. | |
std::string | getResourceName () |
Returns name of resource where test point is located. | |
CLineDescription::EResourceType | getResourceType () |
Returns type of resource for which location is given. | |
std::string | getRuntimeLocation () |
Returns location as calculated during runtime - file name and line number. More... | |
CLineDescription::ESearchContext | getSearchContext () |
Returns search context for pattern. | |
std::string | getSearchPattern () |
Returns search pattern. More... | |
CLineDescription::EFileLocation | getSrcFileLocation () |
Returns location of source files - local host running test case or remote host running winIDEA. | |
virtual bool | isEmpty () const |
This method returns true, if the object contains no data. | |
bool | isMerged () const |
Returns true, if the CTestSpecification section containing this object is merged. More... | |
iconnect::ETristate | isSearch () |
Returns true, if search is to be performed. More... | |
virtual void | serialize (const isys::IEmitterSPtr &emitter) |
Sends contents of this class to emitter. | |
void | setLine (int lineNumber) |
Sets line number, where test point is set, or where search range starts (if pattern is defined). More... | |
void | setLineOffset (int offset) |
Sets the number of lines, which are added to line found by search pattern above. More... | |
void | setLinesRange (int numLines) |
Sets the number of lines, which are searched for pattern. More... | |
void | setMatchingType (CLineDescription::EMatchingType matchingType) |
Sets matching type for pattern. | |
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... | |
void | setResourceName (const std::string &resourceName) |
Sets name of resource where test point is located. | |
void | setResourceType (CLineDescription::EResourceType resourceType) |
Sets type of resource for which location is given. | |
void | setSearch (iconnect::ETristate isSearch) |
Sets the way to determine line number for test point. More... | |
void | setSearchContext (CLineDescription::ESearchContext searchContext) |
Sets search context for pattern. | |
void | setSearchPattern (const std::string &searchPattern) |
Sets search pattern. More... | |
void | setSrcFileLocation (CLineDescription::EFileLocation srcFileLoc) |
Sets source file location. | |
virtual std::string | toString () |
Returns object data as YAML string. | |
std::string | validate () |
Validates consistency of data in object. | |
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, ... | |
isys::CTestLocation::CTestLocation | ( | const CTestBaseSPtr & | parent | ) |
Initializes new instance.
parent | an instance of parent CTestPoint class. |
|
static |
Casts the given object to this class.
Returns NULL if input is NULL.
IllegalArgumentException | if input object is not instance of this class. |
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.
int isys::CTestLocation::getLinesRange | ( | ) |
Returns the number of lines, which are searched for pattern.
Value 0 means till the end of file.
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.
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.
|
virtual |
Returns true, if the CTestSpecification section containing this object is merged.
Reimplemented from isys::CTestBase.
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.
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.
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.
void isys::CTestLocation::setLinesRange | ( | int | numLines | ) |
Sets the number of lines, which are searched for pattern.
Value 0 means till the end of file.
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.
void isys::CTestLocation::setSearch | ( | iconnect::ETristate | isSearch | ) |
Sets the way to determine line number for test point.
isSearch | if E_FALSE or E_DEFAULT, no search is done - then line returned by getLine() is used as test point location. |
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.
searchPattern | depending on the value of matching type (see setMatchingType() ) this pattern represents either exact text to be found or regular expression. |