xtd 0.2.0
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
4#pragma once
5#include "base_assert.h"
6#include <functional>
7
9#if defined(assert)
10#undef assert
11#endif
13
15namespace xtd {
17 namespace tunit {
30 class tunit_export_ assert final : public base_assert {
31 public:
33 assert() = delete;
35
37
48 template<typename expected_t, typename actual_t>
49 static void are_equal(const expected_t& expected, const actual_t& actual) {are_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
60 template<typename expected_t, typename actual_t>
61 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);}
72 template<typename expected_t, typename actual_t>
73 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());}
85 template<typename expected_t, typename actual_t>
86 static void are_equal(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
87 if (actual == expected)
88 succeed(message, stack_frame);
89 else
90 fail(to_string(expected), to_string(actual), message, stack_frame);
91 }
92
94 static void are_equal(const char* expected, const char* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
95#if defined(__cpp_lib_char8_t)
96 static void are_equal(const char8* expected, const char8* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
97#endif
98 static void are_equal(const char16* expected, const char16* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
99 static void are_equal(const char32* expected, const char32* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
100 static void are_equal(const wchar_t* expected, const wchar_t* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
101 static void are_equal(float expected, float actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
102 static void are_equal(double expected, double actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
103 static void are_equal(long double expected, long double actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
105
117 static void are_equal(float expected, float actual, float tolerance);
130 static void are_equal(float expected, float actual, float tolerance, const xtd::diagnostics::stack_frame& stack_frame);
143 static void are_equal(float expected, float& actual, float tolerance, const xtd::ustring& message);
157 static void are_equal(float expected, float actual, float tolerance, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
169 static void are_equal(double expected, double actual, double tolerance);
182 static void are_equal(double expected, double actual, double tolerance, const xtd::diagnostics::stack_frame& stack_frame);
195 static void are_equal(double expected, double actual, double tolerance, const xtd::ustring& message);
209 static void are_equal(double expected, double actual, double tolerance, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
221 static void are_equal(long double expected, long double actual, long double tolerance);
234 static void are_equal(long double expected, long double actual, long double tolerance, const xtd::diagnostics::stack_frame& stack_frame);
247 static void are_equal(long double expected, long double actual, long double tolerance, const xtd::ustring& message);
261 static void are_equal(long double expected, long double actual, long double tolerance, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
262
272 template<typename expected_t, typename actual_t>
273 static void are_not_equal(const expected_t& expected, const actual_t& actual) {are_not_equal(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
284 template<typename expected_t, typename actual_t>
285 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);}
296 template<typename expected_t, typename actual_t>
297 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());}
309 template<typename expected_t, typename actual_t>
310 static void are_not_equal(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
311 if (actual != expected)
312 succeed(message, stack_frame);
313 else
314 fail("not " + to_string(expected), to_string(actual), message, stack_frame);
315 }
316
318 static void are_not_equal(const char* expected, const char* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
319#if defined(__cpp_lib_char8_t)
320 static void are_not_equal(const char8* expected, const char8* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
321#endif
322 static void are_not_equal(const char16* expected, const char16* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
323 static void are_not_equal(const char32* expected, const char32* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
324 static void are_not_equal(const wchar_t* expected, const wchar_t* actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
326
339 template<typename expected_t, typename actual_t>
340 static void are_not_same(const expected_t& expected, const actual_t& actual) {are_not_same(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
354 template<typename expected_t, typename actual_t>
355 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);}
369 template<typename expected_t, typename actual_t>
370 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());}
385 template<typename expected_t, typename actual_t>
386 static void are_not_same(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
387 if (&actual != &expected)
388 succeed(message, stack_frame);
389 else
390 fail("not same as " + to_string(expected), to_string(actual), message, stack_frame);
391 }
392
405 template<typename expected_t, typename actual_t>
406 static void are_same(const expected_t& expected, const actual_t& actual) {are_same(expected, actual, "", xtd::diagnostics::stack_frame::empty());}
420 template<typename expected_t, typename actual_t>
421 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);}
435 template<typename expected_t, typename actual_t>
436 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());}
451 template<typename expected_t, typename actual_t>
452 static void are_same(const expected_t& expected, const actual_t& actual, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
453 if (&actual == &expected)
454 succeed(message, stack_frame);
455 else
456 fail("same as " + to_string(expected), to_string(actual), message, stack_frame);
457 }
458
469 template<typename item_t, typename collection_t>
470 static void contains(const item_t& item, const collection_t& collection) {contains(item, collection, "", xtd::diagnostics::stack_frame::empty());}
482 template<typename item_t, typename collection_t>
483 static void contains(const item_t& item, const collection_t& collection, const xtd::diagnostics::stack_frame& stack_frame) {contains(item, collection, "", stack_frame);}
495 template<typename item_t, typename collection_t>
496 static void contains(const item_t& item, const collection_t& collection, const xtd::ustring& message) {contains(item, collection, message, xtd::diagnostics::stack_frame::empty());}
509 template<typename item_t, typename collection_t>
510 static void contains(const item_t& item, const collection_t& collection, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
511 auto result = std::find(collection.begin(), collection.end(), item);
512 if (result != collection.end())
513 succeed(message, stack_frame);
514 else
515 fail("collection containing " + to_string(item), join_items(collection), message, stack_frame);
516 }
517
519 template<typename item_t, typename value_t>
520 static void contains(const item_t& item, const std::initializer_list<value_t>& values) {contains(item, values, "", xtd::diagnostics::stack_frame::empty());}
521 template<typename item_t, typename value_t>
522 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);}
523 template<typename item_t, typename value_t>
524 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());}
525 template<typename item_t, typename value_t>
526 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) {
527 auto result = std::find(values.begin(), values.end(), item);
528 if (result != values.end())
529 succeed(message, stack_frame);
530 else
531 fail("collection containing " + to_string(item), join_items(values), message, stack_frame);
532 }
533 static void contains(char item, const char* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
534#if defined(__cpp_lib_char8_t)
535 static void contains(char8 item, const char8* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
536#endif
537 static void contains(char16 item, const char16* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
538 static void contains(char32 item, const char32* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
539 static void contains(wchar_t item, const wchar_t* values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
541
551 static void does_not_throw(const std::function<void()>& statement);
562 static void does_not_throw(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame);
573 static void does_not_throw(const std::function<void()>& statement, const xtd::ustring& message);
585 static void does_not_throw(const std::function<void()>& statement, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
586
597 template<typename value_t>
598 static void is_empty(const value_t& value) {is_empty(value, "", xtd::diagnostics::stack_frame::empty());}
610 template<typename value_t>
611 static void is_empty(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_empty(value, "", stack_frame);}
623 template<typename value_t>
624 static void is_empty(const value_t& value, const xtd::ustring& message) {is_empty(value, message, xtd::diagnostics::stack_frame::empty());}
637 template<typename value_t>
638 static void is_empty(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
639 if (std::empty(value))
640 succeed(message, stack_frame);
641 else
642 fail("collection <empty>", join_items(value), message, stack_frame);
643 }
644
646 template<typename value_t>
647 static void is_empty(const std::initializer_list<value_t>& value) {is_empty(value, "", xtd::diagnostics::stack_frame::empty());}
648 template<typename value_t>
649 static void is_empty(const std::initializer_list<value_t>& value, const xtd::diagnostics::stack_frame& stack_frame) {is_empty(value, "", stack_frame);}
650 template<typename value_t>
651 static void is_empty(const std::initializer_list<value_t>& value, const xtd::ustring& message) {is_empty(value, message, xtd::diagnostics::stack_frame::empty());}
652 template<typename value_t>
653 static void is_empty(const std::initializer_list<value_t>& values, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
654 if (std::empty(values))
655 succeed(message, stack_frame);
656 else
657 fail("collection <empty>", join_items(values), message, stack_frame);
658 }
659 static void is_empty(const char* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
660#if defined(__cpp_lib_char8_t)
661 static void is_empty(const char8* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
662#endif
663 static void is_empty(const char16* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
664 static void is_empty(const char32* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
665 static void is_empty(const wchar_t* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
667
678 static void is_false(bool condition);
690 static void is_false(bool condition, const xtd::diagnostics::stack_frame& stack_frame);
702 static void is_false(bool condition, const xtd::ustring& message);
715 static void is_false(bool condition, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
716
726 template<typename value1_t, typename value2_t>
727 static void is_greater(const value1_t& val1, const value2_t& val2) {is_greater(val1, val2, "", xtd::diagnostics::stack_frame::empty());}
738 template<typename value1_t, typename value2_t>
739 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);}
750 template<typename value1_t, typename value2_t>
751 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());}
763 template<typename value1_t, typename value2_t>
764 static void is_greater(const value1_t& val1, const value2_t& val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
765 if (val1 > val2)
766 succeed(message, stack_frame);
767 else
768 fail("greater than " + to_string(val2), to_string(val1), message, stack_frame);
769 }
770
772 static void is_greater(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
773#if defined(__cpp_lib_char8_t)
774 static void is_greater(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
775#endif
776 static void is_greater(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
777 static void is_greater(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
778 static void is_greater(const wchar_t* val1, const wchar_t* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
780
791 template<typename value1_t, typename value2_t>
792 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());}
804 template<typename value1_t, typename value2_t>
805 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);}
817 template<typename value1_t, typename value2_t>
818 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());}
831 template<typename value1_t, typename value2_t>
832 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) {
833 if (val1 >= val2)
834 succeed(message, stack_frame);
835 else
836 fail("greater than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
837 }
838
840 static void is_greater_or_equal(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
841#if defined(__cpp_lib_char8_t)
842 static void is_greater_or_equal(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
843#endif
844 static void is_greater_or_equal(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
845 static void is_greater_or_equal(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
846 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);
848
858 template<typename type_t, typename value_t>
859 static void is_instance_of(const value_t& value) {is_instance_of<type_t>(value, "", xtd::diagnostics::stack_frame::empty());}
870 template<typename type_t, typename value_t>
871 static void is_instance_of(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_instance_of<type_t>(value, "", stack_frame);}
882 template<typename type_t, typename value_t>
883 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());}
895 template<typename type_t, typename value_t>
896 static void is_instance_of(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
897 const type_t* instance = dynamic_cast<const type_t*>(&value);
898 if (instance != nullptr)
899 succeed(message, stack_frame);
900 else
901 fail("instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
902 }
903
913 template<typename value1_t, typename value2_t>
914 static void is_less(const value1_t& val1, const value2_t& val2) {is_less(val1, val2, "", xtd::diagnostics::stack_frame::empty());}
925 template<typename value1_t, typename value2_t>
926 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);}
937 template<typename value1_t, typename value2_t>
938 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());}
950 template<typename value1_t, typename value2_t>
951 static void is_less(const value1_t& val1, const value2_t& val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
952 if (val1 < val2)
953 succeed(message, stack_frame);
954 else
955 fail("less than " + to_string(val2), to_string(val1), message, stack_frame);
956 }
957
959 static void is_less(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
960#if defined(__cpp_lib_char8_t)
961 static void is_less(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
962#endif
963 static void is_less(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
964 static void is_less(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
965 static void is_less(const wchar_t* val1, const wchar_t* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
967
978 template<typename value1_t, typename value2_t>
979 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());}
991 template<typename value1_t, typename value2_t>
992 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);}
1004 template<typename value1_t, typename value2_t>
1005 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());}
1018 template<typename value1_t, typename value2_t>
1019 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) {
1020 if (val1 <= val2)
1021 succeed(message, stack_frame);
1022 else
1023 fail("less than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
1024 }
1025
1027 static void is_less_or_equal(const char* val1, const char* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1028#if defined(__cpp_lib_char8_t)
1029 static void is_less_or_equal(const char8* val1, const char8* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1030#endif
1031 static void is_less_or_equal(const char16* val1, const char16* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1032 static void is_less_or_equal(const char32* val1, const char32* val2, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1033 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);
1035
1046 static void is_NaN(double value);
1058 static void is_NaN(double value, const xtd::diagnostics::stack_frame& stack_frame);
1070 static void is_NaN(double value, const xtd::ustring& message);
1083 static void is_NaN(double value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1094 static void is_NaN(long double value);
1106 static void is_NaN(long double value, const xtd::diagnostics::stack_frame& stack_frame);
1118 static void is_NaN(long double value, const xtd::ustring& message);
1131 static void is_NaN(long double value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1142 static void is_NaN(float value);
1154 static void is_NaN(float value, const xtd::diagnostics::stack_frame& stack_frame);
1166 static void is_NaN(float value, const xtd::ustring& message);
1179 static void is_NaN(float value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1180
1191 template<typename value_t>
1192 static void is_negative(const value_t& value) {is_negative(value, "", xtd::diagnostics::stack_frame::empty());}
1204 template<typename value_t>
1205 static void is_negative(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_negative(value, "", stack_frame);}
1217 template<typename value_t>
1218 static void is_negative(const value_t& value, const xtd::ustring& message) {is_negative(value, message, xtd::diagnostics::stack_frame::empty());}
1231 template<typename value_t>
1232 static void is_negative(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1233 if (value < 0)
1234 succeed(message, stack_frame);
1235 else
1236 fail("negative", to_string(value), message, stack_frame);
1237 }
1238
1249 template<typename value_t>
1250 static void is_not_empty(const value_t& value) {is_not_empty(value, "", xtd::diagnostics::stack_frame::empty());}
1262 template<typename value_t>
1263 static void is_not_empty(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_not_empty(value, "", stack_frame);}
1275 template<typename value_t>
1276 static void is_not_empty(const value_t& value, const xtd::ustring& message) {is_not_empty(value, message, xtd::diagnostics::stack_frame::empty());}
1289 template<typename value_t>
1290 static void is_not_empty(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1291 if (!std::empty(value))
1292 succeed(message, stack_frame);
1293 else
1294 fail("collection not <empty>", "<empty>", message, stack_frame);
1295 }
1296
1298 template<typename value_t>
1299 static void is_not_empty(const std::initializer_list<value_t>& value) {is_not_empty(value, "", xtd::diagnostics::stack_frame::empty());}
1300 template<typename value_t>
1301 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);}
1302 template<typename value_t>
1303 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());}
1304 template<typename value_t>
1305 static void is_not_empty(const std::initializer_list<value_t>& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1306 if (!std::empty(value))
1307 succeed(message, stack_frame);
1308 else
1309 fail("collection not <empty>", "<empty>", message, stack_frame);
1310 }
1311 static void is_not_empty(const char* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1312#if defined(__cpp_lib_char8_t)
1313 static void is_not_empty(const char8* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1314#endif
1315 static void is_not_empty(const char16* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1316 static void is_not_empty(const char32* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1317 static void is_not_empty(const wchar_t* value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1319
1329 template<typename type_t, typename value_t>
1330 static void is_not_instance_of(const value_t& value) {is_not_instance_of<type_t>(value, "", xtd::diagnostics::stack_frame::empty());}
1341 template<typename type_t, typename value_t>
1342 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);}
1353 template<typename type_t, typename value_t>
1354 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());}
1366 template<typename type_t, typename value_t>
1367 static void is_not_instance_of(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1368 const type_t* instance = dynamic_cast<const type_t*>(&value);
1369 if (instance == nullptr)
1370 succeed(message, stack_frame);
1371 else
1372 fail("not instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
1373 }
1374
1386 template<typename pointer_t>
1387 static void is_not_null(const pointer_t* pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1400 template<typename pointer_t>
1401 static void is_not_null(const pointer_t* pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(pointer, "", stack_frame);}
1414 template<typename pointer_t>
1415 static void is_not_null(const pointer_t* pointer, const xtd::ustring& message) {is_not_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1429 template<typename pointer_t>
1430 static void is_not_null(const pointer_t* pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1431 if (pointer != nullptr)
1432 succeed(message, stack_frame);
1433 else
1434 fail("not null", "null", message, stack_frame);
1435 }
1446 template<typename optional_t>
1447 static void is_not_null(const std::optional<optional_t>& opt) {is_not_null(opt, "", xtd::diagnostics::stack_frame::empty());}
1459 template<typename optional_t>
1460 static void is_not_null(const std::optional<optional_t>& opt, const xtd::diagnostics::stack_frame& stack_frame) {is_not_null(opt, "", stack_frame);}
1472 template<typename optional_t>
1473 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());}
1486 template<typename optional_t>
1487 static void is_not_null(const std::optional<optional_t>& opt, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1488 if (opt != std::nullopt)
1489 succeed(message, stack_frame);
1490 else
1491 fail("not null", "null", message, stack_frame);
1492 }
1503 template<typename pointer_t>
1504 static void is_not_null(const std::unique_ptr<pointer_t>& pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1516 template<typename pointer_t>
1517 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);}
1529 template<typename pointer_t>
1530 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());}
1543 template<typename pointer_t>
1544 static void is_not_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1545 if (pointer != nullptr)
1546 succeed(message, stack_frame);
1547 else
1548 fail("not null", "null", message, stack_frame);
1549 }
1560 template<typename pointer_t>
1561 static void is_not_null(const std::shared_ptr<pointer_t>& pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1573 template<typename pointer_t>
1574 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);}
1586 template<typename pointer_t>
1587 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());}
1600 template<typename pointer_t>
1601 static void is_not_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1602 if (pointer != nullptr)
1603 succeed(message, stack_frame);
1604 else
1605 fail("not null", "null", message, stack_frame);
1606 }
1617 template<typename pointer_t>
1618 static void is_not_null(const std::weak_ptr<pointer_t>& pointer) {is_not_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1630 template<typename pointer_t>
1631 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);}
1643 template<typename pointer_t>
1644 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());}
1657 template<typename pointer_t>
1658 static void is_not_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1659 if (pointer.owner_before(std::weak_ptr<pointer_t> {}) || std::weak_ptr<pointer_t> {}.owner_before(pointer))
1660 succeed(message, stack_frame);
1661 else
1662 fail("not null", "null", message, stack_frame);
1663 }
1672 static void is_not_null(std::nullptr_t pointer);
1682 static void is_not_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame);
1692 static void is_not_null(std::nullptr_t pointer, const xtd::ustring& message);
1703 static void is_not_null(std::nullptr_t pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
1704
1715 template<typename value_t>
1716 static void is_not_zero(const value_t& value) {is_not_zero(value, "", xtd::diagnostics::stack_frame::empty());}
1728 template<typename value_t>
1729 static void is_not_zero(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_not_zero(value, "", stack_frame);}
1741 template<typename value_t>
1742 static void is_not_zero(const value_t& value, const xtd::ustring& message) {is_not_zero(value, message, xtd::diagnostics::stack_frame::empty());}
1755 template<typename value_t>
1756 static void is_not_zero(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1757 if (value != 0)
1758 succeed(message, stack_frame);
1759 else
1760 fail("not zero", "0", message, stack_frame);
1761 }
1762
1774 template<typename pointer_t>
1775 static void is_null(const pointer_t* pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1788 template<typename pointer_t>
1789 static void is_null(const pointer_t* pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
1802 template<typename pointer_t>
1803 static void is_null(const pointer_t* pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1817 template<typename pointer_t>
1818 static void is_null(const pointer_t* pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1819 if (pointer == nullptr)
1820 succeed(message, stack_frame);
1821 else
1822 fail("null", "not null", message, stack_frame);
1823 }
1834 template<typename optional_t>
1835 static void is_null(const std::optional<optional_t>& opt) {is_null(opt, "", xtd::diagnostics::stack_frame::empty());}
1847 template<typename optional_t>
1848 static void is_null(const std::optional<optional_t>& opt, const xtd::diagnostics::stack_frame& stack_frame) {is_null(opt, "", stack_frame);}
1860 template<typename optional_t>
1861 static void is_null(const std::optional<optional_t>& opt, const xtd::ustring& message) {is_null(opt, message, xtd::diagnostics::stack_frame::empty());}
1874 template<typename optional_t>
1875 static void is_null(const std::optional<optional_t>& opt, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1876 if (opt == std::nullopt)
1877 succeed(message, stack_frame);
1878 else
1879 fail("null", "not null", message, stack_frame);
1880 }
1891 template<typename pointer_t>
1892 static void is_null(const std::unique_ptr<pointer_t>& pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1904 template<typename pointer_t>
1905 static void is_null(const std::unique_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
1917 template<typename pointer_t>
1918 static void is_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1931 template<typename pointer_t>
1932 static void is_null(const std::unique_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1933 if (pointer == nullptr)
1934 succeed(message, stack_frame);
1935 else
1936 fail("null", "not null", message, stack_frame);
1937 }
1948 template<typename pointer_t>
1949 static void is_null(const std::shared_ptr<pointer_t>& pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
1961 template<typename pointer_t>
1962 static void is_null(const std::shared_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
1974 template<typename pointer_t>
1975 static void is_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
1988 template<typename pointer_t>
1989 static void is_null(const std::shared_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
1990 if (pointer == nullptr)
1991 succeed(message, stack_frame);
1992 else
1993 fail("null", "not null", message, stack_frame);
1994 }
2006 template<typename pointer_t>
2007 static void is_null(const std::weak_ptr<pointer_t>& pointer) {is_null(pointer, "", xtd::diagnostics::stack_frame::empty());}
2020 template<typename pointer_t>
2021 static void is_null(const std::weak_ptr<pointer_t>& pointer, const xtd::diagnostics::stack_frame& stack_frame) {is_null(pointer, "", stack_frame);}
2034 template<typename pointer_t>
2035 static void is_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message) {is_null(pointer, message, xtd::diagnostics::stack_frame::empty());}
2049 template<typename pointer_t>
2050 static void is_null(const std::weak_ptr<pointer_t>& pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2051 if (!pointer.owner_before(std::weak_ptr<pointer_t> {}) && !std::weak_ptr<pointer_t> {}.owner_before(pointer))
2052 succeed(message, stack_frame);
2053 else
2054 fail("null", "not null", message, stack_frame);
2055 }
2064 static void is_null(std::nullptr_t pointer);
2074 static void is_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame);
2084 static void is_null(std::nullptr_t pointer, const xtd::ustring& message);
2095 static void is_null(std::nullptr_t pointer, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
2096
2107 template<typename value_t>
2108 static void is_positive(const value_t& value) {is_positive(value, "", xtd::diagnostics::stack_frame::empty());}
2120 template<typename value_t>
2121 static void is_positive(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_positive(value, "", stack_frame);}
2133 template<typename value_t>
2134 static void is_positive(const value_t& value, const xtd::ustring& message) {is_positive(value, message, xtd::diagnostics::stack_frame::empty());}
2147 template<typename value_t>
2148 static void is_positive(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2149 if (value > 0)
2150 succeed(message, stack_frame);
2151 else
2152 fail("positive", to_string(value), message, stack_frame);
2153 }
2154
2165 static void is_true(bool condition);
2177 static void is_true(bool condition, const xtd::diagnostics::stack_frame& stack_frame);
2189 static void is_true(bool condition, const xtd::ustring& message);
2202 static void is_true(bool condition, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
2203
2214 template<typename value_t>
2215 static void is_zero(const value_t& value) {is_zero(value, "", xtd::diagnostics::stack_frame::empty());}
2227 template<typename value_t>
2228 static void is_zero(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame) {is_zero(value, "", stack_frame);}
2240 template<typename value_t>
2241 static void is_zero(const value_t& value, const xtd::ustring& message) {is_zero(value, message, xtd::diagnostics::stack_frame::empty());}
2254 template<typename value_t>
2255 static void is_zero(const value_t& value, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2256 if (value == static_cast<value_t>(0))
2257 succeed(message, stack_frame);
2258 else
2259 fail("zero", to_string(value), message, stack_frame);
2260 }
2261
2272 template<typename exception_t>
2273 static void throws(const std::function<void()>& statement) {throws<exception_t>(statement, "", xtd::diagnostics::stack_frame::empty());}
2285 template<typename exception_t>
2286 static void throws(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame) {throws<exception_t>(statement, "", stack_frame);}
2298 template<typename exception_t>
2299 static void throws(const std::function<void()>& statement, const xtd::ustring& message) {throws<exception_t>(statement, message, xtd::diagnostics::stack_frame::empty());}
2312 template<typename exception_t>
2313 static void throws(const std::function<void()>& statement, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame) {
2314 try {
2315 statement();
2316 fail("<" + typeof_<exception_t>().full_name() + ">", "<nothing>", message, stack_frame);
2317 } catch (const exception_t&) {
2318 succeed(message, stack_frame);
2319 } catch (const xtd::tunit::assert_error&) {
2320 throw;
2321 } catch (const std::exception& e) {
2322 fail("<" + typeof_<exception_t>().full_name() + ">", "<" + typeof_(e).full_name() + ">", message, stack_frame);
2323 } catch (...) {
2324 fail("<" + typeof_<exception_t>().full_name() + ">", "<exception>", message, stack_frame);
2325 }
2326 }
2327
2337 static void throws_any(const std::function<void()>& statement);
2348 static void throws_any(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame);
2359 static void throws_any(const std::function<void()>& statement, const xtd::ustring& message);
2371 static void throws_any(const std::function<void()>& statement, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
2373
2374 private:
2375 };
2376 }
2377}
2378
2380#define __CMD_ASSERT_0_ARGS__(cmd) cmd(csf_)
2381#define __CMD_ASSERT_1_ARGS__(cmd, arg1) cmd(arg1, csf_)
2382#define __CMD_ASSERT_2_ARGS__(cmd, arg1, arg2) cmd(arg1, arg2, csf_)
2383#define __CMD_ASSERT_3_ARGS__(cmd, arg1, arg2, arg3) cmd(arg1, arg2, arg3, csf_)
2384#define __CMD_ASSERT_4_ARGS__(cmd, arg1, arg2, arg3, arg4) cmd(arg1, arg2, arg3, arg4, csf_)
2385#define __CMD_ASSERT_5_ARGS__(cmd, arg1, arg2, arg3, arg4) cmd(arg1, arg2, arg3, arg4, arg5, csf_)
2386#define __GET_LAST_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...) arg6
2387#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__, )
2388#define __CMD_ASSERT_ARGS(cmd, ...) __CMD_ASSERT_MACRO_CHOOSER(cmd, __VA_ARGS__)(cmd, __VA_ARGS__)
2390
2402#define abort_() abort(csf_)
2403
2417#define are_equal_(...) __CMD_ASSERT_ARGS(are_equal, __VA_ARGS__)
2418
2432#define are_not_equal_(...) __CMD_ASSERT_ARGS(are_not_equal, __VA_ARGS__)
2433
2453#define are_not_same_(...) __CMD_ASSERT_ARGS(are_not_same, __VA_ARGS__)
2454
2474#define are_same_(...) __CMD_ASSERT_ARGS(are_same, __VA_ARGS__)
2475
2493#define contains_(...) __CMD_ASSERT_ARGS(contains, __VA_ARGS__)
2494
2511#define does_not_throw_(...) __CMD_ASSERT_ARGS(does_not_throw, __VA_ARGS__)
2512
2525#define fail_(...) __CMD_ASSERT_ARGS(fail, __VA_ARGS__)
2526
2538#define ignore_(...) __CMD_ASSERT_ARGS(ignore, __VA_ARGS__)
2539
2557#define is_empty_(...) __CMD_ASSERT_ARGS(is_empty, __VA_ARGS__)
2558
2576#define is_false_(...) __CMD_ASSERT_ARGS(is_false, __VA_ARGS__)
2577
2594#define is_greater_(...) __CMD_ASSERT_ARGS(is_greater, __VA_ARGS__)
2595
2615#define is_greater_or_equal_(...) __CMD_ASSERT_ARGS(is_greater_or_equal, __VA_ARGS__)
2616
2633#define is_instance_of_(type_t, ...) __CMD_ASSERT_ARGS(is_instance_of<type_t>, __VA_ARGS__)
2634
2651#define is_less_(...) __CMD_ASSERT_ARGS(is_less, __VA_ARGS__)
2652
2672#define is_less_or_equal_(...) __CMD_ASSERT_ARGS(is_less_or_equal, __VA_ARGS__)
2673
2691#define is_NaN_(...) __CMD_ASSERT_ARGS(is_NaN, __VA_ARGS__)
2692
2710#define is_negative_(...) __CMD_ASSERT_ARGS(is_negative, __VA_ARGS__)
2711
2729#define is_not_empty_(...) __CMD_ASSERT_ARGS(is_not_empty, __VA_ARGS__)
2730
2747#define is_not_instance_of_(type_t, ...) __CMD_ASSERT_ARGS(is_not_instance_of<type_t>, __VA_ARGS__)
2748
2767#define is_not_null_(...) __CMD_ASSERT_ARGS(is_not_null, __VA_ARGS__)
2768
2786#define is_not_zero_(...) __CMD_ASSERT_ARGS(is_not_zero, __VA_ARGS__)
2787
2806#define is_null_(...) __CMD_ASSERT_ARGS(is_null, __VA_ARGS__)
2807
2825#define is_positive_(...) __CMD_ASSERT_ARGS(is_positive, __VA_ARGS__)
2826
2844#define is_true_(...) __CMD_ASSERT_ARGS(is_true, __VA_ARGS__)
2845
2863#define is_zero_(...) __CMD_ASSERT_ARGS(is_zero, __VA_ARGS__)
2864
2876#define succeed_(...) __CMD_ASSERT_ARGS(succeed, __VA_ARGS__)
2877
2895#define throws_(exception_t, ...) __CMD_ASSERT_ARGS(throws<exception_t>, __VA_ARGS__)
2896
2913#define throws_any_(...) __CMD_ASSERT_ARGS(throws_any, __VA_ARGS__)
Contains xtd::tunit::assert class.
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:37
static stack_frame empty() noexcept
Return an empty stack frame.
Exception thow when an assertion failed.
Definition assert_error.h:17
The assert class contains a collection of static methods that implement the most common assertions us...
Definition assert.h:30
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:86
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:1932
static void is_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
Definition assert.h:1789
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:1729
static void are_equal(float expected, float actual, float tolerance)
Asserts that two type are equal.
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:1962
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:805
static void is_not_null(std::nullptr_t pointer, const xtd::ustring &message)
Asserts that the pointer is not null.
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:340
static void is_negative(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is negative.
Definition assert.h:1205
static void is_NaN(double value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a value is NaN.
static void is_null(const std::shared_ptr< pointer_t > &pointer)
Asserts that the pointer is null.
Definition assert.h:1949
static void is_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
static void is_NaN(long double value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a value is NaN.
static void is_not_null(std::nullptr_t pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
static void is_null(std::nullptr_t pointer, const xtd::ustring &message)
Asserts that the pointer is null.
static void are_same(const expected_t &expected, const actual_t &actual)
Asserts that two objects do refer to differents objects.
Definition assert.h:406
static void are_equal(double expected, double actual, double tolerance, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
static void throws_any(const std::function< void()> &statement, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the staement does not throw an exception.
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:1544
static void is_null(const std::unique_ptr< pointer_t > &pointer)
Asserts that the pointer is null.
Definition assert.h:1892
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:1601
static void is_null(const std::weak_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition assert.h:2035
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:871
static void is_null(const std::weak_ptr< pointer_t > &pointer)
Asserts that the pointer is null.
Definition assert.h:2007
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:386
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:739
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:1401
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:1005
static void is_not_zero(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is not zero.
Definition assert.h:1742
static void is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that collection contains an item.
Definition assert.h:611
static void is_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is zero.
Definition assert.h:2228
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:1756
static void is_not_null(const std::unique_ptr< pointer_t > &pointer)
Asserts that the pointer is not null.
Definition assert.h:1504
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:1631
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:1818
static void is_null(const pointer_t *pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition assert.h:1803
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:1875
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:818
static void is_false(bool condition)
Asserts that ta condition is false.
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:285
static void is_null(std::nullptr_t pointer)
Asserts that the pointer is null.
static void are_equal(float expected, float actual, float tolerance, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
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:452
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:914
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:883
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:792
static void is_true(bool condition, const xtd::ustring &message)
Asserts that a condition is true.
static void contains(const item_t &item, const collection_t &collection, const xtd::ustring &message)
Asserts that collection contains an item.
Definition assert.h:496
static void is_not_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is not null.
static void is_not_null(const pointer_t *pointer, const xtd::ustring &message)
Asserts that the pointer is not null.
Definition assert.h:1415
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:979
static void does_not_throw(const std::function< void()> &statement, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the staement does not throw an exception.
static void is_zero(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is zero.
Definition assert.h:2241
static void are_equal(float expected, float actual, float tolerance, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
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:938
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:751
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:638
static void is_null(const std::optional< optional_t > &opt, const xtd::ustring &message)
Asserts that the optional is std::nullopt.
Definition assert.h:1861
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:1330
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:859
static void is_empty(const value_t &value, const xtd::ustring &message)
Asserts that collection contains an item.
Definition assert.h:624
static void is_true(bool condition, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a condition is true.
static void are_equal(long double expected, long double actual, long double tolerance)
Asserts that two type are equal.
static void is_not_null(const std::optional< optional_t > &opt)
Asserts that the optional is not std::nullopt.
Definition assert.h:1447
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:951
static void is_NaN(double value)
that a value is NaN.
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:1587
static void is_NaN(long double value, const xtd::diagnostics::stack_frame &stack_frame)
that a value is NaN.
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:1019
static void are_equal(double expected, double actual, double tolerance, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
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:2148
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:1517
static void does_not_throw(const std::function< void()> &statement, const xtd::ustring &message)
Asserts that the staement does not throw an exception.
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:73
static void is_not_null(std::nullptr_t pointer)
Asserts that the pointer is not null.
static void are_equal(long double expected, long double actual, long double tolerance, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
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:1530
static void is_not_zero(const value_t &value)
Asserts that ta condition is not zero.
Definition assert.h:1716
static void is_false(bool condition, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a condition is false.
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:510
static void are_equal(long double expected, long double actual, long double tolerance, const xtd::ustring &message)
Asserts that two type are equal.
static void are_equal(float expected, float &actual, float tolerance, const xtd::ustring &message)
Asserts that two type are equal.
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:2255
static void is_positive(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that ta condition is positive.
Definition assert.h:2121
static void does_not_throw(const std::function< void()> &statement, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the staement does not throw an exception.
static void is_true(bool condition, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a condition is true.
static void throws_any(const std::function< void()> &statement)
Asserts that the staement does not throw an exception.
static void is_NaN(float value, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a value is NaN.
static void are_equal(long double expected, long double actual, long double tolerance, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that two type are equal.
static void is_negative(const value_t &value)
Asserts that ta condition is negative.
Definition assert.h:1192
static void is_positive(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is positive.
Definition assert.h:2134
static void is_false(bool condition, const xtd::ustring &message)
Asserts that a condition is false.
static void is_negative(const value_t &value, const xtd::ustring &message)
Asserts that ta condition is negative.
Definition assert.h:1218
static void is_empty(const value_t &value)
Asserts that collection contains an item.
Definition assert.h:598
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:1290
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:1989
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:2021
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:992
static void is_null(const std::unique_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition assert.h:1918
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:370
static void is_NaN(float value, const xtd::diagnostics::stack_frame &stack_frame)
that a value is NaN.
static void is_true(bool condition)
Asserts that ta condition is true.
static void is_NaN(long double value)
that a value is NaN.
static void is_NaN(double value, const xtd::ustring &message)
Asserts that a value is NaN.
static void is_not_empty(const value_t &value, const xtd::ustring &message)
Asserts that collection does not contain any item.
Definition assert.h:1276
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:1263
static void does_not_throw(const std::function< void()> &statement)
Asserts that the staement does not throw an exception.
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:1574
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:764
static void is_NaN(float value, const xtd::ustring &message)
Asserts that a value is NaN.
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:1905
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:1658
static void is_not_empty(const value_t &value)
Asserts that collection oes not contain any item.
Definition assert.h:1250
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:483
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:61
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:1487
static void is_not_null(const pointer_t *pointer)
Asserts that the pointer is not null.
Definition assert.h:1387
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:2050
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:1232
static void is_positive(const value_t &value)
Asserts that ta condition is positive.
Definition assert.h:2108
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:926
static void throws_any(const std::function< void()> &statement, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the staement does not throw an exception.
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:1354
static void is_null(const pointer_t *pointer)
Asserts that the pointer is null.
Definition assert.h:1775
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:727
static void is_zero(const value_t &value)
Asserts that ta condition is zero.
Definition assert.h:2215
static void is_not_null(const std::weak_ptr< pointer_t > &pointer)
Asserts that the pointer is not null.
Definition assert.h:1618
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:1848
static void are_equal(double expected, double actual, double tolerance)
Asserts that two type are equal.
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:1342
static void is_null(const std::shared_ptr< pointer_t > &pointer, const xtd::ustring &message)
Asserts that the pointer is null.
Definition assert.h:1975
static void are_equal(const expected_t &expected, const actual_t &actual)
Asserts that two type are equal.
Definition assert.h:49
static void are_not_equal(const expected_t &expected, const actual_t &actual)
Asserts that two type are not equal.
Definition assert.h:273
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:436
static void is_not_null(const std::shared_ptr< pointer_t > &pointer)
Asserts that the pointer is not null.
Definition assert.h:1561
static void is_null(const std::optional< optional_t > &opt)
Asserts that the optional is std::nullopt.
Definition assert.h:1835
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:297
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:1460
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:1430
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:310
static void is_NaN(float value)
that a value is NaN.
static void is_false(bool condition, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that a condition is false.
static void is_NaN(long double value, const xtd::ustring &message)
Asserts that a value is NaN.
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:355
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:1367
static void is_NaN(double value, const xtd::diagnostics::stack_frame &stack_frame)
that a value is NaN.
static void throws_any(const std::function< void()> &statement, const xtd::ustring &message)
Asserts that the staement does not throw an exception.
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:421
static void are_equal(double expected, double actual, double tolerance, const xtd::ustring &message)
Asserts that two type are equal.
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:896
static void is_null(std::nullptr_t pointer, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
Asserts that the pointer is null.
static void contains(const item_t &item, const collection_t &collection)
Asserts that collection contains an item.
Definition assert.h:470
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:1644
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:1473
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:832
The base class for assert.
Definition base_assert.h:29
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
#define tunit_export_
Define shared library export.
Definition tunit_export.h:13
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.h:45
char8_t char8
Represents a 8-bit unicode character.
Definition types.h:64
char16_t char16
Represents a 16-bit unicode character.
Definition types.h:76
char32_t char32
Represents a 32-bit unicode character.
Definition types.h:87
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:1080
@ e
The E key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10