4 #include "../application/argumentparser.h" 5 #include "../conversion/types.h" 6 #include "../misc/traits.h" 27 operator bool()
const;
30 std::string workingCopyPathMode(
const std::string &name,
WorkingCopyMode mode)
const;
31 std::string workingCopyPath(
const std::string &name)
const;
32 int execApp(
const char *
const *args, std::string &output, std::string &errors,
bool suppressLogging =
false,
int timeout = -1)
const;
34 bool unitsSpecified()
const;
35 const std::vector<const char *> &units()
const;
37 static const char *appPath();
40 static std::string readTestfilePathFromEnv();
41 static std::string readTestfilePathFromSrcRef();
49 std::string m_testFilesPath;
50 std::string m_fallbackTestFilesPath;
51 std::string m_workingDir;
62 inline TestApplication::operator bool()
const 72 return TestApplication::m_instance;
80 return m_instance && m_instance->m_applicationPathArg.
firstValue() ? m_instance->m_applicationPathArg.
firstValue() :
"";
97 return m_unitsArg.
values();
136 inline CPP_UTILITIES_EXPORT int execApp(
const char *
const *args, std::string &output, std::string &errors)
142 const char *appPath,
const char *
const *args, std::string &output, std::string &errors,
bool suppressLogging =
false,
int timeout = -1);
170 template <
typename T> std::ostream &operator<<(std::ostream &out, const AsHexNumber<T> &value)
172 return out << std::hex <<
'0' <<
'x' << unsigned(value.value) << std::dec;
184 #ifndef TESTUTILS_ASSERT_EXEC 189 #define TESTUTILS_ASSERT_EXEC(args) CPPUNIT_ASSERT_EQUAL(0, execApp(args, stdout, stderr)) 195 template <
typename Pair, Traits::EnableIf<Traits::IsSpecializationOf<Pair, std::pair>> * =
nullptr>
196 inline std::ostream &
operator<<(std::ostream &out,
const Pair &pair)
198 return out <<
"key: " << pair.first <<
"; value: " << pair.second <<
'\n';
204 template <
typename Iteratable, Traits::EnableIf<Traits::IsIteratable<Iteratable>, Traits::Not<Traits::IsString<Iteratable>>> * =
nullptr>
205 inline std::ostream &
operator<<(std::ostream &out,
const Iteratable &iteratable)
208 std::size_t index = 0;
209 for (
const auto &item : iteratable) {
210 out << std::setw(2) << index <<
':' <<
' ' << item <<
'\n';
224 constexpr std::size_t
operator"" _st(
unsigned long long size)
226 return static_cast<std::size_t
>(size);
233 constexpr
uint64 operator"" _uint64(
unsigned long long size)
235 return static_cast<uint64>(size);
242 constexpr
int64 operator"" _int64(
unsigned long long size)
244 return static_cast<int64>(size);
249 #endif // TESTUTILS_H std::int64_t int64
signed 64-bit integer
bool unitsSpecified() const
Returns whether particular units have been specified.
The TestApplication class simplifies writing test applications that require opening test files...
std::ostream & operator<<(std::ostream &out, const AsHexNumber< T > &value)
Provides the actual formatting of the output for AsHexNumber class.
AsHexNumber(const T &value)
Constructs a new instance; use asHexNumber() for convenience instead.
std::string testFilePath(const std::string &name) const
Returns the full path of the test file with the specified name.
const char * firstValue() const
Returns the first parameter value of the first occurrence of the argument.
std::uint64_t uint64
unsigned 64-bit integer
static const char * appPath()
Returns the application path or an empty string if no application path has been set.
Contains classes and functions utilizing creating of test applications.
const std::vector< const char * > & values(std::size_t occurrence=0) const
Returns the parameter values for the specified occurrence of argument.
bool operator==(const AsHexNumber< T > &lhs, const AsHexNumber< T > &rhs)
Provides operator == required by CPPUNIT_ASSERT_EQUAL.
The Argument class is a wrapper for command line argument information.
const std::vector< const char * > & units() const
Returns the specified test units.
AsHexNumber< T > asHexNumber(const T &value)
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or sim...
WorkingCopyMode
The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::worki...
bool isPresent() const
Returns an indication whether the argument could be detected when parsing.
The HelpArgument class prints help information for an argument parser when present (–help...
static const TestApplication * instance()
Returns the current TestApplication instance.
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
The AsHexNumber class allows printing values asserted with cppunit (or similar test framework) using ...
CPP_UTILITIES_EXPORT std::string testFilePath(const std::string &name)
Convenience function which returns the full path of the test file with the specified name...
The ArgumentParser class provides a means for handling command line arguments.