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_assume.h
Go to the documentation of this file.
1 #pragma once
5 #include "assume.h"
6 #include "file_assert.h"
7 
9 namespace xtd {
11  namespace tunit {
21  class file_assume final : private base_assert {
22  public:
24  file_assume() = delete;
26 
44  template<typename Char>
45  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());}
46 
65  template<typename Char>
66  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);}
67 
86  template<typename Char>
87  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());}
88 
108  template<typename Char>
109  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) {
110  try {
111  file_assert::are_equal(expected, actual, message, stack_frame);
112  } catch(...) {
113  assert::abort();
114  }
115  }
116 
134  template<typename Char>
135  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());}
136 
155  template<typename Char>
156  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);}
157 
176  template<typename Char>
177  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());}
178 
198  template<typename Char>
199  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);}
200 
202  template<typename Char>
203  static void are_equal(const std::basic_string<Char>& expected, const Char* actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
204  template<typename Char>
205  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);}
206  template<typename Char>
207  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());}
208  template<typename Char>
209  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);}
210  template<typename Char>
211  static void are_equal(const Char* expected, const std::basic_string<Char>& actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
212  template<typename Char>
213  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);}
214  template<typename Char>
215  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());}
216  template<typename Char>
217  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);}
218  template<typename Char>
219  static void are_equal(const Char* expected, const Char* actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
220  template<typename Char>
221  static void are_equal(const Char* expected, const Char* actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
222  template<typename Char>
223  static void are_equal(const Char* expected, const Char* actual, const std::string& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
224  template<typename Char>
225  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);}
227 
245  template<typename Char>
246  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());}
247 
266  template<typename Char>
267  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);}
268 
287  template<typename Char>
288  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());}
289 
309  template<typename Char>
310  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) {
311  try {
312  file_assert::are_not_equal(expected, actual, message, stack_frame);
313  } catch(...) {
314  assert::abort();
315  }
316  }
317 
335  template<typename Char>
336  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());}
337 
356  template<typename Char>
357  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);}
358 
377  template<typename Char>
378  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());}
379 
399  template<typename Char>
400  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);}
401 
403  template<typename Char>
404  static void are_not_equal(const std::basic_string<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 std::basic_string<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 std::basic_string<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 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);}
411  template<typename Char>
412  static void are_not_equal(const Char* expected, const std::basic_string<Char>& actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
413  template<typename Char>
414  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);}
415  template<typename Char>
416  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());}
417  template<typename Char>
418  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);}
419  template<typename Char>
420  static void are_not_equal(const Char* expected, const Char* actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
421  template<typename Char>
422  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);}
423  template<typename Char>
424  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());}
425  template<typename Char>
426  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);}
428 
440  template<typename Char>
441  static void exists(const std::basic_string<Char>& file) {exists(file, "", xtd::diagnostics::stack_frame::empty());}
442 
455  template<typename Char>
456  static void exists(const std::basic_string<Char>& file, const xtd::diagnostics::stack_frame& stack_frame) {exists(file, "", stack_frame);}
457 
470  template<typename Char>
471  static void exists(const std::basic_string<Char>& file, const std::string& message) {exists(file, message, xtd::diagnostics::stack_frame::empty());}
472 
486  template<typename Char>
487  static void exists(const std::basic_string<Char>& file, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {
488  try {
489  file_assert::exists(file, message, stack_frame);
490  } catch(...) {
491  assert::abort();
492  }
493  }
494 
496  template<typename Char>
497  static void exists(const Char* file) {exists(file, "", xtd::diagnostics::stack_frame::empty());}
498  template<typename Char>
499  static void exists(const Char* file, const xtd::diagnostics::stack_frame& stack_frame) {exists(file, "", stack_frame);}
500  template<typename Char>
501  static void exists(const Char* file, const std::string& message) {exists(file, message, xtd::diagnostics::stack_frame::empty());}
502  template<typename Char>
503  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);}
505 
517  template<typename Char>
518  static void does_not_exist(const std::basic_string<Char>& file) {does_not_exist(file, "", xtd::diagnostics::stack_frame::empty());}
519 
532  template<typename Char>
533  static void does_not_exist(const std::basic_string<Char>& file, const xtd::diagnostics::stack_frame& stack_frame) {does_not_exist(file, "", stack_frame);}
534 
547  template<typename Char>
548  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());}
549 
563  template<typename Char>
564  static void does_not_exist(const std::basic_string<Char>& file, const std::string& message, const xtd::diagnostics::stack_frame& stack_frame) {
565  try {
566  file_assert::does_not_exist(file, message, stack_frame);
567  } catch(...) {
568  assert::abort();
569  }
570  }
571 
573  template<typename Char>
574  static void does_not_exist(const Char* file) {does_not_exist(file, "", xtd::diagnostics::stack_frame::empty());}
575  template<typename Char>
576  static void does_not_exist(const Char* file, const xtd::diagnostics::stack_frame& stack_frame) {does_not_exist(file, "", stack_frame);}
577  template<typename Char>
578  static void does_not_exist(const Char* file, const std::string& message) {does_not_exist(file, message, xtd::diagnostics::stack_frame::empty());}
579  template<typename Char>
580  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);}
582  };
583  }
584 }
Contains xtd::tunit::assume class.
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 abort()
Abort current test. This is used by the other Assert functions.
Definition: base_assert.h:36
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_assume class contains a collection of static methods that implement the most file assertions...
Definition: file_assume.h:21
static void does_not_exist(const std::basic_string< Char > &file, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that file not exists.
Definition: file_assume.h:533
static void are_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual)
Assumes that two files are equal.
Definition: file_assume.h:135
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)
Assumes that two files are not equal.
Definition: file_assume.h:400
static void does_not_exist(const std::basic_string< Char > &file)
Assumes that file not exists.
Definition: file_assume.h:518
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)
Assumes that two files are equal.
Definition: file_assume.h:199
static void does_not_exist(const std::basic_string< Char > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that file not exists.
Definition: file_assume.h:564
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)
Assumes that two files are not equal.
Definition: file_assume.h:310
static void exists(const std::basic_string< Char > &file, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that file exists.
Definition: file_assume.h:487
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.
Definition: file_assume.h:177
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that two files are not equal.
Definition: file_assume.h:267
static void are_not_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual)
Assumes that two files are not equal.
Definition: file_assume.h:336
static void are_not_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
Assumes that two files are not equal.
Definition: file_assume.h:246
static void exists(const std::basic_string< Char > &file, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that file exists.
Definition: file_assume.h:456
static void exists(const std::basic_string< Char > &file)
Assumes that file exists.
Definition: file_assume.h:441
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.
Definition: file_assume.h:288
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.
Definition: file_assume.h:87
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual)
Assumes that two files are equal.
Definition: file_assume.h:45
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.
Definition: file_assume.h:378
static void exists(const std::basic_string< Char > &file, const std::string &message)
Assumes that file exists.
Definition: file_assume.h:471
static void does_not_exist(const std::basic_string< Char > &file, const std::string &message)
Assumes that file not exists.
Definition: file_assume.h:548
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)
Assumes that two files are equal.
Definition: file_assume.h:109
static void are_not_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that two files are not equal.
Definition: file_assume.h:357
static void are_equal(const std::basic_string< Char > &expected, const std::basic_string< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that two files are equal.
Definition: file_assume.h:156
static void are_equal(const std::basic_istream< Char > &expected, const std::basic_istream< Char > &actual, const xtd::diagnostics::stack_frame &stack_frame)
Assumes that two files are equal.
Definition: file_assume.h:66
Contains xtd::tunit::file_assert class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17