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 <cassert>
7#include <functional>
8
10#if defined(assert)
11#undef assert
12#endif
14
16namespace xtd {
18 namespace tunit {
31 class tunit_export_ assert final : public base_assert {
32 public:
34 assert() = delete;
36
38
50 template<typename expected_t, typename actual_t>
51 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);}
63 template<typename expected_t, typename actual_t>
64 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 {
65 if (equals(expected, actual)) succeed(message, stack_frame);
66 else fail(to_string(expected), to_string(actual), message, stack_frame);
67 }
68
70 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;
71 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;
72 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;
73 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;
74 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;
75 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;
76 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;
77 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;
91 static auto are_equal(float expected, float actual, float tolerance, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
105 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;
118 static auto are_equal(double expected, double actual, double tolerance, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
132 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;
145 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;
159 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;
160
171 template<typename expected_t, typename actual_t>
172 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);}
184 template<typename expected_t, typename actual_t>
185 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 {
186 if (!equals(expected, actual)) succeed(message, stack_frame);
187 else fail("not " + to_string(expected), to_string(actual), message, stack_frame);
188 }
189
191 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;
192 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;
193 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;
194 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;
195 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;
197
211 template<typename expected_t, typename actual_t>
212 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);}
227 template<typename expected_t, typename actual_t>
228 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 {
229 if (!equals(&expected, &actual)) succeed(message, stack_frame);
230 else fail("not same as " + to_string(expected), to_string(actual), message, stack_frame);
231 }
232
246 template<typename expected_t, typename actual_t>
247 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);}
262 template<typename expected_t, typename actual_t>
263 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 {
264 if (equals(&expected, &actual)) succeed(message, stack_frame);
265 else fail("same as " + to_string(expected), to_string(actual), message, stack_frame);
266 }
267
279 template<typename item_t, typename collection_t>
280 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);}
293 template<typename item_t, typename collection_t>
294 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 {
295 auto result = std::find(collection.begin(), collection.end(), item);
296 if (result != collection.end()) succeed(message, stack_frame);
297 else fail("collection containing " + to_string(item), join_items(collection), message, stack_frame);
298 }
299
301 template<typename item_t, typename value_t>
302 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);}
303 template<typename item_t, typename value_t>
304 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 {
305 auto result = std::find(values.begin(), values.end(), item);
306 if (result != values.end()) succeed(message, stack_frame);
307 else fail("collection containing " + to_string(item), join_items(values), message, stack_frame);
308 }
309 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;
310 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;
311 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;
312 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;
313 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;
315
326 static auto does_not_throw(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
338 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;
339
351 template<typename value_t>
352 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);}
365 template<typename value_t>
366 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 {
367 if (empty(value)) succeed(message, stack_frame);
368 else fail("collection <empty>", join_items(value), message, stack_frame);
369 }
370
372 template<typename value_t>
373 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);}
374 template<typename value_t>
375 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 {
376 if (empty(values)) succeed(message, stack_frame);
377 else fail("collection <empty>", join_items(values), message, stack_frame);
378 }
379 static auto is_empty(const char* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
380 static auto is_empty(const char8* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
381 static auto is_empty(const char16* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
382 static auto is_empty(const char32* value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
383 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;
385
397 static auto is_false(bool condition, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
410 static auto is_false(bool condition, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
411
422 template<typename value1_t, typename value2_t>
423 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);}
435 template<typename value1_t, typename value2_t>
436 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 {
437 if (val1 > val2) succeed(message, stack_frame);
438 else fail("greater than " + to_string(val2), to_string(val1), message, stack_frame);
439 }
440
442 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;
443 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;
444 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;
445 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;
446 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;
448
460 template<typename value1_t, typename value2_t>
461 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);}
474 template<typename value1_t, typename value2_t>
475 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 {
476 if (val1 >= val2) succeed(message, stack_frame);
477 else fail("greater than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
478 }
479
481 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;
482 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;
483 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;
484 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;
485 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;
487
498 template<typename type_t, typename value_t>
499 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);}
511 template<typename type_t, typename value_t>
512 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 {
513 const type_t* instance = dynamic_cast<const type_t*>(&value);
514 if (instance != nullptr) succeed(message, stack_frame);
515 else fail("instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
516 }
517
528 template<typename value1_t, typename value2_t>
529 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);}
541 template<typename value1_t, typename value2_t>
542 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 {
543 if (val1 < val2) succeed(message, stack_frame);
544 else fail("less than " + to_string(val2), to_string(val1), message, stack_frame);
545 }
546
548 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;
549 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;
550 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;
551 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;
552 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;
554
566 template<typename value1_t, typename value2_t>
567 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);}
580 template<typename value1_t, typename value2_t>
581 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 {
582 if (val1 <= val2) succeed(message, stack_frame);
583 else fail("less than or equal to " + to_string(val2), to_string(val1), message, stack_frame);
584 }
585
587 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;
588 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;
589 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;
590 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;
591 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;
593
605 static auto is_NaN(double value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
618 static auto is_NaN(double value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
630 static auto is_NaN(long double value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
643 static auto is_NaN(long double value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
655 static auto is_NaN(float value, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
668 static auto is_NaN(float value, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
669
681 template<typename value_t>
682 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);}
695 template<typename value_t>
696 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 {
697 if (value < 0) succeed(message, stack_frame);
698 else fail("negative", to_string(value), message, stack_frame);
699 }
700
712 template<typename value_t>
713 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);}
726 template<typename value_t>
727 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 {
728 if (!empty(value)) succeed(message, stack_frame);
729 else fail("collection not <empty>", "<empty>", message, stack_frame);
730 }
731
733 template<typename value_t>
734 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);}
735 template<typename value_t>
736 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 {
737 if (!empty(values)) succeed(message, stack_frame);
738 else fail("collection not <empty>", "<empty>", message, stack_frame);
739 }
740 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;
741 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;
742 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;
743 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;
744 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;
746
757 template<typename type_t, typename value_t>
758 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);}
770 template<typename type_t, typename value_t>
771 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 {
772 const type_t* instance = dynamic_cast<const type_t*>(&value);
773 if (instance == nullptr) succeed(message, stack_frame);
774 else fail("not instance of <" + typeof_<type_t>().full_name() + ">", "<" + typeof_(value).full_name() + ">", message, stack_frame);
775 }
776
789 template<typename pointer_t>
804 template<typename pointer_t>
805 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 {
806 if (pointer != nullptr) succeed(message, stack_frame);
807 else fail("not null", "null", message, stack_frame);
808 }
809
820 template<typename optional_t>
821 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);}
834 template<typename optional_t>
835 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 {
836 if (opt != std::nullopt) succeed(message, stack_frame);
837 else fail("not null", "null", message, stack_frame);
838 }
839
850 template<typename pointer_t>
864 template<typename pointer_t>
866 if (pointer != nullptr) succeed(message, stack_frame);
867 else fail("not null", "null", message, stack_frame);
868 }
869
880 template<typename pointer_t>
894 template<typename pointer_t>
896 if (pointer != nullptr) succeed(message, stack_frame);
897 else fail("not null", "null", message, stack_frame);
898 }
899
910 template<typename pointer_t>
924 template<typename pointer_t>
926 if (pointer.owner_before(xtd::wptr<pointer_t> {}) || xtd::wptr<pointer_t> {}.owner_before(pointer)) succeed(message, stack_frame);
927 else fail("not null", "null", message, stack_frame);
928 }
929
938 static auto is_not_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
949 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;
950
962 template<typename value_t>
963 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);}
976 template<typename value_t>
977 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 {
978 if (value != static_cast<value_t>(0)) succeed(message, stack_frame);
979 else fail("not zero", "0", message, stack_frame);
980 }
981
994 template<typename pointer_t>
995 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);}
1009 template<typename pointer_t>
1010 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 {
1011 if (pointer == nullptr) succeed(message, stack_frame);
1012 else fail("null", "not null", message, stack_frame);
1013 }
1014
1025 template<typename optional_t>
1026 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);}
1039 template<typename optional_t>
1040 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 {
1041 if (opt == std::nullopt) succeed(message, stack_frame);
1042 else fail("null", "not null", message, stack_frame);
1043 }
1044
1055 template<typename pointer_t>
1069 template<typename pointer_t>
1071 if (pointer == nullptr) succeed(message, stack_frame);
1072 else fail("null", "not null", message, stack_frame);
1073 }
1074
1085 template<typename pointer_t>
1099 template<typename pointer_t>
1101 if (pointer == nullptr) succeed(message, stack_frame);
1102 else fail("null", "not null", message, stack_frame);
1103 }
1104
1116 template<typename pointer_t>
1131 template<typename pointer_t>
1133 if (!pointer.owner_before(xtd::wptr<pointer_t> {}) && !xtd::wptr<pointer_t> {}.owner_before(pointer)) succeed(message, stack_frame);
1134 else fail("null", "not null", message, stack_frame);
1135 }
1136
1145 static auto is_null(std::nullptr_t pointer, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1156 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;
1157
1169 template<typename value_t>
1170 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);}
1183 template<typename value_t>
1184 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 {
1185 if (value > 0) succeed(message, stack_frame);
1186 else fail("positive", to_string(value), message, stack_frame);
1187 }
1188
1200 static auto is_true(bool condition, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1213 static auto is_true(bool condition, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1214
1226 template<typename value_t>
1227 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);}
1240 template<typename value_t>
1241 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 {
1242 if (value == static_cast<value_t>(0)) succeed(message, stack_frame);
1243 else fail("zero", to_string(value), message, stack_frame);
1244 }
1245
1257 template<typename exception_t>
1258 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);}
1271 template<typename exception_t>
1272 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 {
1273 try {
1274 statement();
1275 fail("<" + typeof_<exception_t>().full_name() + ">", "<nothing>", message, stack_frame);
1276 } catch (const exception_t&) {
1277 succeed(message, stack_frame);
1278 } catch (const xtd::tunit::assert_error&) {
1279 throw;
1280 } catch (const std::exception& e) {
1281 fail("<" + typeof_<exception_t>().full_name() + ">", "<" + typeof_(e).full_name() + ">", message, stack_frame);
1282 } catch (...) {
1283 fail("<" + typeof_<exception_t>().full_name() + ">", "<exception>", message, stack_frame);
1284 }
1285 }
1286
1297 static auto throws_any(const std::function<void()>& statement, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) -> void;
1309 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;
1311
1312 private:
1313 template<typename collection_t>
1314 static auto empty(const collection_t collection) -> bool {return collection.begin() == collection.end();}
1315 };
1316 }
1317}
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:31
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:366
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:865
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:352
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:696
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:805
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:821
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:461
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:1184
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:995
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:1258
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:851
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:790
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:436
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:1170
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:64
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:911
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:475
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:713
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:1010
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:1086
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:263
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:542
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:1227
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:682
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:727
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:228
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:835
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:247
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:771
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:212
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:581
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:881
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:423
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:294
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:925
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:758
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:512
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:1117
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:1241
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:963
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:499
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:1040
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:1026
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:185
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:1132
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:280
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:977
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:1100
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:529
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:1070
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:567
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:51
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:1056
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:895
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:172
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