tunit - Reference Guide  1.0.0
Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android.
tunit::directory_assert Class Referencefinal

The directory_assert class contains a collection of static methods that implement the most directory assertions used in tUnit. More...

#include <directory_assert.h>

Inheritance diagram for tunit::directory_assert:
Collaboration diagram for tunit::directory_assert:

Static Public Member Functions

template<typename Char >
static void does_not_exist (const std::basic_string< Char > &directory)
 Asserts that file not exists. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &directory, const tunit::line_info &line_info)
 Asserts that file not exists. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &directory, const std::string &message)
 Asserts that file not exists. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &directory, const std::string &message, const tunit::line_info &line_info)
 Asserts that file not exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &directory)
 Asserts that directory exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &directory, const tunit::line_info &line_info)
 Asserts that directory exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &directory, const std::string &message)
 Asserts that directory exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &directory, const std::string &message, const tunit::line_info &line_info)
 Asserts that directory exists. More...
 

Static Private Member Functions

static void abort ()
 Abort current test. More...
 
static void abort (const tunit::line_info &line_info)
 Abort current test. More...
 
static void abort (const std::string &message)
 Abort current test. More...
 
static void abort (const std::string &message, const tunit::line_info &line_info)
 Abort current test. More...
 
static void error ()
 
static void error (const std::string &actual, const std::string &expected, const std::string &message, const tunit::line_info &line_info)
 
static void fail ()
 Throws an tunit::assertion_error exception. More...
 
static void fail (const tunit::line_info &line_info)
 Throws an tunit::assertion_error exception. More...
 
static void fail (const std::string &message)
 Throws an tunit::assertion_error exception. More...
 
static void fail (const std::string &message, const tunit::line_info &line_info)
 Throws an tunit::assertion_error exception. More...
 
static void fail (const std::string &actual, const std::string &expected, const std::string &message, const tunit::line_info &line_info)
 
static void ignore ()
 Ignore current test. More...
 
static void ignore (const tunit::line_info &line_info)
 Ignore current test. More...
 
static void ignore (const std::string &message)
 Ignore current test. More...
 
static void ignore (const std::string &message, const tunit::line_info &line_info)
 Ignore current test. More...
 
template<typename TCollection >
static std::string join_items (const TCollection &collection)
 
static std::string join_items (const std::string &str)
 
static void succeed ()
 Generates a success with a generic message. More...
 
static void succeed (const tunit::line_info &line_info)
 Generates a success with a generic message. More...
 
static void succeed (const std::string &message)
 Generates a success with a generic message. More...
 
static void succeed (const std::string &message, const tunit::line_info &line_info)
 Generates a success with a generic message. More...
 
template<typename TValue >
static std::string to_string (const TValue &value)
 
template<typename TValue >
static std::string to_string (const TValue *value)
 

Detailed Description

The directory_assert class contains a collection of static methods that implement the most directory assertions used in tUnit.

Examples
This example show how to used some methods :

Member Function Documentation

◆ does_not_exist() [1/4]

template<typename Char >
static void tunit::directory_assert::does_not_exist ( const std::basic_string< Char > &  directory)
inlinestatic

Asserts that file not exists.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::does_not_exist("Test2.txt"); // test ok.
tunit::file_assert::does_not_exist("Test1.txt"); // test throws an assertion_error exception.

◆ does_not_exist() [2/4]

template<typename Char >
static void tunit::directory_assert::does_not_exist ( const std::basic_string< Char > &  directory,
const tunit::line_info line_info 
)
inlinestatic

Asserts that file not exists.

Parameters
expectedthe expected value.
actualthe actual value.
line_infoContains information about current file and current line.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::does_not_exist("Test1.txt", line_info_); // test throws an assertion_error exception.

◆ does_not_exist() [3/4]

template<typename Char >
static void tunit::directory_assert::does_not_exist ( const std::basic_string< Char > &  directory,
const std::string &  message 
)
inlinestatic

Asserts that file not exists.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::does_not_exist("Test2.txt", "User message..."); // test ok.
tunit::file_assert::does_not_exist("Test1.txt", "User message..."); // test throws an assertion_error exception.

◆ does_not_exist() [4/4]

template<typename Char >
static void tunit::directory_assert::does_not_exist ( const std::basic_string< Char > &  directory,
const std::string &  message,
const tunit::line_info line_info 
)
inlinestatic

Asserts that file not exists.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
line_infoContains information about current file and current line.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::does_not_exist("Test2.txt" "User message...", line_info_); // test ok.
tunit::file_assert::does_not_exist("Test1.txt", "User message...", line_info_); // test throws an assertion_error exception.

◆ exists() [1/4]

template<typename Char >
static void tunit::directory_assert::exists ( const std::basic_string< Char > &  directory)
inlinestatic

Asserts that directory exists.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::exists("Test1.txt"); // test ok.
tunit::file_assert::exists("Test2.txt"); // test throws an assertion_error exception.

◆ exists() [2/4]

template<typename Char >
static void tunit::directory_assert::exists ( const std::basic_string< Char > &  directory,
const tunit::line_info line_info 
)
inlinestatic

Asserts that directory exists.

Parameters
expectedthe expected value.
actualthe actual value.
line_infoContains information about current file and current line.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::exists("Test1.txt", line_info_); // test ok.
tunit::file_assert::exists("Test2.txt", line_info_); // test throws an assertion_error exception.

◆ exists() [3/4]

template<typename Char >
static void tunit::directory_assert::exists ( const std::basic_string< Char > &  directory,
const std::string &  message 
)
inlinestatic

Asserts that directory exists.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::exists("Test1.txt", "User message..."); // test ok.
tunit::file_assert::exists("Test2.txt", "User message..."); // test throws an assertion_error exception.

◆ exists() [4/4]

template<typename Char >
static void tunit::directory_assert::exists ( const std::basic_string< Char > &  directory,
const std::string &  message,
const tunit::line_info line_info 
)
inlinestatic

Asserts that directory exists.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
line_infoContains information about current file and current line.
Exceptions
tunit::assertion_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assert::exists("Test1.txt" "User message...", line_info_); // test ok.
tunit::file_assert::exists("Test2.txt", "User message...", line_info_); // test throws an assertion_error exception.

The documentation for this class was generated from the following file: