xtd 0.2.0
xtd::tunit::file_assert Class Referencefinal

#include <file_assert.h>

Definition

The file_assert class contains a collection of static methods that implement the most file assertions used in xtd::tUnit.

Namespace
xtd::tunit
Library
xtd.tunit
Remarks
Assertions are central to unit testing in any of the xUnit frameworks, and xtd.tunit is no exception. xtd.tunit provides a rich set of assertions as static methods of the Assert class.
If an assertion fails, the method call does not return and an error is reported. If a test contains multiple assertions, any that follow the one that failed will not be executed. For this reason, it's usually best to try for one assertion per test.
Each method may be called without a message, with a simple text message or with a message and arguments. In the last case the message is formatted using the provided text and arguments.
Examples
This example show how to used some methods :
#include <xtd/xtd.tunit>
#include <stdexcept>
using namespace xtd::tunit;
namespace unit_tests {
// The class test must be declared with test_class_ helper.
class test_class_(test) {
public:
void test_method_(test_case1) {
}
void test_method_(test_case2) {
}
void test_method_(test_case3) {
assert::does_not_throw([] {throw std::range_error("error");});
}
};
}
auto main()->int {
return console_unit_test().run();
}
// This code can produce the following output:
//
// Start 3 tests from 1 test case
// Run tests:
// SUCCEED test.test_case1 (0 ms total)
// FAILED test.test_case2 (0 ms total)
// Expected: false
// But was: true
// Stack Trace: in |---OMITTED---|/assert.cpp:14
// FAILED test.test_case3 (0 ms total)
// Expected: No Exception to be thrown
// But was: <std::range_error>
// Stack Trace: in |---OMITTED---|/assert.cpp:18
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. (0 ms total)

Methods

template<typename char_t >
static void are_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual, const std::string &message)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual, const std::string &message)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual, const std::string &message)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_istream< char_t > &expected, const std::basic_istream< char_t > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual, const std::string &message)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void are_not_equal (const std::basic_string< char_t > &expected, const std::basic_string< char_t > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two files are not equal. More...
 
template<typename char_t >
static void exists (const std::basic_string< char_t > &file)
 Asserts that file exists. More...
 
template<typename char_t >
static void exists (const std::basic_string< char_t > &file, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that file exists. More...
 
template<typename char_t >
static void exists (const std::basic_string< char_t > &file, const std::string &message)
 Asserts that file exists. More...
 
template<typename char_t >
static void exists (const std::basic_string< char_t > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that file exists. More...
 
template<typename char_t >
static void does_not_exist (const std::basic_string< char_t > &file)
 Asserts that file not exists. More...
 
template<typename char_t >
static void does_not_exist (const std::basic_string< char_t > &file, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that file not exists. More...
 
template<typename char_t >
static void does_not_exist (const std::basic_string< char_t > &file, const std::string &message)
 Asserts that file not exists. More...
 
template<typename char_t >
static void does_not_exist (const std::basic_string< char_t > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that file not exists. More...
 

Member Function Documentation

◆ are_equal() [1/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_equal ( const std::basic_istream< char_t > &  expected,
const std::basic_istream< char_t > &  actual 
)
inlinestatic

Asserts that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1); // test throws an assert_error exception.

◆ are_equal() [2/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_equal ( const std::basic_istream< char_t > &  expected,
const std::basic_istream< char_t > &  actual,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1, csf_); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_equal(s2, s1, csf_); // test throws an assert_error exception.

◆ are_equal() [3/8]

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

Asserts 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
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1, "User message..."); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_equal(s2, s1, "User message..."); // test throws an assert_error exception.

◆ are_equal() [4/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_equal ( const std::basic_istream< char_t > &  expected,
const std::basic_istream< char_t > &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts 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.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1, "User message...", csf_); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_equal(s2, s1, "User message...", csf_); // test throws an assert_error exception.

◆ are_equal() [5/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_equal ( const std::basic_string< char_t > &  expected,
const std::basic_string< char_t > &  actual 
)
inlinestatic

Asserts that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1); // test throws an assert_error exception.

◆ are_equal() [6/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_equal ( const std::basic_string< char_t > &  expected,
const std::basic_string< char_t > &  actual,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts that two files are equal.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1, csf_); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_equal(s2, s1, csf_); // test throws an assert_error exception.

◆ are_equal() [7/8]

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

Asserts 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
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1, "User message..."); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_equal(s2, s1, "User message..."); // test throws an assert_error exception.

◆ are_equal() [8/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_equal ( const std::basic_string< char_t > &  expected,
const std::basic_string< char_t > &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts 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.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_equal(s2, s1, "User message...", csf_); // test ok.
s2 << "Test2";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_equal(s2, s1, "User message...", csf_); // test throws an assert_error exception.

◆ are_not_equal() [1/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_not_equal ( const std::basic_istream< char_t > &  expected,
const std::basic_istream< char_t > &  actual 
)
inlinestatic

Asserts that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1); // test throws an assert_error exception.

◆ are_not_equal() [2/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_not_equal ( const std::basic_istream< char_t > &  expected,
const std::basic_istream< char_t > &  actual,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1, csf_); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_not_equal(s2, s1, csf_); // test throws an assert_error exception.

◆ are_not_equal() [3/8]

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

Asserts 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
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message..."); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message..."); // test throws an assert_error exception.

◆ are_not_equal() [4/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_not_equal ( const std::basic_istream< char_t > &  expected,
const std::basic_istream< char_t > &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts 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.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message...", csf_); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message...", csf_); // test throws an assert_error exception.

◆ are_not_equal() [5/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_not_equal ( const std::basic_string< char_t > &  expected,
const std::basic_string< char_t > &  actual 
)
inlinestatic

Asserts that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1); // test throws an assert_error exception.

◆ are_not_equal() [6/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_not_equal ( const std::basic_string< char_t > &  expected,
const std::basic_string< char_t > &  actual,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts that two files are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1, csf_); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_not_equal(s2, s1, csf_); // test throws an assert_error exception.

◆ are_not_equal() [7/8]

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

Asserts 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
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message..."); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message..."); // test throws an assert_error exception.

◆ are_not_equal() [8/8]

template<typename char_t >
static void xtd::tunit::file_assert::are_not_equal ( const std::basic_string< char_t > &  expected,
const std::basic_string< char_t > &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts 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.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_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);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message...", csf_); // test ok.
s2 << "Test";
s2.seekg(0, std::ios::beg);
xtd::tunit::file_assert::are_not_equal(s2, s1, "User message...", csf_); // test throws an assert_error exception.

◆ does_not_exist() [1/4]

template<typename char_t >
static void xtd::tunit::file_assert::does_not_exist ( const std::basic_string< char_t > &  file)
inlinestatic

Asserts that file not exists.

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

◆ does_not_exist() [2/4]

template<typename char_t >
static void xtd::tunit::file_assert::does_not_exist ( const std::basic_string< char_t > &  file,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts that file not exists.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::does_not_exist("Test2.txt", csf_); // test ok.
xtd::tunit::file_assert::does_not_exist("Test1.txt", csf_); // test throws an assert_error exception.

◆ does_not_exist() [3/4]

template<typename char_t >
static void xtd::tunit::file_assert::does_not_exist ( const std::basic_string< char_t > &  file,
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
xtd::tunit::assert_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::does_not_exist("Test2.txt", "User message..."); // test ok.
xtd::tunit::file_assert::does_not_exist("Test1.txt", "User message..."); // test throws an assert_error exception.

◆ does_not_exist() [4/4]

template<typename char_t >
static void xtd::tunit::file_assert::does_not_exist ( const std::basic_string< char_t > &  file,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::does_not_exist("Test2.txt" "User message...", csf_); // test ok.
xtd::tunit::file_assert::does_not_exist("Test1.txt", "User message...", csf_); // test throws an assert_error exception.

◆ exists() [1/4]

template<typename char_t >
static void xtd::tunit::file_assert::exists ( const std::basic_string< char_t > &  file)
inlinestatic

Asserts that file exists.

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

◆ exists() [2/4]

template<typename char_t >
static void xtd::tunit::file_assert::exists ( const std::basic_string< char_t > &  file,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts that file exists.

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

◆ exists() [3/4]

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

Asserts 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
xtd::tunit::assert_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::exists("Test1.txt", "User message..."); // test ok.
xtd::tunit::file_assert::exists("Test2.txt", "User message..."); // test throws an assert_error exception.

◆ exists() [4/4]

template<typename char_t >
static void xtd::tunit::file_assert::exists ( const std::basic_string< char_t > &  file,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
inlinestatic

Asserts 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.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::exists("Test1.txt" "User message...", csf_); // test ok.
xtd::tunit::file_assert::exists("Test2.txt", "User message...", csf_); // test throws an assert_error exception.

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