xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
file_valid.h
Go to the documentation of this file.
1 #pragma once
5 #include "valid.h"
6 #include "file_assert.h"
7 
9 namespace xtd {
11  namespace tunit {
21  class file_valid final : private base_assert {
22  public:
24  file_valid() = delete;
26 
43  template<typename Char>
44  static void are_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
45 
63  template<typename Char>
64  static void are_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
65 
83  template<typename Char>
84  static void are_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual, const std::string& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
85 
104  template<typename Char>
105  static void are_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {
106  try {
107  file_assert::are_equal(expected, actual, message, stack_frame);
108  } catch(...) {
109  base_assert::error();
110  }
111  }
112 
129  template<typename Char>
130  static void are_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
131 
149  template<typename Char>
150  static void are_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
151 
169  template<typename Char>
170  static void are_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual, const std::string& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
171 
190  template<typename Char>
191  static void are_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
192 
194  template<typename Char>
195  static void are_equal(const std::basic_string<Char>& expected, const Char* actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
196  template<typename Char>
197  static void are_equal(const std::basic_string<Char>& expected, const Char* actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
198  template<typename Char>
199  static void are_equal(const std::basic_string<Char>& expected, const Char* actual, const std::string& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
200  template<typename Char>
201  static void are_equal(const std::basic_string<Char>& expected, const Char* actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
202  template<typename Char>
203  static void are_equal(const Char* expected, const std::basic_string<Char>& actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
204  template<typename Char>
205  static void are_equal(const Char* expected, const std::basic_string<Char>& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
206  template<typename Char>
207  static void are_equal(const Char* expected, const std::basic_string<Char>& actual, const std::string& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
208  template<typename Char>
209  static void are_equal(const Char* expected, const std::basic_string<Char>& actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
210  template<typename Char>
211  static void are_equal(const Char* expected, const Char* actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
212  template<typename Char>
213  static void are_equal(const Char* expected, const Char* actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
214  template<typename Char>
215  static void are_equal(const Char* expected, const Char* actual, const std::string& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
216  template<typename Char>
217  static void are_equal(const Char* expected, const Char* actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
219 
236  template<typename Char>
237  static void are_not_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
238 
256  template<typename Char>
257  static void are_not_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(expected, actual, "", stack_frame);}
258 
276  template<typename Char>
277  static void are_not_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual, const std::string& message) {are_not_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
278 
297  template<typename Char>
298  static void are_not_equal(const std::basic_istream<Char>& expected, const std::basic_istream<Char>& actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {
299  try {
300  file_assert::are_not_equal(expected, actual, message, stack_frame);
301  } catch(...) {
302  base_assert::error();
303  }
304  }
305 
322  template<typename Char>
323  static void are_not_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
324 
342  template<typename Char>
343  static void are_not_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(expected, actual, "", stack_frame);}
344 
362  template<typename Char>
363  static void are_not_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual, const std::string& message) {are_not_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
364 
383  template<typename Char>
384  static void are_not_equal(const std::basic_string<Char>& expected, const std::basic_string<Char>& actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
385 
387  template<typename Char>
388  static void are_not_equal(const std::basic_string<Char>& expected, const Char* actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
389  template<typename Char>
390  static void are_not_equal(const std::basic_string<Char>& expected, const Char* actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(expected, actual, "", stack_frame);}
391  template<typename Char>
392  static void are_not_equal(const std::basic_string<Char>& expected, const Char* actual, const std::string& message) {are_not_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
393  template<typename Char>
394  static void are_not_equal(const std::basic_string<Char>& expected, const Char* actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
395  template<typename Char>
396  static void are_not_equal(const Char* expected, const std::basic_string<Char>& actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
397  template<typename Char>
398  static void are_not_equal(const Char* expected, const std::basic_string<Char>& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(expected, actual, "", stack_frame);}
399  template<typename Char>
400  static void are_not_equal(const Char* expected, const std::basic_string<Char>& actual, const std::string& message) {are_not_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
401  template<typename Char>
402  static void are_not_equal(const Char* expected, const std::basic_string<Char>& actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
403  template<typename Char>
404  static void are_not_equal(const Char* expected, const Char* actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
405  template<typename Char>
406  static void are_not_equal(const Char* expected, const Char* actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(expected, actual, "", stack_frame);}
407  template<typename Char>
408  static void are_not_equal(const Char* expected, const Char* actual, const std::string& message) {are_not_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
409  template<typename Char>
410  static void are_not_equal(const Char* expected, const Char* actual, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(std::basic_ifstream<Char>(expected), std::basic_ifstream<Char>(actual), message, stack_frame);}
412 
423  template<typename Char>
424  static void exists(const std::basic_string<Char>& file) {exists(file, "", xtd::diagnostics::stack_frame::empty());}
425 
437  template<typename Char>
438  static void exists(const std::basic_string<Char>& file, const xtd::diagnostics::stack_frame& stack_frame) {exists(file, "", stack_frame);}
439 
451  template<typename Char>
452  static void exists(const std::basic_string<Char>& file, const std::string& message) {exists(file, message, xtd::diagnostics::stack_frame::empty());}
453 
466  template<typename Char>
467  static void exists(const std::basic_string<Char>& file, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {
468  try {
469  file_assert::exists(file, message, stack_frame);
470  } catch(...) {
471  base_assert::error();
472  }
473  }
474 
476  template<typename Char>
477  static void exists(const Char* file) {exists(file, "", xtd::diagnostics::stack_frame::empty());}
478  template<typename Char>
479  static void exists(const Char* file, const xtd::diagnostics::stack_frame& stack_frame) {exists(file, "", stack_frame);}
480  template<typename Char>
481  static void exists(const Char* file, const std::string& message) {exists(file, message, xtd::diagnostics::stack_frame::empty());}
482  template<typename Char>
483  static void exists(const Char* file, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {exists(std::basic_string<Char>(file), message, stack_frame);}
485 
496  template<typename Char>
497  static void does_not_exist(const std::basic_string<Char>& file) {does_not_exist(file, "", xtd::diagnostics::stack_frame::empty());}
498 
510  template<typename Char>
511  static void does_not_exist(const std::basic_string<Char>& file, const xtd::diagnostics::stack_frame& stack_frame) {does_not_exist(file, "", stack_frame);}
512 
524  template<typename Char>
525  static void does_not_exist(const std::basic_string<Char>& file, const std::string& message) {does_not_exist(file, message, xtd::diagnostics::stack_frame::empty());}
526 
539  template<typename Char>
540  static void does_not_exist(const std::basic_string<Char>& file, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {
541  try {
542  file_assert::does_not_exist(file, message, stack_frame);
543  } catch(...) {
544  base_assert::error();
545  }
546  }
547 
549  template<typename Char>
550  static void does_not_exist(const Char* file) {does_not_exist(file, "", xtd::diagnostics::stack_frame::empty());}
551  template<typename Char>
552  static void does_not_exist(const Char* file, const xtd::diagnostics::stack_frame& stack_frame) {does_not_exist(file, "", stack_frame);}
553  template<typename Char>
554  static void does_not_exist(const Char* file, const std::string& message) {does_not_exist(file, message, xtd::diagnostics::stack_frame::empty());}
555  template<typename Char>
556  static void does_not_exist(const Char* file, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {does_not_exist(std::basic_string<Char>(file), message, stack_frame);}
558  };
559  }
560 }
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:29
static stack_frame empty() noexcept
Return an empty stack frame.
The base class for assert.
Definition: base_assert.h:25
static void does_not_exist(const std::basic_string< Char > &file)
Asserts that file not exists.
Definition: file_assert.h:552
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
Asserts that two files are equal.
Definition: file_assert.h:44
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
Asserts that two files are not equal.
Definition: file_assert.h:263
static void exists(const std::basic_string< Char > &file)
Asserts that file exists.
Definition: file_assert.h:476
The file_valid class contains a collection of static methods that implement the most file assertions ...
Definition: file_valid.h:21
static void does_not_exist(const std::basic_string< Char > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Validate that file not exists.
Definition: file_valid.h:540
static void exists(const std::basic_string< Char > &file, const std::string &message)
Validate that file exists.
Definition: file_valid.h:452
static void are_not_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are not equal.
Definition: file_valid.h:343
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are equal.
Definition: file_valid.h:64
static void exists(const std::basic_string< Char > &file)
Validate that file exists.
Definition: file_valid.h:424
static void are_not_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual)
Validate that two files are not equal.
Definition: file_valid.h:323
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
Validate that two files are equal.
Definition: file_valid.h:44
static void does_not_exist(const std::basic_string< Char > &file, const std::string &message)
Validate that file not exists.
Definition: file_valid.h:525
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message)
Validate that two files are equal.
Definition: file_valid.h:84
static void exists(const std::basic_string< Char > &file, const xtd::diagnostics::stack_frame &stack_frame)
Validate that file exists.
Definition: file_valid.h:438
static void exists(const std::basic_string< Char > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Validate that file exists.
Definition: file_valid.h:467
static void are_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message)
Validate that two files are equal.
Definition: file_valid.h:170
static void are_not_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are not equal.
Definition: file_valid.h:384
static void does_not_exist(const std::basic_string< Char > &file)
Validate that file not exists.
Definition: file_valid.h:497
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are not equal.
Definition: file_valid.h:298
static void does_not_exist(const std::basic_string< Char > &file, const xtd::diagnostics::stack_frame &stack_frame)
Validate that file not exists.
Definition: file_valid.h:511
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are not equal.
Definition: file_valid.h:257
static void are_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are equal.
Definition: file_valid.h:150
static void are_not_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message)
Validate that two files are not equal.
Definition: file_valid.h:363
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are equal.
Definition: file_valid.h:105
static void are_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual)
Validate that two files are equal.
Definition: file_valid.h:130
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
Validate that two files are not equal.
Definition: file_valid.h:237
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const std::string &message)
Validate that two files are not equal.
Definition: file_valid.h:277
static void are_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Validate that two files are equal.
Definition: file_valid.h:191
Contains xtd::tunit::file_assert class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::tunit::valid class.