A List of
Test representing a path to access a
Test.
More...
#include <TestPath.h>
List of all members.
Public Member Functions
Constructs an invalid path.
Constructs a valid path.
Constructs a path using a slice of another path.
TestPath (
Test *searchRoot, const std::string &pathAsString)
Resolves a path from a string returned by
toString().
Copy constructor.
Tests if the path contains at least one test.
Adds a test to the path.
Adds all the tests of the specified path.
Inserts a test at the specified index.
Inserts all the tests at the specified path at a given index.
Removes all the test from the path.
Removes the test at the specified index of the path.
Removes the last test.
Returns the number of tests in the path.
Returns the test of the specified index.
Get the last test of the path.
Returns the path as a string.
Assignment operator.
Protected Types
A list of test names.
Protected Member Functions
Checks that the specified test index is within valid range.
Splits a path string into its test name components.
Finds the actual root of a path string and get the path string name components.
Protected Attributes
Detailed Description
A List of
Test representing a path to access a
Test.
The path can be converted to a string and resolved from a string with toString() and TestPath( Test *root, const std::string &pathAsString ).
Pointed tests are not owned by the class.
- See also:
- Test::resolvedTestPath()
Member Typedef Documentation
Constructor & Destructor Documentation
CPPUNIT_NS_BEGIN TestPath::TestPath
(
)
Constructs an invalid path.
The path is invalid until a test is added with add().
TestPath::TestPath
(
Test *
root
)
Constructs a valid path.
- Parameters:
-
TestPath::TestPath
(
const
TestPath &
otherPath,
int
indexFirst,
int
count = -1
)
Constructs a path using a slice of another path.
- Parameters:
-
otherPath Path the test are copied from.
indexFirst Zero based index of the first test to copy. Adjusted to be in valid range. count is adjusted with indexFirst.
count Number of tests to copy. If < 0 then all test starting from index indexFirst are copied.
TestPath::TestPath
(
Test *
searchRoot,
const std::string &
pathAsString
)
Resolves a path from a string returned by toString().
If pathAsString is an absolute path (begins with '/'), then the first test name of the path must be the name of searchRoot. Otherwise, pathAsString is a relative path, and the first test found using Test::findTest() matching the first test name is used as root. An empty string resolve to a path containing searchRoot.
The resolved path is always valid.
- Parameters:
-
searchRoot Test used to resolve the path.
pathAsString String that contains the path as a string created by
toString().
- Exceptions:
-
std::invalid_argument if one of the test names can not be resolved.
- See also:
- toString().
TestPath::TestPath
(
const
TestPath &
other
)
Copy constructor.
- Parameters:
-
other Object to copy.
Member Function Documentation
void TestPath::add
(
const
TestPath &
path
)
[virtual]
Adds all the tests of the specified path.
- Parameters:
-
path Path that contains the test to add.
void TestPath::add
(
Test *
test
)
[virtual]
Adds a test to the path.
- Parameters:
-
test Pointer on the test to add. Must not be NULL
.
void TestPath::checkIndexValid
(
int
index
)
const [protected]
Checks that the specified test index is within valid range.
- Parameters:
-
index Zero based index to check.
- Exceptions:
-
Test * TestPath::findActualRoot
(
Test *
searchRoot,
const std::string &
pathAsString,
)
[protected]
Finds the actual root of a path string and get the path string name components.
- Parameters:
-
searchRoot Test used as root if the path string is absolute, or to search the root test if the path string is relative.
pathAsString Path string. May be absolute or relative.
testNames Test name components are added to that container.
- Returns:
- Pointer on the resolved root test. Never
NULL
.
- Exceptions:
-
std::invalid_argument if either the root name can not be resolved or if pathAsString contains no name components.
Test * TestPath::getChildTest
(
)
const
[virtual]
Get the last test of the path.
- Returns:
- Pointer on the last test (test at the bottom of the hierarchy). Never
NULL
.
- Exceptions:
-
std::out_of_range if the path is not valid (
isValid() returns
false
).
Test * TestPath::getTestAt
(
int
index
)
const
[virtual]
Returns the test of the specified index.
- Parameters:
-
index Zero based index of the test to return.
- Returns:
- Pointer on the test at index index. Never
NULL
.
- Exceptions:
-
int TestPath::getTestCount
(
)
const [virtual]
Returns the number of tests in the path.
- Returns:
- Number of tests in the path.
void TestPath::insert
(
const
TestPath &
path,
int
index
)
[virtual]
Inserts all the tests at the specified path at a given index.
- Parameters:
-
path Path that contains the test to insert.
index Zero based index indicating where the tests are inserted.
- Exceptions:
-
std::out_of_range is
index < 0 or
index >
getTestCount(), and
path is valid.
void TestPath::insert
(
Test *
test,
int
index
)
[virtual]
Inserts a test at the specified index.
- Parameters:
-
test Pointer on the test to insert. Must not be NULL
.
index Zero based index indicating where the test is inserted.
- Exceptions:
-
bool TestPath::isValid
(
)
const [virtual]
Tests if the path contains at least one test.
- Returns:
true
if the path contains at least one test, otherwise returns false
.
Assignment operator.
- Parameters:
-
other Object to copy.
- Returns:
- This object.
void TestPath::removeTest
(
int
index
)
[virtual]
Removes the test at the specified index of the path.
- Parameters:
-
index Zero based index of the test to remove.
- Exceptions:
-
void TestPath::removeTests
(
)
[virtual]
Removes all the test from the path.
The path becomes invalid after this call.
bool TestPath::splitPathString
(
const std::string &
pathAsString,
)
[protected]
Splits a path string into its test name components.
- Parameters:
-
testNames Test name components are added to that container.
- Returns:
true
if the path is relative (does not begin with '/'), false
if it is absolute (begin with '/').
std::string TestPath::toString
(
)
const [virtual]
Returns the path as a string.
For example, if a path is composed of three tests named "All Tests", "Math" and "Math::testAdd", toString() will return:
"All Tests/Math/Math::testAdd".
- Returns:
- A string composed of the test names separated with a '/'. It is a relative path.
void TestPath::up
(
)
[virtual]
Removes the last test.
- Exceptions:
-
std::out_of_range is the path is invalid.
- See also:
- isValid().
Member Data Documentation
The documentation for this class was generated from the following files: