C++ Utilities
4.16.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 (int argc, char **argv) | |
Constructs a TestApplication instance. More... | |
~TestApplication () | |
Destroys the TestApplication. More... | |
operator bool () const | |
Returns whether the TestApplication instance is valid. More... | |
std::string | testFilePath (const std::string &name) const |
Returns the full path of the test file with the specified name. More... | |
std::string | workingCopyPathMode (const std::string &name, WorkingCopyMode mode) const |
Returns the full path to a working copy of the test file with the specified name. More... | |
std::string | workingCopyPath (const std::string &name) const |
Creates a working copy of the test file with the specified name and returns the full path of the created file. 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... | |
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 23 of file testutils.h.
TestUtilities::TestApplication::TestApplication | ( | int | argc, |
char ** | argv | ||
) |
Constructs a TestApplication instance.
Throws | std::runtime_error if an instance has already been created. |
Definition at line 112 of file testutils.cpp.
TestUtilities::TestApplication::~TestApplication | ( | ) |
Destroys the TestApplication.
Definition at line 218 of file testutils.cpp.
|
inlinestatic |
Returns the application path or an empty string if no application path has been set.
Definition at line 79 of file testutils.h.
|
inlinestatic |
Returns the current TestApplication instance.
Definition at line 71 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 63 of file testutils.h.
string TestUtilities::TestApplication::testFilePath | ( | const std::string & | name | ) | const |
Returns the full path of the test file with the specified name.
The specified name might be a relative path in the testfiles directory.
The following directories are searched for the specified testfile:
TEST_FILE_PATH
.Definition at line 235 of file testutils.cpp.
|
inline |
Returns the specified test units.
Definition at line 96 of file testutils.h.
|
inline |
Returns whether particular units have been specified.
Definition at line 87 of file testutils.h.
string TestUtilities::TestApplication::workingCopyPath | ( | const std::string & | name | ) | const |
Creates a working copy of the test file with the specified name and returns the full path of the created file.
The test file is located using testFilePath().
Definition at line 359 of file testutils.cpp.
string TestUtilities::TestApplication::workingCopyPathMode | ( | const std::string & | name, |
WorkingCopyMode | mode | ||
) | const |
Returns the full path to a working copy of the test file with the specified name.
The specified mode controls whether a working copy is actually created or whether just the path is returned. The test file is located using testFilePath().
Definition at line 269 of file testutils.cpp.