xtd 0.2.0
assert.h
Go to the documentation of this file.
1 #pragma once
5 #include "base_assert.h"
6 #include <algorithm>
7 #include <cmath>
8 #include <cstring>
9 #include <exception>
10 #include <functional>
11 #include <iterator>
12 #include <memory>
13 
15 #if defined(assert)
16 #undef assert
17 #endif
18 
21 namespace xtd {
23  namespace tunit {
36  class tunit_export_ assert final : public base_assert {
37  public:
39  assert() = delete;
41 
43 
54  template<typename expected_t, typename actual_t>
55  static void are_equal(const expected_t& expected, const actual_t& actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
66  template<typename expected_t, typename actual_t>
67  static void are_equal(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_equal(expected, actual, "", stack_frame);}
78  template<typename expected_t, typename actual_t>
79  static void are_equal(const expected_t& expected, const actual_t& actual, const xtd::ustring& message) {are_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
91  template<typename expected_t, typename actual_t>
92  static void are_equal(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
93  if (actual == expected)
94  succeed(message, stack_frame);
95  else
96  fail(to_string(expected), to_string(actual), message, stack_frame);
97  }
98 
100  static void are_equal(const char* expected, const char* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
101 #if defined(__cpp_lib_char8_t)
102  static void are_equal(const char8* expected, const char8* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
103 #endif
104  static void are_equal(const char16* expected, const char16* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
105  static void are_equal(const char32* expected, const char32* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
106  static void are_equal(const wchar_t* expected, const wchar_t* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
107  static void are_equal(float expected, float actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
108  static void are_equal(double expected, double actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
109  static void are_equal(long double expected, long double actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
111 
123  static void are_equal(float expected, float actual, float tolerance);
136  static void are_equal(float expected, float actual, float tolerance, const xtd::diagnostics::stack_frame& stack_frame);
149  static void are_equal(float expected, float& actual, float tolerance, const xtd::ustring& message);
163  static void are_equal(float expected, float actual, float tolerance, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
175  static void are_equal(double expected, double actual, double tolerance);
188  static void are_equal(double expected, double actual, double tolerance, const xtd::diagnostics::stack_frame& stack_frame);
201  static void are_equal(double expected, double actual, double tolerance, const xtd::ustring& message);
215  static void are_equal(double expected, double actual, double tolerance, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
227  static void are_equal(long double expected, long double actual, long double tolerance);
240  static void are_equal(long double expected, long double actual, long double tolerance, const xtd::diagnostics::stack_frame& stack_frame);
253  static void are_equal(long double expected, long double actual, long double tolerance, const xtd::ustring& message);
267  static void are_equal(long double expected, long double actual, long double tolerance, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
268 
278  template<typename expected_t, typename actual_t>
279  static void are_not_equal(const expected_t& expected, const actual_t& actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
290  template<typename expected_t, typename actual_t>
291  static void are_not_equal(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_equal(expected, actual, "", stack_frame);}
302  template<typename expected_t, typename actual_t>
303  static void are_not_equal(const expected_t& expected, const actual_t& actual, const xtd::ustring& message) {are_not_equal(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
315  template<typename expected_t, typename actual_t>
316  static void are_not_equal(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
317  if (actual != expected)
318  succeed(message, stack_frame);
319  else
320  fail("not " + to_string(expected), to_string(actual), message, stack_frame);
321  }
322 
324  static void are_not_equal(const char* expected, const char* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
325 #if defined(__cpp_lib_char8_t)
326  static void are_not_equal(const char8* expected, const char8* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
327 #endif
328  static void are_not_equal(const char16* expected, const char16* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
329  static void are_not_equal(const char32* expected, const char32* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
330  static void are_not_equal(const wchar_t* expected, const wchar_t* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
332 
345  template<typename expected_t, typename actual_t>
346  static void are_not_same(const expected_t& expected, const actual_t& actual) {are_not_same(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
360  template<typename expected_t, typename actual_t>
361  static void are_not_same(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_not_same(expected, actual, "", stack_frame);}
375  template<typename expected_t, typename actual_t>
376  static void are_not_same(const expected_t& expected, const actual_t& actual, const xtd::ustring& message) {are_not_same(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
391  template<typename expected_t, typename actual_t>
392  static void are_not_same(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
393  if (&actual != &expected)
394  succeed(message, stack_frame);
395  else
396  fail("not same as " + to_string(expected), to_string(actual), message, stack_frame);
397  }
398 
411  template<typename expected_t, typename actual_t>
412  static void are_same(const expected_t& expected, const actual_t& actual) {are_same(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
426  template<typename expected_t, typename actual_t>
427  static void are_same(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame) {are_same(expected, actual, "", stack_frame);}
441  template<typename expected_t, typename actual_t>
442  static void are_same(const expected_t& expected, const actual_t& actual, const xtd::ustring& message) {are_same(expected, actual, message, xtd::diagnostics::stack_frame::empty());}
457  template<typename expected_t, typename actual_t>
458  static void are_same(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
459  if (&actual == &expected)
460  succeed(message, stack_frame);
461  else
462  fail("same as " + to_string(expected), to_string(actual), message, stack_frame);
463  }
464 
475  template<typename item_t, typename collection_t>
476  static void contains(const item_t& item, const collection_t& collection) {contains(item, collection, "", xtd::diagnostics::stack_frame::empty());}
488  template<typename item_t, typename collection_t>
489  static void contains(const item_t& item, const collection_t& collection, const xtd::diagnostics::stack_frame& stack_frame) {contains(item, collection, "", stack_frame);}
501  template<typename item_t, typename collection_t>
502  static void contains(const item_t& item, const collection_t& collection, const xtd::ustring& message) {contains(item, collection, message, xtd::diagnostics::stack_frame::empty());}
515  template<typename item_t, typename collection_t>
516  static void contains(const item_t& item, const collection_t& collection, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
517  auto result = std::find(collection.begin(), collection.end(), item);
518  if (result != collection.end())
519  succeed(message, stack_frame);
520  else
521  fail("collection containing " + to_string(item), join_items(collection), message, stack_frame);
522  }
523 
525  template<typename item_t, typename value_t>
526  static void contains(const item_t& item, const std::initializer_list<value_t>& values) {contains(item, values, "", xtd::diagnostics::stack_frame::empty());}
527  template<typename item_t, typename value_t>
528  static void contains(const item_t& item, const std::initializer_list<value_t>& values, const xtd::diagnostics::stack_frame& stack_frame) {contains(item, values, "", stack_frame);}
529  template<typename item_t, typename value_t>
530  static void contains(const item_t& item, const std::initializer_list<value_t>& values, const xtd::ustring& message) {contains(item, values, message, xtd::diagnostics::stack_frame::empty());}
531  template<typename item_t, typename value_t>
532  static void contains(const item_t& item, const std::initializer_list<value_t>& values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
533  auto result = std::find(values.begin(), values.end(), item);
534  if (result != values.end())
535  succeed(message, stack_frame);
536  else
537  fail("collection containing " + to_string(item), join_items(values), message, stack_frame);
538  }
539  static void contains(char item, const char* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
540 #if defined(__cpp_lib_char8_t)
541  static void contains(char8 item, const char8* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
542 #endif
543  static void contains(char16 item, const char16* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
544  static void contains(char32 item, const char32* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
545  static void contains(wchar_t item, const wchar_t* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
547 
557  static void does_not_throw(const std::function<void()>& statement);
568  static void does_not_throw(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame);
579  static void does_not_throw(const std::function<void()>& statement, const xtd::ustring& message);
591  static void does_not_throw(const std::function<void()>& statement, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
592 
603  template<typename value_t>
604  static void is_empty(const value_t& value) {is_empty(value, "", xtd::diagnostics::stack_frame::empty());}
616  template<typename value_t>
617  static void is_empty(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_empty(value, "", stack_frame);}
629  template<typename value_t>
630  static void is_empty(const value_t& value, const xtd::ustring& message) {is_empty(value, message, xtd::diagnostics::stack_frame::empty());}
643  template<typename value_t>
644  static void is_empty(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
645  if (std::empty(value))
646  succeed(message, stack_frame);
647  else
648  fail("collection <empty>", join_items(value), message, stack_frame);
649  }
650 
652  template<typename value_t>
653  static void is_empty(const std::initializer_list<value_t>& value) {is_empty(value, "", xtd::diagnostics::stack_frame::empty());}
654  template<typename value_t>
655  static void is_empty(const std::initializer_list<value_t>& value, const xtd::diagnostics::stack_frame& stack_frame) {is_empty(value, "", stack_frame);}
656  template<typename value_t>
657  static void is_empty(const std::initializer_list<value_t>& value, const xtd::ustring& message) {is_empty(value, message, xtd::diagnostics::stack_frame::empty());}
658  template<typename value_t>
659  static void is_empty(const std::initializer_list<value_t>& values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
660  if (std::empty(values))
661  succeed(message, stack_frame);
662  else
663  fail("collection <empty>", join_items(values), message, stack_frame);
664  }
665  static void is_empty(const char* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
666 #if defined(__cpp_lib_char8_t)
667  static void is_empty(const char8* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
668 #endif
669  static void is_empty(const char16* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
670  static void is_empty(const char32* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
671  static void is_empty(const wchar_t* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
673 
684  static void is_false(bool condition);
696  static void is_false(bool condition, const xtd::diagnostics::stack_frame& stack_frame);
708  static void is_false(bool condition, const xtd::ustring& message);
721  static void is_false(bool condition, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
722 
732  template<typename value1_t, typename value2_t>
733  static void is_greater(const value1_t& val1, const value2_t& val2) {is_greater(val1, val2, "", xtd::diagnostics::stack_frame::empty());}
744  template<typename value1_t, typename value2_t>
745  static void is_greater(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame) {is_greater(val1, val2, "", stack_frame);}
756  template<typename value1_t, typename value2_t>
757  static void is_greater(const value1_t& val1, const value2_t& val2, const xtd::ustring& message) {is_greater(val1, val2, message, xtd::diagnostics::stack_frame::empty());}
769  template<typename value1_t, typename value2_t>
770  static void is_greater(const value1_t& val1, const value2_t& val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
771  if (val1 > val2)
772  succeed(message, stack_frame);
773  else
774  fail("greater than " + to_string(val2), to_string(val1), message, stack_frame);
775  }
776 
778  static void is_greater(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
779 #if defined(__cpp_lib_char8_t)
780  static void is_greater(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
781 #endif
782  static void is_greater(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
783  static void is_greater(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
784  static void is_greater(const wchar_t* val1, const wchar_t* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
786 
797  template<typename value1_t, typename value2_t>
798  static void is_greater_or_equal(const value1_t& val1, const value2_t& val2) {is_greater_or_equal(val1, val2, "", xtd::diagnostics::stack_frame::empty());}
810  template<typename value1_t, typename value2_t>
811  static void is_greater_or_equal(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame) {is_greater_or_equal(val1, val2, "", stack_frame);}
823  template<typename value1_t, typename value2_t>
824  static void is_greater_or_equal(const value1_t& val1, const value2_t& val2, const xtd::ustring& message) {is_greater_or_equal(val1, val2, message, xtd::diagnostics::stack_frame::empty());}
837  template<typename value1_t, typename value2_t>
838  static void is_greater_or_equal(const value1_t& val1, const value2_t& val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
839  if (val1 >= val2)
840  succeed(message, stack_frame);
841  else
842  fail("greater than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
843  }
844 
846  static void is_greater_or_equal(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
847 #if defined(__cpp_lib_char8_t)
848  static void is_greater_or_equal(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
849 #endif
850  static void is_greater_or_equal(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
851  static void is_greater_or_equal(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
852  static void is_greater_or_equal(const wchar_t* val1, const wchar_t* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
854 
864  template<typename type_t, typename value_t>
865  static void is_instance_of(const value_t& value) {is_instance_of<type_t>(value, "", xtd::diagnostics::stack_frame::empty());}
876  template<typename type_t, typename value_t>
877  static void is_instance_of(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_instance_of<type_t>(value, "", stack_frame);}
888  template<typename type_t, typename value_t>
889  static void is_instance_of(const value_t& value, const xtd::ustring& message) {is_instance_of<type_t>(value, message, xtd::diagnostics::stack_frame::empty());}
901  template<typename type_t, typename value_t>
902  static void is_instance_of(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
903  const type_t* instance = dynamic_cast<const type_t*>(&value);
904  if (instance != nullptr)
905  succeed(message, stack_frame);
906  else
907  fail("instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
908  }
909 
919  template<typename value1_t, typename value2_t>
920  static void is_less(const value1_t& val1, const value2_t& val2) {is_less(val1, val2, "", xtd::diagnostics::stack_frame::empty());}
931  template<typename value1_t, typename value2_t>
932  static void is_less(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame) {is_less(val1, val2, "", stack_frame);}
943  template<typename value1_t, typename value2_t>
944  static void is_less(const value1_t& val1, const value2_t& val2, const xtd::ustring& message) {is_less(val1, val2, message, xtd::diagnostics::stack_frame::empty());}
956  template<typename value1_t, typename value2_t>
957  static void is_less(const value1_t& val1, const value2_t& val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
958  if (val1 < val2)
959  succeed(message, stack_frame);
960  else
961  fail("less than " + to_string(val2), to_string(val1), message, stack_frame);
962  }
963 
965  static void is_less(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
966 #if defined(__cpp_lib_char8_t)
967  static void is_less(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
968 #endif
969  static void is_less(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
970  static void is_less(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
971  static void is_less(const wchar_t* val1, const wchar_t* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
973 
984  template<typename value1_t, typename value2_t>
985  static void is_less_or_equal(const value1_t& val1, const value2_t& val2) {is_less_or_equal(val1, val2, "", xtd::diagnostics::stack_frame::empty());}
997  template<typename value1_t, typename value2_t>
998  static void is_less_or_equal(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame) {is_less_or_equal(val1, val2, "", stack_frame);}
1010  template<typename value1_t, typename value2_t>
1011  static void is_less_or_equal(const value1_t& val1, const value2_t& val2, const xtd::ustring& message) {is_less_or_equal(val1, val2, message, xtd::diagnostics::stack_frame::empty());}
1024  template<typename value1_t, typename value2_t>
1025  static void is_less_or_equal(const value1_t& val1, const value2_t& val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1026  if (val1 <= val2)
1027  succeed(message, stack_frame);
1028  else
1029  fail("less than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
1030  }
1031 
1033  static void is_less_or_equal(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1034 #if defined(__cpp_lib_char8_t)
1035  static void is_less_or_equal(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1036 #endif
1037  static void is_less_or_equal(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1038  static void is_less_or_equal(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1039  static void is_less_or_equal(const wchar_t* val1, const wchar_t* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1041 
1052  static void is_NaN(double value);
1064  static void is_NaN(double value, const xtd::diagnostics::stack_frame& stack_frame);
1076  static void is_NaN(double value, const xtd::ustring& message);
1089  static void is_NaN(double value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1100  static void is_NaN(long double value);
1112  static void is_NaN(long double value, const xtd::diagnostics::stack_frame& stack_frame);
1124  static void is_NaN(long double value, const xtd::ustring& message);
1137  static void is_NaN(long double value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1148  static void is_NaN(float value);
1160  static void is_NaN(float value, const xtd::diagnostics::stack_frame& stack_frame);
1172  static void is_NaN(float value, const xtd::ustring& message);
1185  static void is_NaN(float value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1186 
1197  template<typename value_t>
1198  static void is_negative(const value_t& value) {is_negative(value, "", xtd::diagnostics::stack_frame::empty());}
1210  template<typename value_t>
1211  static void is_negative(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_negative(value, "", stack_frame);}
1223  template<typename value_t>
1224  static void is_negative(const value_t& value, const xtd::ustring& message) {is_negative(value, message, xtd::diagnostics::stack_frame::empty());}
1237  template<typename value_t>
1238  static void is_negative(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1239  if (value < 0)
1240  succeed(message, stack_frame);
1241  else
1242  fail("negative", to_string(value), message, stack_frame);
1243  }
1244 
1255  template<typename value_t>
1256  static void is_not_empty(const value_t& value) {is_not_empty(value, "", xtd::diagnostics::stack_frame::empty());}
1268  template<typename value_t>
1269  static void is_not_empty(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_not_empty(value, "", stack_frame);}
1281  template<typename value_t>
1282  static void is_not_empty(const value_t& value, const xtd::ustring& message) {is_not_empty(value, message, xtd::diagnostics::stack_frame::empty());}
1295  template<typename value_t>
1296  static void is_not_empty(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1297  if (!std::empty(value))
1298  succeed(message, stack_frame);
1299  else
1300  fail("collection not <empty>", "<empty>", message, stack_frame);
1301  }
1302 
1304  template<typename value_t>
1305  static void is_not_empty(const std::initializer_list<value_t>& value) {is_not_empty(value, "", xtd::diagnostics::stack_frame::empty());}
1306  template<typename value_t>
1307  static void is_not_empty(const std::initializer_list<value_t>& value, const xtd::diagnostics::stack_frame& stack_frame) {is_not_empty(value, "", stack_frame);}
1308  template<typename value_t>
1309  static void is_not_empty(const std::initializer_list<value_t>& value, const xtd::ustring& message) {is_not_empty(value, message, xtd::diagnostics::stack_frame::empty());}
1310  template<typename value_t>
1311  static void is_not_empty(const std::initializer_list<value_t>& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1312  if (!std::empty(value))
1313  succeed(message, stack_frame);
1314  else
1315  fail("collection not <empty>", "<empty>", message, stack_frame);
1316  }
1317  static void is_not_empty(const char* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1318 #if defined(__cpp_lib_char8_t)
1319  static void is_not_empty(const char8* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1320 #endif
1321  static void is_not_empty(const char16* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1322  static void is_not_empty(const char32* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1323  static void is_not_empty(const wchar_t* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1325 
1335  template<typename type_t, typename value_t>
1336  static void is_not_instance_of(const value_t& value) {is_not_instance_of<type_t>(value, "", xtd::diagnostics::stack_frame::empty());}
1347  template<typename type_t, typename value_t>
1348  static void is_not_instance_of(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_not_instance_of<type_t>(value, "", stack_frame);}
1359  template<typename type_t, typename value_t>
1360  static void is_not_instance_of(const value_t& value, const xtd::ustring& message) {is_not_instance_of<type_t>(value, message, xtd::diagnostics::stack_frame::empty());}
1372  template<typename type_t, typename value_t>
1373  static void is_not_instance_of(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1374  const type_t* instance = dynamic_cast<const type_t*>(&value);
1375  if (instance == nullptr)
1376  succeed(message, stack_frame);
1377  else
1378  fail("not instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
1379  }
1380 
1392  template<typename pointer_t>
1393  static void is_not_null(const pointer_t* pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1406  template<typename pointer_t>
1407  static void is_not_null(const pointer_t* pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(pointer, "", stack_frame);}
1420  template<typename pointer_t>
1421  static void is_not_null(const pointer_t* pointer, const xtd::ustring& message) {is_not_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1435  template<typename pointer_t>
1436  static void is_not_null(const pointer_t* pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1437  if (pointer != nullptr)
1438  succeed(message, stack_frame);
1439  else
1440  fail("not null", "null", message, stack_frame);
1441  }
1452  template<typename optional_t>
1453  static void is_not_null(const std::optional<optional_t>& opt) {is_not_null(opt, "", xtd::diagnostics::stack_frame::empty());}
1465  template<typename optional_t>
1466  static void is_not_null(const std::optional<optional_t>& opt, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(opt, "", stack_frame);}
1478  template<typename optional_t>
1479  static void is_not_null(const std::optional<optional_t>& opt, const xtd::ustring& message) {is_not_null(opt, message, xtd::diagnostics::stack_frame::empty());}
1492  template<typename optional_t>
1493  static void is_not_null(const std::optional<optional_t>& opt, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1494  if (opt != std::nullopt)
1495  succeed(message, stack_frame);
1496  else
1497  fail("not null", "null", message, stack_frame);
1498  }
1509  template<typename pointer_t>
1510  static void is_not_null(const std::unique_ptr<pointer_t>& pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1522  template<typename pointer_t>
1523  static void is_not_null(const std::unique_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(pointer, "", stack_frame);}
1535  template<typename pointer_t>
1536  static void is_not_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_not_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1549  template<typename pointer_t>
1550  static void is_not_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1551  if (pointer != nullptr)
1552  succeed(message, stack_frame);
1553  else
1554  fail("not null", "null", message, stack_frame);
1555  }
1566  template<typename pointer_t>
1567  static void is_not_null(const std::shared_ptr<pointer_t>& pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1579  template<typename pointer_t>
1580  static void is_not_null(const std::shared_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(pointer, "", stack_frame);}
1592  template<typename pointer_t>
1593  static void is_not_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_not_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1606  template<typename pointer_t>
1607  static void is_not_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1608  if (pointer != nullptr)
1609  succeed(message, stack_frame);
1610  else
1611  fail("not null", "null", message, stack_frame);
1612  }
1623  template<typename pointer_t>
1624  static void is_not_null(const std::weak_ptr<pointer_t>& pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1636  template<typename pointer_t>
1637  static void is_not_null(const std::weak_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(pointer, "", stack_frame);}
1649  template<typename pointer_t>
1650  static void is_not_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_not_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1663  template<typename pointer_t>
1664  static void is_not_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1665  if (pointer.owner_before(std::weak_ptr<pointer_t> {}) || std::weak_ptr<pointer_t> {}.owner_before(pointer))
1666  succeed(message, stack_frame);
1667  else
1668  fail("not null", "null", message, stack_frame);
1669  }
1678  static void is_not_null(std::nullptr_t pointer);
1688  static void is_not_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame);
1698  static void is_not_null(std::nullptr_t pointer, const xtd::ustring& message);
1709  static void is_not_null(std::nullptr_t pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1710 
1721  template<typename value_t>
1722  static void is_not_zero(const value_t& value) {is_not_zero(value, "", xtd::diagnostics::stack_frame::empty());}
1734  template<typename value_t>
1735  static void is_not_zero(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_not_zero(value, "", stack_frame);}
1747  template<typename value_t>
1748  static void is_not_zero(const value_t& value, const xtd::ustring& message) {is_not_zero(value, message, xtd::diagnostics::stack_frame::empty());}
1761  template<typename value_t>
1762  static void is_not_zero(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1763  if (value != 0)
1764  succeed(message, stack_frame);
1765  else
1766  fail("not zero", "0", message, stack_frame);
1767  }
1768 
1780  template<typename pointer_t>
1781  static void is_null(const pointer_t* pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1794  template<typename pointer_t>
1795  static void is_null(const pointer_t* pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
1808  template<typename pointer_t>
1809  static void is_null(const pointer_t* pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1823  template<typename pointer_t>
1824  static void is_null(const pointer_t* pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1825  if (pointer == nullptr)
1826  succeed(message, stack_frame);
1827  else
1828  fail("null", "not null", message, stack_frame);
1829  }
1840  template<typename optional_t>
1841  static void is_null(const std::optional<optional_t>& opt) {is_null(opt, "", xtd::diagnostics::stack_frame::empty());}
1853  template<typename optional_t>
1854  static void is_null(const std::optional<optional_t>& opt, const xtd::diagnostics::stack_frame& stack_frame) {is_null(opt, "", stack_frame);}
1866  template<typename optional_t>
1867  static void is_null(const std::optional<optional_t>& opt, const xtd::ustring& message) {is_null(opt, message, xtd::diagnostics::stack_frame::empty());}
1880  template<typename optional_t>
1881  static void is_null(const std::optional<optional_t>& opt, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1882  if (opt == std::nullopt)
1883  succeed(message, stack_frame);
1884  else
1885  fail("null", "not null", message, stack_frame);
1886  }
1897  template<typename pointer_t>
1898  static void is_null(const std::unique_ptr<pointer_t>& pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1910  template<typename pointer_t>
1911  static void is_null(const std::unique_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
1923  template<typename pointer_t>
1924  static void is_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1937  template<typename pointer_t>
1938  static void is_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1939  if (pointer == nullptr)
1940  succeed(message, stack_frame);
1941  else
1942  fail("null", "not null", message, stack_frame);
1943  }
1954  template<typename pointer_t>
1955  static void is_null(const std::shared_ptr<pointer_t>& pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1967  template<typename pointer_t>
1968  static void is_null(const std::shared_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
1980  template<typename pointer_t>
1981  static void is_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1994  template<typename pointer_t>
1995  static void is_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1996  if (pointer == nullptr)
1997  succeed(message, stack_frame);
1998  else
1999  fail("null", "not null", message, stack_frame);
2000  }
2012  template<typename pointer_t>
2013  static void is_null(const std::weak_ptr<pointer_t>& pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
2026  template<typename pointer_t>
2027  static void is_null(const std::weak_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
2040  template<typename pointer_t>
2041  static void is_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
2055  template<typename pointer_t>
2056  static void is_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2057  if (!pointer.owner_before(std::weak_ptr<pointer_t> {}) && !std::weak_ptr<pointer_t> {}.owner_before(pointer))
2058  succeed(message, stack_frame);
2059  else
2060  fail("null", "not null", message, stack_frame);
2061  }
2070  static void is_null(std::nullptr_t pointer);
2080  static void is_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame);
2090  static void is_null(std::nullptr_t pointer, const xtd::ustring& message);
2101  static void is_null(std::nullptr_t pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
2102 
2113  template<typename value_t>
2114  static void is_positive(const value_t& value) {is_positive(value, "", xtd::diagnostics::stack_frame::empty());}
2126  template<typename value_t>
2127  static void is_positive(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_positive(value, "", stack_frame);}
2139  template<typename value_t>
2140  static void is_positive(const value_t& value, const xtd::ustring& message) {is_positive(value, message, xtd::diagnostics::stack_frame::empty());}
2153  template<typename value_t>
2154  static void is_positive(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2155  if (value > 0)
2156  succeed(message, stack_frame);
2157  else
2158  fail("positive", to_string(value), message, stack_frame);
2159  }
2160 
2171  static void is_true(bool condition);
2183  static void is_true(bool condition, const xtd::diagnostics::stack_frame& stack_frame);
2195  static void is_true(bool condition, const xtd::ustring& message);
2208  static void is_true(bool condition, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
2209 
2220  template<typename value_t>
2221  static void is_zero(const value_t& value) {is_zero(value, "", xtd::diagnostics::stack_frame::empty());}
2233  template<typename value_t>
2234  static void is_zero(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_zero(value, "", stack_frame);}
2246  template<typename value_t>
2247  static void is_zero(const value_t& value, const xtd::ustring& message) {is_zero(value, message, xtd::diagnostics::stack_frame::empty());}
2260  template<typename value_t>
2261  static void is_zero(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2262  if (value == static_cast<value_t>(0))
2263  succeed(message, stack_frame);
2264  else
2265  fail("zero", to_string(value), message, stack_frame);
2266  }
2267 
2278  template<typename exception_t>
2279  static void throws(const std::function<void()>& statement) {throws<exception_t>(statement, "", xtd::diagnostics::stack_frame::empty());}
2291  template<typename exception_t>
2292  static void throws(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame) {throws<exception_t>(statement, "", stack_frame);}
2304  template<typename exception_t>
2305  static void throws(const std::function<void()>& statement, const xtd::ustring& message) {throws<exception_t>(statement, message, xtd::diagnostics::stack_frame::empty());}
2318  template<typename exception_t>
2319  static void throws(const std::function<void()>& statement, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2320  try {
2321  statement();
2322  fail("<" + typeof_<exception_t>().full_name() + ">", "<nothing>", message, stack_frame);
2323  } catch (const exception_t&) {
2324  succeed(message, stack_frame);
2325  } catch (const xtd::tunit::assert_error&) {
2326  throw;
2327  } catch (const std::exception& e) {
2328  fail("<" + typeof_<exception_t>().full_name() + ">", "<" + typeof_(e).full_name() + ">", message, stack_frame);
2329  } catch (...) {
2330  fail("<" + typeof_<exception_t>().full_name() + ">", "<exception>", message, stack_frame);
2331  }
2332  }
2333 
2343  static void throws_any(const std::function<void()>& statement);
2354  static void throws_any(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame);
2365  static void throws_any(const std::function<void()>& statement, const xtd::ustring& message);
2377  static void throws_any(const std::function<void()>& statement, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
2379 
2380  private:
2381  };
2382  }
2383 }
2384 
2386 #define __CMD_ASSERT_0_ARGS__(cmd) cmd(csf_)
2387 #define __CMD_ASSERT_1_ARGS__(cmd, arg1) cmd(arg1, csf_)
2388 #define __CMD_ASSERT_2_ARGS__(cmd, arg1, arg2) cmd(arg1, arg2, csf_)
2389 #define __CMD_ASSERT_3_ARGS__(cmd, arg1, arg2, arg3) cmd(arg1, arg2, arg3, csf_)
2390 #define __CMD_ASSERT_4_ARGS__(cmd, arg1, arg2, arg3, arg4) cmd(arg1, arg2, arg3, arg4, csf_)
2391 #define __CMD_ASSERT_5_ARGS__(cmd, arg1, arg2, arg3, arg4) cmd(arg1, arg2, arg3, arg4, arg5, csf_)
2392 #define __GET_LAST_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...) arg6
2393 #define __CMD_ASSERT_MACRO_CHOOSER(cmd, ...) __GET_LAST_ARG(__VA_ARGS__, __CMD_ASSERT_5_ARGS__, __CMD_ASSERT_4_ARGS__, __CMD_ASSERT_3_ARGS__, __CMD_ASSERT_2_ARGS__, __CMD_ASSERT_1_ARGS__, __CMD_ASSERT_0_ARGS__, )
2394 #define __CMD_ASSERT_ARGS(cmd, ...) __CMD_ASSERT_MACRO_CHOOSER(cmd, __VA_ARGS__)(cmd, __VA_ARGS__)
2395 
2408 #define abort_() abort(csf_)
2409 
2423 #define are_equal_(...) __CMD_ASSERT_ARGS(are_equal, __VA_ARGS__)
2424 
2438 #define are_not_equal_(...) __CMD_ASSERT_ARGS(are_not_equal, __VA_ARGS__)
2439 
2459 #define are_not_same_(...) __CMD_ASSERT_ARGS(are_not_same, __VA_ARGS__)
2460 
2480 #define are_same_(...) __CMD_ASSERT_ARGS(are_same, __VA_ARGS__)
2481 
2499 #define contains_(...) __CMD_ASSERT_ARGS(contains, __VA_ARGS__)
2500 
2517 #define does_not_throw_(...) __CMD_ASSERT_ARGS(does_not_throw, __VA_ARGS__)
2518 
2531 #define fail_(...) __CMD_ASSERT_ARGS(fail, __VA_ARGS__)
2532 
2544 #define ignore_(...) __CMD_ASSERT_ARGS(ignore, __VA_ARGS__)
2545 
2563 #define is_empty_(...) __CMD_ASSERT_ARGS(is_empty, __VA_ARGS__)
2564 
2582 #define is_false_(...) __CMD_ASSERT_ARGS(is_false, __VA_ARGS__)
2583 
2600 #define is_greater_(...) __CMD_ASSERT_ARGS(is_greater, __VA_ARGS__)
2601 
2621 #define is_greater_or_equal_(...) __CMD_ASSERT_ARGS(is_greater_or_equal, __VA_ARGS__)
2622 
2639 #define is_instance_of_(type_t, ...) __CMD_ASSERT_ARGS(is_instance_of<type_t>, __VA_ARGS__)
2640 
2657 #define is_less_(...) __CMD_ASSERT_ARGS(is_less, __VA_ARGS__)
2658 
2678 #define is_less_or_equal_(...) __CMD_ASSERT_ARGS(is_less_or_equal, __VA_ARGS__)
2679 
2697 #define is_NaN_(...) __CMD_ASSERT_ARGS(is_NaN, __VA_ARGS__)
2698 
2716 #define is_negative_(...) __CMD_ASSERT_ARGS(is_negative, __VA_ARGS__)
2717 
2735 #define is_not_empty_(...) __CMD_ASSERT_ARGS(is_not_empty, __VA_ARGS__)
2736 
2753 #define is_not_instance_of_(type_t, ...) __CMD_ASSERT_ARGS(is_not_instance_of<type_t>, __VA_ARGS__)
2754 
2773 #define is_not_null_(...) __CMD_ASSERT_ARGS(is_not_null, __VA_ARGS__)
2774 
2792 #define is_not_zero_(...) __CMD_ASSERT_ARGS(is_not_zero, __VA_ARGS__)
2793 
2812 #define is_null_(...) __CMD_ASSERT_ARGS(is_null, __VA_ARGS__)
2813 
2831 #define is_positive_(...) __CMD_ASSERT_ARGS(is_positive, __VA_ARGS__)
2832 
2850 #define is_true_(...) __CMD_ASSERT_ARGS(is_true, __VA_ARGS__)
2851 
2869 #define is_zero_(...) __CMD_ASSERT_ARGS(is_zero, __VA_ARGS__)
2870 
2882 #define succeed_(...) __CMD_ASSERT_ARGS(succeed, __VA_ARGS__)
2883 
2901 #define throws_(exception_t, ...) __CMD_ASSERT_ARGS(throws<exception_t>, __VA_ARGS__)
2902 
2919 #define throws_any_(...) __CMD_ASSERT_ARGS(throws_any, __VA_ARGS__)
static void is_less(const value1_t &val1, const value2_t &val2)
Asserts that the first value is is_less than the second value.
Definition: assert.h:920
static void is_zero(const value_t &value)
Asserts that ta condition is zero.
Definition: assert.h:2221
The base class for assert.
Definition: base_assert.h:29
static void is_null(const std::shared_ptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:1968
static void is_instance_of(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:877
static void is_less_or_equal(const value1_t &val1, const value2_t &val2, const xtd::ustring &message)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:1011
static void is_less_or_equal(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:998
static void is_less(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is is_less than the second value.
Definition: assert.h:932
static void is_not_zero(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is not zero.
Definition: assert.h:1748
static void is_null(const pointer_t *pointer)
Asserts that the pointer is null.
Definition: assert.h:1781
Exception thow when an assertion failed.
Definition: assert_error.h:17
static void contains(const item_t &item, const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection contains an item.
Definition: assert.h:489
static void is_not_null(const std::weak_ptr< pointer_t > &pointer)
Asserts that the pointer is not null.
Definition: assert.h:1624
static void is_not_null(const std::shared_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is not null.
Definition: assert.h:1593
The assert class contains a collection of static methods that implement the most common assertions us...
Definition: assert.h:36
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
Definition: assert.h:67
static void is_negative(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is negative.
Definition: assert.h:1211
static void is_not_null(const std::unique_ptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1523
static void are_not_same(const expected_t &expected, const actual_t &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two objects do refer to differents objects.
Definition: assert.h:392
static void is_not_null(const std::shared_ptr< pointer_t > &pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1607
static void is_null(const std::weak_ptr< pointer_t > &pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:2056
static void are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are not equal.
Definition: assert.h:291
static void is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection contains an item.
Definition: assert.h:617
static void is_null(const std::shared_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition: assert.h:1981
static void are_same(const expected_t &expected, const actual_t &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two objects do refer to differents objects.
Definition: assert.h:458
static void are_not_equal(const expected_t &expected, const actual_t &actual)
Asserts that two type are not equal.
Definition: assert.h:279
static void is_positive(const value_t &value)
Asserts that ta condition is positive.
Definition: assert.h:2114
static void are_same(const expected_t &expected, const actual_t &actual)
Asserts that two objects do refer to differents objects.
Definition: assert.h:412
static void is_not_empty(const value_t &value)
Asserts that collection oes not contain any item.
Definition: assert.h:1256
static void is_not_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is not zero.
Definition: assert.h:1735
static void is_not_null(const std::shared_ptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1580
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
static void are_not_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two objects do refer to differents objects.
Definition: assert.h:361
static void is_null(const std::unique_ptr< pointer_t > &pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:1938
static void are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::ustring &message)
Asserts that two type are not equal.
Definition: assert.h:303
static void is_not_null(const pointer_t *pointer, const xtd::ustring &message)
Asserts that the pointer is not null.
Definition: assert.h:1421
static void is_instance_of(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:902
static void is_null(const std::shared_ptr< pointer_t > &pointer)
Asserts that the pointer is null.
Definition: assert.h:1955
static void is_not_null(const std::unique_ptr< pointer_t > &pointer)
Asserts that the pointer is not null.
Definition: assert.h:1510
static void is_greater(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is greater than the second value.
Definition: assert.h:745
static void is_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is zero.
Definition: assert.h:2234
static void contains(const item_t &item, const collection_t &collection, const xtd::ustring &message)
Asserts that collection contains an item.
Definition: assert.h:502
static void are_not_same(const expected_t &expected, const actual_t &actual)
Asserts that two objects do refer to differents objects.
Definition: assert.h:346
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
static void is_not_null(const std::shared_ptr< pointer_t > &pointer)
Asserts that the pointer is not null.
Definition: assert.h:1567
static void is_null(const std::unique_ptr< pointer_t > &pointer)
Asserts that the pointer is null.
Definition: assert.h:1898
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1063
static void is_not_null(const std::weak_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is not null.
Definition: assert.h:1650
static void is_not_instance_of(const value_t &value)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1336
static void is_not_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection does not contain any item.
Definition: assert.h:1269
static void is_zero(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is zero.
Definition: assert.h:2247
static void are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are not equal.
Definition: assert.h:316
static void is_less(const value1_t &val1, const value2_t &val2, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is is_less than the second value.
Definition: assert.h:957
static void are_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two objects do refer to differents objects.
Definition: assert.h:427
static void is_less_or_equal(const value1_t &val1, const value2_t &val2, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:1025
static void is_null(const std::optional< optional_t > &opt, const xtd::ustring &message)
Asserts that the optional is std::nullopt.
Definition: assert.h:1867
static void are_not_same(const expected_t &expected, const actual_t &actual, const xtd::ustring &message)
Asserts that two objects do refer to differents objects.
Definition: assert.h:376
static void is_not_null(const std::weak_ptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1637
static void is_not_null(const std::optional< optional_t > &opt, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the optional is not std::nullopt.
Definition: assert.h:1466
static void is_greater(const value1_t &val1, const value2_t &val2)
Asserts that the first value is greater than the second value.
Definition: assert.h:733
static void is_greater_or_equal(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:811
static void is_null(const std::unique_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition: assert.h:1924
static void is_not_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1407
static void is_not_null(const std::unique_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is not null.
Definition: assert.h:1536
static void contains(const item_t &item, const collection_t &collection, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection contains an item.
Definition: assert.h:516
static void is_greater_or_equal(const value1_t &val1, const value2_t &val2, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:838
#define typeof_
Used to obtain the type string for a type. A typeof_ expression takes the following form: ...
Definition: typeof.h:42
static void is_not_null(const pointer_t *pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1436
static void is_null(const std::weak_ptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:2027
static void is_empty(const value_t &value)
Asserts that collection contains an item.
Definition: assert.h:604
static void is_less(const value1_t &val1, const value2_t &val2, const xtd::ustring &message)
Asserts that the first value is is_less than the second value.
Definition: assert.h:944
static void is_not_null(const std::optional< optional_t > &opt)
Asserts that the optional is not std::nullopt.
Definition: assert.h:1453
static void is_null(const std::optional< optional_t > &opt, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the optional is std::nullopt.
Definition: assert.h:1881
static void contains(const item_t &item, const collection_t &collection)
Asserts that collection contains an item.
Definition: assert.h:476
static void is_not_instance_of(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1348
static void is_not_empty(const value_t &value, const xtd::ustring &message)
Asserts that collection does not contain any item.
Definition: assert.h:1282
static void is_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:1795
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:37
static void is_greater_or_equal(const value1_t &val1, const value2_t &val2, const xtd::ustring &message)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:824
static void is_not_null(const pointer_t *pointer)
Asserts that the pointer is not null.
Definition: assert.h:1393
static stack_frame empty() noexcept
Return an empty stack frame.
static void is_null(const std::weak_ptr< pointer_t > &pointer)
Asserts that the pointer is null.
Definition: assert.h:2013
static void is_positive(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is positive.
Definition: assert.h:2140
static void is_not_zero(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is not zero.
Definition: assert.h:1762
static void is_null(const std::unique_ptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:1911
static void is_not_null(const std::unique_ptr< pointer_t > &pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1550
static void is_null(const std::optional< optional_t > &opt, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the optional is std::nullopt.
Definition: assert.h:1854
static void is_null(const std::shared_ptr< pointer_t > &pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:1995
static void is_empty(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection contains an item.
Definition: assert.h:644
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
Definition: assert.h:92
static void is_null(const std::optional< optional_t > &opt)
Asserts that the optional is std::nullopt.
Definition: assert.h:1841
static void is_not_instance_of(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1373
static void is_negative(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is negative.
Definition: assert.h:1238
static void is_positive(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is positive.
Definition: assert.h:2154
static void is_not_null(const std::optional< optional_t > &opt, const xtd::ustring &message)
Asserts that the optional is not std::nullopt.
Definition: assert.h:1479
char32_t char32
Represents a 32-bit unicode character.
Definition: types.h:85
static void is_negative(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is negative.
Definition: assert.h:1224
static void is_instance_of(const value_t &value)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:865
static void is_not_empty(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection does not contain any item.
Definition: assert.h:1296
static void is_null(const std::weak_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition: assert.h:2041
static void is_negative(const value_t &value)
Asserts that ta condition is negative.
Definition: assert.h:1198
static void is_positive(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is positive.
Definition: assert.h:2127
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::ustring &message)
Asserts that two type are equal.
Definition: assert.h:79
static void is_greater(const value1_t &val1, const value2_t &val2, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the first value is greater than the second value.
Definition: assert.h:770
static void is_null(const pointer_t *pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition: assert.h:1809
static void is_not_instance_of(const value_t &value, const xtd::ustring &message)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1360
static void is_not_zero(const value_t &value)
Asserts that ta condition is not zero.
Definition: assert.h:1722
static void is_greater(const value1_t &val1, const value2_t &val2, const xtd::ustring &message)
Asserts that the first value is greater than the second value.
Definition: assert.h:757
static void is_null(const pointer_t *pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition: assert.h:1824
char8_t char8
Represents a 8-bit unicode character.
Definition: types.h:62
static void is_not_null(const std::optional< optional_t > &opt, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the optional is not std::nullopt.
Definition: assert.h:1493
char16_t char16
Represents a 16-bit unicode character.
Definition: types.h:74
static void is_not_null(const std::weak_ptr< pointer_t > &pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
Definition: assert.h:1664
static void is_empty(const value_t &value, const xtd::ustring &message)
Asserts that collection contains an item.
Definition: assert.h:630
Contains xtd::tunit::assert class.
static void are_equal(const expected_t &expected, const actual_t &actual)
Asserts that two type are equal.
Definition: assert.h:55
static void is_less_or_equal(const value1_t &val1, const value2_t &val2)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:985
static void is_greater_or_equal(const value1_t &val1, const value2_t &val2)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:798
static void are_same(const expected_t &expected, const actual_t &actual, const xtd::ustring &message)
Asserts that two objects do refer to differents objects.
Definition: assert.h:442
static void is_instance_of(const value_t &value, const xtd::ustring &message)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:889
static void is_zero(const value_t &value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is zero.
Definition: assert.h:2261