50 template<
typename char_t>
71 template<
typename char_t>
73 std::basic_istream<char_t> if_expected(expected.rdbuf());
74 std::basic_istream<char_t> if_actual(actual.rdbuf());
76 if_expected.seekg(0, std::ios::end);
77 if_actual.seekg(0, std::ios::end);
78 size_t size_expected =
static_cast<size_t>(if_expected.tellg());
79 size_t size_actual =
static_cast<size_t>(if_actual.tellg());
80 if (size_expected != size_actual) {
81 fail(
"istream length " +
to_string(size_expected),
to_string(size_actual), message, stack_frame);
85 if_expected.seekg(0, std::ios::beg);
86 if_actual.seekg(0, std::ios::beg);
87 for (
size_t offset = 0; offset < size_actual; ++offset) {
88 char_t value_expected =
static_cast<char_t
>(if_expected.get());
89 char_t value_actual =
static_cast<char_t
>(if_actual.get());
90 if (value_expected != value_actual) {
91 fail(
"istream at offset " +
to_string(offset) +
" value " +
to_string(value_expected),
to_string(value_actual), message, stack_frame);
95 assert::succeed(message, stack_frame);
115 template<
typename char_t>
136 template<
typename char_t>
140 template<
typename char_t>
142 template<
typename char_t>
144 template<
typename char_t>
146 template<
typename char_t>
148 template<
typename char_t>
150 template<
typename char_t>
172 template<
typename char_t>
193 template<
typename char_t>
195 std::basic_istream<char_t> if_expected(expected.rdbuf());
196 std::basic_istream<char_t> if_actual(actual.rdbuf());
198 if_expected.seekg(0, std::ios::end);
199 if_actual.seekg(0, std::ios::end);
200 size_t size_expected =
static_cast<size_t>(if_expected.tellg());
201 size_t size_actual =
static_cast<size_t>(if_actual.tellg());
202 if (size_expected != size_actual) {
203 assert::succeed(message, stack_frame);
207 if_expected.seekg(0, std::ios::beg);
208 if_actual.seekg(0, std::ios::beg);
209 for (
size_t offset = 0; offset < size_actual; ++offset) {
210 char_t value_expected =
static_cast<char_t
>(if_expected.get());
211 char_t value_actual =
static_cast<char_t
>(if_actual.get());
212 if (value_expected != value_actual) {
213 assert::succeed(message, stack_frame);
217 fail(
"not equal <" +
typeof_(expected).full_name() +
">",
"<" +
typeof_(expected).full_name() +
">", message, stack_frame);
237 template<
typename char_t>
258 template<
typename char_t>
262 template<
typename char_t>
264 template<
typename char_t>
266 template<
typename char_t>
268 template<
typename char_t>
270 template<
typename char_t>
272 template<
typename char_t>
288 template<
typename char_t>
303 template<
typename char_t>
305 auto is = std::basic_ifstream<char_t>(file);
306 if (
is.good() ==
true) {
308 fail(
"not file exists",
to_string(file), message, stack_frame);
310 assert::succeed(message, stack_frame);
314 template<
typename char_t>
316 template<
typename char_t>
332 template<
typename char_t>
347 template<
typename char_t>
349 auto is = std::basic_ifstream<char_t>(file);
350 if (
is.good() ==
false)
351 fail(
"file exists",
to_string(file), message, stack_frame);
354 assert::succeed(message, stack_frame);
359 template<
typename char_t>
361 template<
typename char_t>
Represents text as a sequence of character units.
Definition basic_string.h:79
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.h:124
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:47
static stack_frame current(const xtd::source_location &value=xtd::source_location::current()) noexcept
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
The base class for assert.
Definition base_assert.h:29
The file_assert class contains a collection of static methods that implement the most file assertions...
Definition file_assert.h:23
static void does_not_exist(const xtd::basic_string< char_t > &file, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that file not exists.
Definition file_assert.h:289
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=xtd::diagnostics::stack_frame::current())
Asserts that two files are not equal.
Definition file_assert.h:194
static void are_equal(const xtd::basic_string< char_t > &expected, const xtd::basic_string< char_t > &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that two files are equal.
Definition file_assert.h:116
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=xtd::diagnostics::stack_frame::current())
Asserts that two files are not equal.
Definition file_assert.h:173
static void does_not_exist(const xtd::basic_string< char_t > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that file not exists.
Definition file_assert.h:304
static void are_not_equal(const xtd::basic_string< char_t > &expected, const xtd::basic_string< char_t > &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that two files are not equal.
Definition file_assert.h:238
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=xtd::diagnostics::stack_frame::current())
Asserts that two files are equal.
Definition file_assert.h:72
static void exists(const xtd::basic_string< char_t > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that file exists.
Definition file_assert.h:348
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=xtd::diagnostics::stack_frame::current())
Asserts that two files are equal.
Definition file_assert.h:51
static void exists(const xtd::basic_string< char_t > &file, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that file exists.
Definition file_assert.h:333
static void are_equal(const xtd::basic_string< char_t > &expected, const xtd::basic_string< char_t > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that two files are equal.
Definition file_assert.h:137
static void are_not_equal(const xtd::basic_string< char_t > &expected, const xtd::basic_string< char_t > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that two files are not equal.
Definition file_assert.h:259
Contains xtd::tunit::directory_assert class.
#define tunit_export_
Define shared library export.
Definition tunit_export.h:13
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.h:45
bool is(std::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.h:365
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition to_string.h:41
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10