xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Static Public Member Functions | List of all members
xtd::tunit::directory_assume Class Referencefinal

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

#include <directory_assume.h>

Inheritance diagram for xtd::tunit::directory_assume:
Inheritance graph
[legend]
Collaboration diagram for xtd::tunit::directory_assume:
Collaboration graph
[legend]

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 xtd::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 xtd::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 xtd::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 xtd::tunit::line_info &line_info)
 Asserts that directory exists. More...
 

Detailed Description

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

Library
xtd.tunit
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");});
}
};
}
int main() {
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 /Users/yves/Projects/xtd/examples/xtd.tunit.examples/assert/src/assert.cpp:14
// FAILED test.test_case3 (0 ms total)
// Expected: No Exception to be thrown
// But was: <std::range_error>
// Stack Trace: in /Users/yves/Projects/xtd/examples/xtd.tunit.examples/assert/src/assert.cpp:18
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. (0 ms total)

Member Function Documentation

◆ does_not_exist() [1/4]

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

Asserts that file not exists.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::abort_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 abort_error exception.

◆ does_not_exist() [2/4]

template<typename Char >
static void xtd::tunit::directory_assume::does_not_exist ( const std::basic_string< Char > &  directory,
const xtd::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
xtd::tunit::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::does_not_exist("Test1.txt", line_info_);// test throws an abort_error exception.

◆ does_not_exist() [3/4]

template<typename Char >
static void xtd::tunit::directory_assume::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
xtd::tunit::abort_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 abort_error exception.

◆ does_not_exist() [4/4]

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

◆ exists() [1/4]

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

Asserts that directory exists.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::abort_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 abort_error exception.

◆ exists() [2/4]

template<typename Char >
static void xtd::tunit::directory_assume::exists ( const std::basic_string< Char > &  directory,
const xtd::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
xtd::tunit::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::exists("Test1.txt", line_info_); // test ok.
xtd::tunit::file_assert::exists("Test2.txt", line_info_);// test throws an abort_error exception.

◆ exists() [3/4]

template<typename Char >
static void xtd::tunit::directory_assume::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
xtd::tunit::abort_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 abort_error exception.

◆ exists() [4/4]

template<typename Char >
static void xtd::tunit::directory_assume::exists ( const std::basic_string< Char > &  directory,
const std::string &  message,
const xtd::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
xtd::tunit::abort_errorIf bad assertion.
Examples
std::ifstream f1("Test1.txt");
f1.close();
xtd::tunit::file_assert::exists("Test1.txt" "User message...", line_info_); // test ok.
xtd::tunit::file_assert::exists("Test2.txt", "User message...", line_info_);// test throws an abort_error exception.

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