xtd 1.0.0
Loading...
Searching...
No Matches
assert.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "base_assert.hpp"
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
49 template<typename expected_t, typename actual_t>
50 static auto are_equal(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {are_equal(expected, actual, xtd::string::empty_string, stack_frame);}
62 template<typename expected_t, typename actual_t>
63 static auto are_equal(const expected_t& expected, const actual_t& actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
64 if (equals(expected, actual)) succeed(message, stack_frame);
65 else fail(to_string(expected), to_string(actual), message, stack_frame);
66 }
67
69 static auto are_equal(const char* expected, const char* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
70 static auto are_equal(const char8* expected, const char8* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
71 static auto are_equal(const char16* expected, const char16* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
72 static auto are_equal(const char32* expected, const char32* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
73 static auto are_equal(const wchar_t* expected, const wchar_t* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
74 static auto are_equal(float expected, float actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
75 static auto are_equal(double expected, double actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
76 static auto are_equal(long double expected, long double actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
90 static auto are_equal(float expected, float actual, float tolerance, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
104 static auto are_equal(float expected, float actual, float tolerance, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
117 static auto are_equal(double expected, double actual, double tolerance, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
131 static auto are_equal(double expected, double actual, double tolerance, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
144 static auto are_equal(long double expected, long double actual, long double tolerance, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
158 static auto are_equal(long double expected, long double actual, long double tolerance, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
159
170 template<typename expected_t, typename actual_t>
171 static auto are_not_equal(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {are_not_equal(expected, actual, xtd::string::empty_string, stack_frame);}
183 template<typename expected_t, typename actual_t>
184 static auto are_not_equal(const expected_t& expected, const actual_t& actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
185 if (!equals(expected, actual)) succeed(message, stack_frame);
186 else fail("not " + to_string(expected), to_string(actual), message, stack_frame);
187 }
188
190 static auto are_not_equal(const char* expected, const char* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
191 static auto are_not_equal(const char8* expected, const char8* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
192 static auto are_not_equal(const char16* expected, const char16* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
193 static auto are_not_equal(const char32* expected, const char32* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
194 static auto are_not_equal(const wchar_t* expected, const wchar_t* actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
196
210 template<typename expected_t, typename actual_t>
211 static auto are_not_same(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {are_not_same(expected, actual, xtd::string::empty_string, stack_frame);}
226 template<typename expected_t, typename actual_t>
227 static auto are_not_same(const expected_t& expected, const actual_t& actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
228 if (!equals(&expected, &actual)) succeed(message, stack_frame);
229 else fail("not same as " + to_string(expected), to_string(actual), message, stack_frame);
230 }
231
245 template<typename expected_t, typename actual_t>
246 static auto are_same(const expected_t& expected, const actual_t& actual, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {are_same(expected, actual, xtd::string::empty_string, stack_frame);}
261 template<typename expected_t, typename actual_t>
262 static auto are_same(const expected_t& expected, const actual_t& actual, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
263 if (equals(&expected, &actual)) succeed(message, stack_frame);
264 else fail("same as " + to_string(expected), to_string(actual), message, stack_frame);
265 }
266
278 template<typename item_t, typename collection_t>
279 static auto contains(const item_t& item, const collection_t& collection, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {contains(item, collection, xtd::string::empty_string, stack_frame);}
292 template<typename item_t, typename collection_t>
293 static auto contains(const item_t& item, const collection_t& collection, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
294 auto result = std::find(collection.begin(), collection.end(), item);
295 if (result != collection.end()) succeed(message, stack_frame);
296 else fail("collection containing " + to_string(item), join_items(collection), message, stack_frame);
297 }
298
300 template<typename item_t, typename value_t>
301 static auto contains(const item_t& item, const std::initializer_list<value_t>& values, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {contains(item, values, xtd::string::empty_string, stack_frame);}
302 template<typename item_t, typename value_t>
303 static auto contains(const item_t& item, const std::initializer_list<value_t>& values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
304 auto result = std::find(values.begin(), values.end(), item);
305 if (result != values.end()) succeed(message, stack_frame);
306 else fail("collection containing " + to_string(item), join_items(values), message, stack_frame);
307 }
308 static auto contains(char item, const char* values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
309 static auto contains(char8 item, const char8* values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
310 static auto contains(char16 item, const char16* values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
311 static auto contains(char32 item, const char32* values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
312 static auto contains(wchar_t item, const wchar_t* values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
314
325 static auto does_not_throw(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
337 static auto does_not_throw(const std::function<void()>& statement, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
338
350 template<typename value_t>
351 static auto is_empty(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_empty(value, xtd::string::empty_string, stack_frame);}
364 template<typename value_t>
365 static auto is_empty(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
366 if (empty(value)) succeed(message, stack_frame);
367 else fail("collection <empty>", join_items(value), message, stack_frame);
368 }
369
371 template<typename value_t>
372 static auto is_empty(const std::initializer_list<value_t>& values, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_empty(values, xtd::string::empty_string, stack_frame);}
373 template<typename value_t>
374 static auto is_empty(const std::initializer_list<value_t>& values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
375 if (empty(values)) succeed(message, stack_frame);
376 else fail("collection <empty>", join_items(values), message, stack_frame);
377 }
378 static auto is_empty(const char* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
379 static auto is_empty(const char8* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
380 static auto is_empty(const char16* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
381 static auto is_empty(const char32* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
382 static auto is_empty(const wchar_t* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
384
396 static auto is_false(bool condition, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
409 static auto is_false(bool condition, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
410
421 template<typename value1_t, typename value2_t>
422 static auto is_greater(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_greater(val1, val2, xtd::string::empty_string, stack_frame);}
434 template<typename value1_t, typename value2_t>
435 static auto is_greater(const value1_t& val1, const value2_t& val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
436 if (val1 > val2) succeed(message, stack_frame);
437 else fail("greater than " + to_string(val2), to_string(val1), message, stack_frame);
438 }
439
441 static auto is_greater(const char* val1, const char* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
442 static auto is_greater(const char8* val1, const char8* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
443 static auto is_greater(const char16* val1, const char16* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
444 static auto is_greater(const char32* val1, const char32* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
445 static auto is_greater(const wchar_t* val1, const wchar_t* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
447
459 template<typename value1_t, typename value2_t>
460 static auto is_greater_or_equal(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_greater_or_equal(val1, val2, xtd::string::empty_string, stack_frame);}
473 template<typename value1_t, typename value2_t>
474 static auto is_greater_or_equal(const value1_t& val1, const value2_t& val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
475 if (val1 >= val2) succeed(message, stack_frame);
476 else fail("greater than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
477 }
478
480 static auto is_greater_or_equal(const char* val1, const char* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
481 static auto is_greater_or_equal(const char8* val1, const char8* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
482 static auto is_greater_or_equal(const char16* val1, const char16* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
483 static auto is_greater_or_equal(const char32* val1, const char32* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
484 static auto is_greater_or_equal(const wchar_t* val1, const wchar_t* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
486
497 template<typename type_t, typename value_t>
498 static auto is_instance_of(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_instance_of<type_t>(value, xtd::string::empty_string, stack_frame);}
510 template<typename type_t, typename value_t>
511 static auto is_instance_of(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
512 const type_t* instance = dynamic_cast<const type_t*>(&value);
513 if (instance != nullptr) succeed(message, stack_frame);
514 else fail("instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
515 }
516
527 template<typename value1_t, typename value2_t>
528 static auto is_less(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_less(val1, val2, xtd::string::empty_string, stack_frame);}
540 template<typename value1_t, typename value2_t>
541 static auto is_less(const value1_t& val1, const value2_t& val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
542 if (val1 < val2) succeed(message, stack_frame);
543 else fail("less than " + to_string(val2), to_string(val1), message, stack_frame);
544 }
545
547 static auto is_less(const char* val1, const char* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
548 static auto is_less(const char8* val1, const char8* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
549 static auto is_less(const char16* val1, const char16* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
550 static auto is_less(const char32* val1, const char32* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
551 static auto is_less(const wchar_t* val1, const wchar_t* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
553
565 template<typename value1_t, typename value2_t>
566 static auto is_less_or_equal(const value1_t& val1, const value2_t& val2, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_less_or_equal(val1, val2, xtd::string::empty_string, stack_frame);}
579 template<typename value1_t, typename value2_t>
580 static auto is_less_or_equal(const value1_t& val1, const value2_t& val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
581 if (val1 <= val2) succeed(message, stack_frame);
582 else fail("less than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
583 }
584
586 static auto is_less_or_equal(const char* val1, const char* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
587 static auto is_less_or_equal(const char8* val1, const char8* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
588 static auto is_less_or_equal(const char16* val1, const char16* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
589 static auto is_less_or_equal(const char32* val1, const char32* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
590 static auto is_less_or_equal(const wchar_t* val1, const wchar_t* val2, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
592
604 static auto is_NaN(double value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
617 static auto is_NaN(double value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
629 static auto is_NaN(long double value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
642 static auto is_NaN(long double value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
654 static auto is_NaN(float value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
667 static auto is_NaN(float value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
668
680 template<typename value_t>
681 static auto is_negative(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_negative(value, xtd::string::empty_string, stack_frame);}
694 template<typename value_t>
695 static auto is_negative(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
696 if (value < 0) succeed(message, stack_frame);
697 else fail("negative", to_string(value), message, stack_frame);
698 }
699
711 template<typename value_t>
712 static auto is_not_empty(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_not_empty(value, xtd::string::empty_string, stack_frame);}
725 template<typename value_t>
726 static auto is_not_empty(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
727 if (!empty(value)) succeed(message, stack_frame);
728 else fail("collection not <empty>", "<empty>", message, stack_frame);
729 }
730
732 template<typename value_t>
733 static auto is_not_empty(const std::initializer_list<value_t>& values, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_not_empty(values, xtd::string::empty_string, stack_frame);}
734 template<typename value_t>
735 static auto is_not_empty(const std::initializer_list<value_t>& values, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
736 if (!empty(values)) succeed(message, stack_frame);
737 else fail("collection not <empty>", "<empty>", message, stack_frame);
738 }
739 static auto is_not_empty(const char* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
740 static auto is_not_empty(const char8* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
741 static auto is_not_empty(const char16* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
742 static auto is_not_empty(const char32* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
743 static auto is_not_empty(const wchar_t* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
745
756 template<typename type_t, typename value_t>
757 static auto is_not_instance_of(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_not_instance_of<type_t>(value, xtd::string::empty_string, stack_frame);}
769 template<typename type_t, typename value_t>
770 static auto is_not_instance_of(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
771 const type_t* instance = dynamic_cast<const type_t*>(&value);
772 if (instance == nullptr) succeed(message, stack_frame);
773 else fail("not instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
774 }
775
788 template<typename pointer_t>
803 template<typename pointer_t>
804 static auto is_not_null(const pointer_t* pointer, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
805 if (pointer != nullptr) succeed(message, stack_frame);
806 else fail("not null", "null", message, stack_frame);
807 }
808
819 template<typename optional_t>
820 static auto is_not_null(const std::optional<optional_t>& opt, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_not_null(opt, xtd::string::empty_string, stack_frame);}
833 template<typename optional_t>
834 static auto is_not_null(const std::optional<optional_t>& opt, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
835 if (opt != std::nullopt) succeed(message, stack_frame);
836 else fail("not null", "null", message, stack_frame);
837 }
838
849 template<typename pointer_t>
863 template<typename pointer_t>
865 if (pointer != nullptr) succeed(message, stack_frame);
866 else fail("not null", "null", message, stack_frame);
867 }
868
879 template<typename pointer_t>
893 template<typename pointer_t>
895 if (pointer != nullptr) succeed(message, stack_frame);
896 else fail("not null", "null", message, stack_frame);
897 }
898
909 template<typename pointer_t>
923 template<typename pointer_t>
925 if (pointer.owner_before(xtd::wptr<pointer_t> {}) || xtd::wptr<pointer_t> {}.owner_before(pointer)) succeed(message, stack_frame);
926 else fail("not null", "null", message, stack_frame);
927 }
928
937 static auto is_not_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
948 static auto is_not_null(std::nullptr_t pointer, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
949
961 template<typename value_t>
962 static auto is_not_zero(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_not_zero(value, xtd::string::empty_string, stack_frame);}
975 template<typename value_t>
976 static auto is_not_zero(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
977 if (value != static_cast<value_t>(0)) succeed(message, stack_frame);
978 else fail("not zero", "0", message, stack_frame);
979 }
980
993 template<typename pointer_t>
994 static auto is_null(const pointer_t* pointer, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_null(pointer, xtd::string::empty_string, stack_frame);}
1008 template<typename pointer_t>
1009 static auto is_null(const pointer_t* pointer, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
1010 if (pointer == nullptr) succeed(message, stack_frame);
1011 else fail("null", "not null", message, stack_frame);
1012 }
1013
1024 template<typename optional_t>
1025 static auto is_null(const std::optional<optional_t>& opt, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_null(opt, xtd::string::empty_string, stack_frame);}
1038 template<typename optional_t>
1039 static auto is_null(const std::optional<optional_t>& opt, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
1040 if (opt == std::nullopt) succeed(message, stack_frame);
1041 else fail("null", "not null", message, stack_frame);
1042 }
1043
1054 template<typename pointer_t>
1068 template<typename pointer_t>
1070 if (pointer == nullptr) succeed(message, stack_frame);
1071 else fail("null", "not null", message, stack_frame);
1072 }
1073
1084 template<typename pointer_t>
1098 template<typename pointer_t>
1100 if (pointer == nullptr) succeed(message, stack_frame);
1101 else fail("null", "not null", message, stack_frame);
1102 }
1103
1115 template<typename pointer_t>
1130 template<typename pointer_t>
1132 if (!pointer.owner_before(xtd::wptr<pointer_t> {}) && !xtd::wptr<pointer_t> {}.owner_before(pointer)) succeed(message, stack_frame);
1133 else fail("null", "not null", message, stack_frame);
1134 }
1135
1144 static auto is_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1155 static auto is_null(std::nullptr_t pointer, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1156
1168 template<typename value_t>
1169 static auto is_positive(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_positive(value, xtd::string::empty_string, stack_frame);}
1182 template<typename value_t>
1183 static auto is_positive(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
1184 if (value > 0) succeed(message, stack_frame);
1185 else fail("positive", to_string(value), message, stack_frame);
1186 }
1187
1199 static auto is_true(bool condition, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1212 static auto is_true(bool condition, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1213
1225 template<typename value_t>
1226 static auto is_zero(const value_t& value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {is_zero(value, xtd::string::empty_string, stack_frame);}
1239 template<typename value_t>
1240 static auto is_zero(const value_t& value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
1241 if (value == static_cast<value_t>(0)) succeed(message, stack_frame);
1242 else fail("zero", to_string(value), message, stack_frame);
1243 }
1244
1256 template<typename exception_t>
1257 static auto throws(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {throws<exception_t>(statement, xtd::string::empty_string, stack_frame);}
1270 template<typename exception_t>
1271 static auto throws(const std::function<void()>& statement, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void {
1272 try {
1273 statement();
1274 fail("<" + typeof_<exception_t>().full_name() + ">", "<nothing>", message, stack_frame);
1275 } catch (const exception_t&) {
1276 succeed(message, stack_frame);
1277 } catch (const xtd::tunit::assert_error&) {
1278 throw;
1279 } catch (const std::exception& e) {
1280 fail("<" + typeof_<exception_t>().full_name() + ">", "<" + typeof_(e).full_name() + ">", message, stack_frame);
1281 } catch (...) {
1282 fail("<" + typeof_<exception_t>().full_name() + ">", "<exception>", message, stack_frame);
1283 }
1284 }
1285
1296 static auto throws_any(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1308 static auto throws_any(const std::function<void()>& statement, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1310
1311 private:
1312 template<typename collection_t>
1313 static auto empty(const collection_t collection) -> bool {return collection.begin() == collection.end();}
1314 };
1315 }
1316}
Contains xtd::tunit::assert class.
static const basic_string empty_string
Definition basic_string.hpp:111
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:46
static auto current(const xtd::diagnostics::source_location &value=xtd::diagnostics::source_location::current()) noexcept -> xtd::diagnostics::stack_frame
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
Exception thow when an assertion failed.
Definition assert_error.hpp:17
The assert class contains a collection of static methods that implement the most common assertions us...
Definition assert.hpp:30
static auto are_equal(float expected, float actual, float tolerance, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
static auto is_empty(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection contains an item.
Definition assert.hpp:365
static auto is_not_null(const xtd::uptr< pointer_t > &pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:864
static auto is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection contains an item.
Definition assert.hpp:351
static auto is_negative(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is negative.
Definition assert.hpp:695
static auto is_not_null(const pointer_t *pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:804
static auto is_not_null(const std::optional< optional_t > &opt, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the optional is not std::nullopt.
Definition assert.hpp:820
static auto does_not_throw(const std::function< void()> &statement, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the staement does not throw an exception.
static auto is_greater_or_equal(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is greater than or equal to the second value.
Definition assert.hpp:460
static auto is_positive(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is positive.
Definition assert.hpp:1183
static auto is_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:994
static auto throws(const std::function< void()> &statement, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the statement throws a particular exception when called.
Definition assert.hpp:1257
static auto is_not_null(const xtd::uptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:850
static auto is_not_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:789
static auto is_greater(const value1_t &val1, const value2_t &val2, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is greater than the second value.
Definition assert.hpp:435
static auto are_equal(double expected, double actual, double tolerance, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
static auto is_positive(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is positive.
Definition assert.hpp:1169
static auto are_equal(const expected_t &expected, const actual_t &actual, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
Definition assert.hpp:63
static auto is_not_null(const xtd::wptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:910
static auto is_greater_or_equal(const value1_t &val1, const value2_t &val2, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is greater than or equal to the second value.
Definition assert.hpp:474
static auto is_not_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection does not contain any item.
Definition assert.hpp:712
static auto is_null(const pointer_t *pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1009
static auto does_not_throw(const std::function< void()> &statement, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the staement does not throw an exception.
static auto is_NaN(double value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a value is NaN.
static auto is_NaN(float value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a value is NaN.
static auto is_null(const xtd::sptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1085
static auto are_same(const expected_t &expected, const actual_t &actual, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two objects do refer to differents objects.
Definition assert.hpp:262
static auto is_less(const value1_t &val1, const value2_t &val2, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is is_less than the second value.
Definition assert.hpp:541
static auto are_equal(float expected, float actual, float tolerance, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
static auto is_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is zero.
Definition assert.hpp:1226
static auto is_negative(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is negative.
Definition assert.hpp:681
static auto is_not_empty(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection does not contain any item.
Definition assert.hpp:726
static auto are_not_same(const expected_t &expected, const actual_t &actual, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two objects do refer to differents objects.
Definition assert.hpp:227
static auto is_not_null(const std::optional< optional_t > &opt, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the optional is not std::nullopt.
Definition assert.hpp:834
static auto are_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two objects do refer to differents objects.
Definition assert.hpp:246
static auto is_not_instance_of(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that an object is not of the type supplied or a derived type.
Definition assert.hpp:770
static auto is_NaN(double value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
that a value is NaN.
static auto are_not_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two objects do refer to differents objects.
Definition assert.hpp:211
static auto throws_any(const std::function< void()> &statement, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the staement does not throw an exception.
static auto are_equal(double expected, double actual, double tolerance, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
static auto is_true(bool condition, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a condition is true.
static auto is_less_or_equal(const value1_t &val1, const value2_t &val2, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is is_less than or equal to the second value.
Definition assert.hpp:580
static auto is_not_null(const xtd::sptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:880
static auto are_equal(long double expected, long double actual, long double tolerance, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
static auto is_greater(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is greater than the second value.
Definition assert.hpp:422
static auto contains(const item_t &item, const collection_t &collection, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection contains an item.
Definition assert.hpp:293
static auto is_not_null(const xtd::wptr< pointer_t > &pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:924
static auto is_not_instance_of(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that an object is not of the type supplied or a derived type.
Definition assert.hpp:757
static auto is_not_null(std::nullptr_t pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
static auto is_instance_of(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that an object is of the type supplied or a derived type.
Definition assert.hpp:511
static auto is_null(const xtd::wptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1116
static auto is_zero(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is zero.
Definition assert.hpp:1240
static auto is_false(bool condition, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a condition is false.
static auto is_not_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is not zero.
Definition assert.hpp:962
static auto is_true(bool condition, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a condition is true.
static auto is_instance_of(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that an object is of the type supplied or a derived type.
Definition assert.hpp:498
static auto is_null(const std::optional< optional_t > &opt, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the optional is std::nullopt.
Definition assert.hpp:1039
static auto is_not_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
static auto is_null(const std::optional< optional_t > &opt, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the optional is std::nullopt.
Definition assert.hpp:1025
static auto is_NaN(long double value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a value is NaN.
static auto are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are not equal.
Definition assert.hpp:184
static auto is_false(bool condition, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a condition is false.
static auto is_null(const xtd::wptr< pointer_t > &pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1131
static auto is_null(std::nullptr_t pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
static auto contains(const item_t &item, const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection contains an item.
Definition assert.hpp:279
static auto is_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
static auto is_not_zero(const value_t &value, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is not zero.
Definition assert.hpp:976
static auto is_null(const xtd::sptr< pointer_t > &pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1099
static auto is_less(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is is_less than the second value.
Definition assert.hpp:528
static auto is_null(const xtd::uptr< pointer_t > &pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1069
static auto is_less_or_equal(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is is_less than or equal to the second value.
Definition assert.hpp:566
static auto are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
Definition assert.hpp:50
static auto is_null(const xtd::uptr< pointer_t > &pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:1055
static auto is_not_null(const xtd::sptr< pointer_t > &pointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:894
static auto are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are not equal.
Definition assert.hpp:171
static auto throws_any(const std::function< void()> &statement, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the staement does not throw an exception.
static auto is_NaN(long double value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
that a value is NaN.
static auto are_equal(long double expected, long double actual, long double tolerance, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
static auto is_NaN(float value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
that a value is NaN.
The base class for assert.
Definition base_assert.hpp:33
static auto to_string(const value_t &value) -> xtd::string
Convert specified value to xtd::string.
Definition base_assert.hpp:153
static auto join_items(const collection_t &collection) -> xtd::string
Join specified collection into xtd::string.
Definition base_assert.hpp:164
static auto succeed(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Generates a success with a generic message. This is used by the other assert functions.
static auto fail(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
static auto equals(const value_a_t &value_a, const value_b_t &value_b) -> bool
Determines if specified values are equal.
Definition base_assert.hpp:179
#define tunit_export_
Define shared library export.
Definition tunit_export.hpp:13
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.hpp:24
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::weak_ptr< type_t > wptr
The xtd::uptr object is a weak pointer.
Definition wptr.hpp:17
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
@ e
The E key.
Definition console_key.hpp:96
The tunit namespace contains a unit test library.
Definition abort_error.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
auto to_string() const noexcept -> xtd::string override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:342
const type_t * pointer
Represents the read_only_span pointer type.
Definition read_only_span.hpp:63
constexpr auto is_empty() const noexcept -> bool
Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.
Definition read_only_span.hpp:209