C++ Utilities
5.3.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
The TestApplication class simplifies writing test applications that require opening test files. More...
#include <testutils.h>
Public Member Functions | |
TestApplication () | |
Constructs a TestApplication instance without further arguments. More... | |
TestApplication (int argc, const char *const *argv) | |
Constructs a TestApplication instance for the specified arguments. More... | |
~TestApplication () | |
Destroys the TestApplication. More... | |
operator bool () const | |
Returns whether the TestApplication instance is valid. More... | |
std::string | testFilePath (const std::string &relativeTestFilePath) const |
Returns the full path of the test file with the specified relativeTestFilePath. More... | |
std::string | workingCopyPath (const std::string &relativeTestFilePath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) const |
Returns the full path to a working copy of the test file with the specified relativeTestFilePath. More... | |
std::string | workingCopyPathAs (const std::string &relativeTestFilePath, const std::string &relativeWorkingCopyPath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) const |
Returns the full path to a working copy of the test file with the specified relativeTestFilePath. More... | |
const std::vector< std::string > & | testFilePaths () const |
Returns the list of directories to look for test files. More... | |
const std::string & | workingDirectory () const |
Returns the directory which is supposed to used for storing files created by tests. More... | |
const char * | applicationPath () |
Returns the application path or an empty string if no application path has been set. More... | |
bool | unitsSpecified () const |
Returns whether particular units have been specified. More... | |
const std::vector< const char * > & | units () const |
Returns the specified test units. More... | |
bool | onlyListUnits () const |
Returns whether the test application should only list available units and not actually run any tests. More... | |
Static Public Member Functions | |
static const TestApplication * | instance () |
Returns the current TestApplication instance. More... | |
static const char * | appPath () |
Returns the application path or an empty string if no application path has been set. More... | |
The TestApplication class simplifies writing test applications that require opening test files.
Definition at line 21 of file testutils.h.
|
explicit |
Constructs a TestApplication instance without further arguments.
Throws | std::runtime_error if an instance has already been created. |
Definition at line 108 of file testutils.cpp.
|
explicit |
Constructs a TestApplication instance for the specified arguments.
Throws | std::runtime_error if an instance has already been created. |
Definition at line 117 of file testutils.cpp.
CppUtilities::TestApplication::~TestApplication | ( | ) |
Destroys the TestApplication.
Definition at line 213 of file testutils.cpp.
|
inline |
Returns the application path or an empty string if no application path has been set.
Definition at line 113 of file testutils.h.
|
inlinestatic |
Returns the application path or an empty string if no application path has been set.
Definition at line 89 of file testutils.h.
|
inlinestatic |
Returns the current TestApplication instance.
Definition at line 81 of file testutils.h.
|
inline |
Returns whether the test application should only list available units and not actually run any tests.
Definition at line 138 of file testutils.h.
|
inline |
Returns whether the TestApplication instance is valid.
An instance is considered invalid if an error occured when parsing the command line arguments.
Definition at line 73 of file testutils.h.
string CppUtilities::TestApplication::testFilePath | ( | const std::string & | relativeTestFilePath | ) | const |
Returns the full path of the test file with the specified relativeTestFilePath.
The specified relativeTestFilePath is considered to be a path to a test file which is relative to at least one of the considered test file search directories.
The following directories are searched for test files in the given order:
TEST_FILE_PATH
.Definition at line 230 of file testutils.cpp.
|
inline |
Returns the list of directories to look for test files.
Definition at line 97 of file testutils.h.
|
inline |
Returns the specified test units.
Definition at line 130 of file testutils.h.
|
inline |
Returns whether particular units have been specified.
Definition at line 121 of file testutils.h.
string CppUtilities::TestApplication::workingCopyPath | ( | const std::string & | relativeTestFilePath, |
WorkingCopyMode | mode = WorkingCopyMode::CreateCopy |
||
) | const |
Returns the full path to a working copy of the test file with the specified relativeTestFilePath.
The specified mode controls whether a working copy is actually created or whether just the path is returned.
Definition at line 249 of file testutils.cpp.
string CppUtilities::TestApplication::workingCopyPathAs | ( | const std::string & | relativeTestFilePath, |
const std::string & | relativeWorkingCopyPath, | ||
WorkingCopyMode | mode = WorkingCopyMode::CreateCopy |
||
) | const |
Returns the full path to a working copy of the test file with the specified relativeTestFilePath.
The specified mode controls whether a working copy is actually created or whether just the path is returned. If only the path is returned, the relativeTestFilePath is ignored.
In contrast to workingCopyPath(), this method allows to adjust the relative path of the working copy within the working copy directory via relativeWorkingCopyPath.
Definition at line 268 of file testutils.cpp.
|
inline |
Returns the directory which is supposed to used for storing files created by tests.
Definition at line 105 of file testutils.h.