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

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

#include <file_assume.h>

Inheritance diagram for tunit::file_assume:
Collaboration diagram for tunit::file_assume:

Static Public Member Functions

template<typename Char >
static void are_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const tunit::line_info &line_info)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message, const tunit::line_info &line_info)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const tunit::line_info &line_info)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message, const tunit::line_info &line_info)
 Assumes that two files are equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const tunit::line_info &line_info)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message, const tunit::line_info &line_info)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const tunit::line_info &line_info)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void are_not_equal (const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message, const tunit::line_info &line_info)
 Assumes that two files are not equal. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &file)
 Assumes that file not exists. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &file, const tunit::line_info &line_info)
 Assumes that file not exists. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &file, const std::string &message)
 Assumes that file not exists. More...
 
template<typename Char >
static void does_not_exist (const std::basic_string< Char > &file, const std::string &message, const tunit::line_info &line_info)
 Assumes that file not exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &file)
 Assumes that file exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &file, const tunit::line_info &line_info)
 Assumes that file exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &file, const std::string &message)
 Assumes that file exists. More...
 
template<typename Char >
static void exists (const std::basic_string< Char > &file, const std::string &message, const tunit::line_info &line_info)
 Assumes that file 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 file_assume class contains a collection of static methods that implement the most file assertions used in tUnit.

Examples
This example show how to used some methods :

Member Function Documentation

◆ are_equal() [1/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual 
)
inlinestatic

Assumes that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1);// test throws an abort_error exception.

◆ are_equal() [2/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
line_infoContains information about current file and current line.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, line_info_);// test throws an abort_error exception.

◆ are_equal() [3/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual,
const std::string &  message 
)
inlinestatic

Assumes that two files are equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message..."); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message...");// test throws an abort_error exception.

◆ are_equal() [4/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual,
const std::string &  message,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message...", line_info_); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message...", line_info_);// test throws an abort_error exception.

◆ are_equal() [5/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual 
)
inlinestatic

Assumes that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1);// test throws an abort_error exception.

◆ are_equal() [6/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
line_infoContains information about current file and current line.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, line_info_);// test throws an abort_error exception.

◆ are_equal() [7/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual,
const std::string &  message 
)
inlinestatic

Assumes that two files are equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message..."); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message...");// test throws an abort_error exception.

◆ are_equal() [8/8]

template<typename Char >
static void tunit::file_assume::are_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual,
const std::string &  message,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message...", line_info_); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_equal(s2, s1, "User message...", line_info_);// test throws an abort_error exception.

◆ are_not_equal() [1/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual 
)
inlinestatic

Assumes that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1);// test throws an abort_error exception.

◆ are_not_equal() [2/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
line_infoContains information about current file and current line.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, line_info_);// test throws an abort_error exception.

◆ are_not_equal() [3/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual,
const std::string &  message 
)
inlinestatic

Assumes that two files are not equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message..."); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message...");// test throws an abort_error exception.

◆ are_not_equal() [4/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_istream< Char > &  expected,
const std::basic_istream< Char > &  actual,
const std::string &  message,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are not equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message...", line_info_); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message...", line_info_);// test throws an abort_error exception.

◆ are_not_equal() [5/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual 
)
inlinestatic

Assumes that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1);// test throws an abort_error exception.

◆ are_not_equal() [6/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
line_infoContains information about current file and current line.
Exceptions
tunit::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, line_info_);// test throws an abort_error exception.

◆ are_not_equal() [7/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual,
const std::string &  message 
)
inlinestatic

Assumes that two files are not equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message..."); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message...");// test throws an abort_error exception.

◆ are_not_equal() [8/8]

template<typename Char >
static void tunit::file_assume::are_not_equal ( const std::basic_string< Char > &  expected,
const std::basic_string< Char > &  actual,
const std::string &  message,
const tunit::line_info line_info 
)
inlinestatic

Assumes that two files are not equal.

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::abort_errorIf bad assertion.
Examples
std::stringstream s1;
s1 << "Test";
s1.seekg(0, std::ios::beg);
std::stringstream s2;
s2 << "Test2";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message...", line_info_); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
tunit::file_assume::are_not_equal(s2, s1, "User message...", line_info_);// test throws an abort_error exception.

◆ does_not_exist() [1/4]

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

Assumes that file not exists.

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

◆ does_not_exist() [2/4]

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

Assumes that file not exists.

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

◆ does_not_exist() [3/4]

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

Assumes 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::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assume::does_not_exist("Test2.txt", "User message..."); // test ok.
tunit::file_assume::does_not_exist("Test1.txt", "User message...");// test throws an abort_error exception.

◆ does_not_exist() [4/4]

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

Assumes 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::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assume::does_not_exist("Test2.txt" "User message...", line_info_); // test ok.
tunit::file_assume::does_not_exist("Test1.txt", "User message...", line_info_);// test throws an abort_error exception.

◆ exists() [1/4]

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

Assumes that file exists.

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

◆ exists() [2/4]

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

Assumes that file exists.

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

◆ exists() [3/4]

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

Assumes that file 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::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assume::exists("Test1.txt", "User message..."); // test ok.
tunit::file_assume::exists("Test2.txt", "User message...");// test throws an abort_error exception.

◆ exists() [4/4]

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

Assumes that file 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::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
tunit::file_assume::exists("Test1.txt" "User message...", line_info_); // test ok.
tunit::file_assume::exists("Test2.txt", "User message...", line_info_);// test throws an abort_error exception.

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