41 template<
typename TExpected,
typename TActual>
54 template<
typename TExpected,
typename TActual>
67 template<
typename TExpected,
typename TActual>
68 static void are_equal(
const TExpected& expected,
const TActual& actual,
const std::string& message) {
are_equal(expected, actual, message,
line_info());}
81 template<
typename TExpected,
typename TActual>
83 if (actual == expected)
86 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
91 if (strcmp(actual, expected) == 0)
94 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
97 static void are_equal(
const char16_t* expected,
const char16_t* actual,
const std::string& message,
const tunit::line_info& line_info) {
98 if (std::u16string(actual) == std::u16string(expected))
101 base_assert::base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
104 static void are_equal(
const char32_t* expected,
const char32_t* actual,
const std::string& message,
const tunit::line_info& line_info) {
105 if (std::u32string(actual) == std::u32string(expected))
108 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
111 static void are_equal(
const wchar_t* expected,
const wchar_t* actual,
const std::string& message,
const tunit::line_info& line_info) {
112 if (wcscmp(actual, expected) == 0)
115 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
119 if (std::isnan(actual) && std::isnan(expected))
121 else if (actual == expected)
124 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
128 if (std::isnan(actual) && std::isnan(expected))
130 else if (actual == expected)
133 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
136 static void are_equal(
long double expected,
long double actual,
const std::string& message,
const tunit::line_info& line_info) {
137 if (std::isnan(actual) && std::isnan(expected))
139 else if (actual == expected)
142 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
185 static void are_equal(
float expected,
float& actual,
float tolerance,
const std::string& message) {
are_equal(expected, actual, tolerance, message, line_info());}
201 if (fabsf(expected - actual) <= fabsf(tolerance))
204 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
246 static void are_equal(
double expected,
double actual,
double tolerance,
const std::string& message) {
are_equal(expected, actual, tolerance, message, line_info());}
261 static void are_equal(
double expected,
double actual,
double tolerance,
const std::string& message,
const tunit::line_info& line_info) {
262 if (fabs(expected - actual) <= fabs(tolerance))
265 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
307 static void are_equal(
long double expected,
long double actual,
long double tolerance,
const std::string& message) {
are_equal(expected, actual, tolerance, message, line_info());}
322 static void are_equal(
long double expected,
long double actual,
long double tolerance,
const std::string& message,
const tunit::line_info& line_info) {
323 if (fabsl(expected - actual) <= fabsl(tolerance))
326 base_assert::fail(base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
338 template<
typename TExpected,
typename TActual>
351 template<
typename TExpected,
typename TActual>
364 template<
typename TExpected,
typename TActual>
365 static void are_not_equal(
const TExpected& expected,
const TActual& actual,
const std::string& message) {
are_not_equal(expected, actual, message, line_info());}
378 template<
typename TExpected,
typename TActual>
380 if (actual != expected)
383 base_assert::fail(
"not " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
388 if (strcmp(actual, expected) != 0)
391 base_assert::fail(
"not " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
395 if (std::u16string(actual) != std::u16string(expected))
398 base_assert::fail(
"not " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
402 if (std::u32string(actual) != std::u32string(expected))
405 base_assert::fail(
"not " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
409 if (wcscmp(actual, expected) != 0)
412 base_assert::fail(
"not " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
428 template<
typename TExpected,
typename TActual>
444 template<
typename TExpected,
typename TActual>
460 template<
typename TExpected,
typename TActual>
461 static void are_not_same(
const TExpected& expected,
const TActual& actual,
const std::string& message) {
are_not_same(expected, actual, message, line_info());}
477 template<
typename TExpected,
typename TActual>
479 if (&actual != &expected)
482 base_assert::fail(
"not same as " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
497 template<
typename TExpected,
typename TActual>
498 static void are_same(
const TExpected& expected,
const TActual& actual) {
are_same(expected, actual,
"", line_info());}
513 template<
typename TExpected,
typename TActual>
529 template<
typename TExpected,
typename TActual>
530 static void are_same(
const TExpected& expected,
const TActual& actual,
const std::string& message) {
are_same(expected, actual, message, line_info());}
546 template<
typename TExpected,
typename TActual>
547 static void are_same(
const TExpected& expected,
const TActual& actual,
const std::string& message,
const tunit::line_info& line_info) {
548 if (&actual == &expected)
551 base_assert::fail(
"same as " + base_assert::to_string(expected), base_assert::to_string(actual), message, line_info);
564 template<
typename TItem,
typename TCollection>
565 static void contains(
const TItem& item,
const TCollection& collection) {
contains(item, collection,
"", line_info());}
578 template<
typename TItem,
typename TCollection>
592 template<
typename TItem,
typename TCollection>
593 static void contains(
const TItem& item,
const TCollection& collection,
const std::string& message) {
contains(item, collection, message, line_info());}
607 template<
typename TItem,
typename TCollection>
608 static void contains(
const TItem& item,
const TCollection& collection,
const std::string& message,
const tunit::line_info& line_info) {
609 auto result = std::find(collection.begin(), collection.end(), item);
610 if (result != collection.end())
613 base_assert::fail(
"collection containing " + base_assert::to_string(item), base_assert::join_items(collection), message, line_info);
617 template<
typename TItem,
typename TValue>
618 static void contains(
const TItem& item,
const std::initializer_list<TValue>& values) {
contains(item, values,
"", line_info());}
619 template<
typename TItem,
typename TValue>
620 static void contains(
const TItem& item,
const std::initializer_list<TValue>& values,
const tunit::line_info& line_info) {
contains(item, values,
"", line_info);}
621 template<
typename TItem,
typename TValue>
622 static void contains(
const TItem& item,
const std::initializer_list<TValue>& values,
const std::string& message) {
contains(item, values, message, line_info());}
623 template<
typename TItem,
typename TValue>
624 static void contains(
const TItem& item,
const std::initializer_list<TValue>& values,
const std::string& message,
const tunit::line_info& line_info) {
625 auto result = std::find(values.begin(), values.end(), item);
626 if (result != values.end())
629 base_assert::fail(
"collection containing " + base_assert::to_string(item), base_assert::join_items(values), message, line_info);
632 static void contains(
char item,
const char* values,
const std::string& message,
const tunit::line_info& line_info) {
633 std::string s(values);
634 auto result = std::find(s.begin(), s.end(), item);
635 if (result != s.end())
638 base_assert::fail(
"collection containing " + base_assert::to_string(item), base_assert::join_items(s), message, line_info);
641 static void contains(char16_t item,
const char16_t* values,
const std::string& message,
const tunit::line_info& line_info) {
642 std::u16string s(values);
643 auto result = std::find(s.begin(), s.end(), item);
644 if (result != s.end())
647 base_assert::fail(
"collection containing " + base_assert::to_string(item), base_assert::join_items(s), message, line_info);
650 static void contains(char32_t item,
const char32_t* values,
const std::string& message,
const tunit::line_info& line_info) {
651 std::u32string s(values);
652 auto result = std::find(s.begin(), s.end(), item);
653 if (result != s.end())
656 base_assert::fail(
"collection containing " + base_assert::to_string(item), base_assert::join_items(s), message, line_info);
659 static void contains(
wchar_t item,
const wchar_t* values,
const std::string& message,
const tunit::line_info& line_info) {
660 std::wstring s(values);
661 auto result = std::find(s.begin(), s.end(), item);
662 if (result != s.end())
665 base_assert::fail(
"collection containing " + base_assert::to_string(item), base_assert::join_items(s), message, line_info);
719 }
catch (
const std::exception& e) {
720 base_assert::fail(
"No Exception to be thrown",
"<" + __tunit_demangle(
typeid(e).name()) +
">", message, line_info);
722 base_assert::fail(
"No Exception to be thrown",
"<exception>", message, line_info);
736 template<
typename TValue>
750 template<
typename TValue>
764 template<
typename TValue>
765 static void is_empty(
const TValue& value,
const std::string& message) {
is_empty(value, message, line_info());}
779 template<
typename TValue>
781 if (std::empty(value))
784 base_assert::fail(
"collection <empty>", base_assert::join_items(value), message, line_info);
788 template<
typename TValue>
789 static void is_empty(
const std::initializer_list<TValue>& value) {
is_empty(value,
"", line_info());}
790 template<
typename TValue>
792 template<
typename TValue>
793 static void is_empty(
const std::initializer_list<TValue>& value,
const std::string& message) {
is_empty(value, message, line_info());}
794 template<
typename TValue>
795 static void is_empty(
const std::initializer_list<TValue>& values,
const std::string& message,
const tunit::line_info& line_info) {
796 if (std::empty(values))
799 base_assert::fail(
"collection <empty>", base_assert::join_items(values), message, line_info);
803 std::string s(value);
807 base_assert::fail(
"collection <empty>", base_assert::join_items(s), message, line_info);
811 std::u16string s(value);
815 base_assert::fail(
"collection <empty>", base_assert::join_items(s), message, line_info);
819 std::u32string s(value);
823 base_assert::fail(
"collection <empty>", base_assert::join_items(s), message, line_info);
827 std::wstring s(value);
831 base_assert::fail(
"collection <empty>", base_assert::join_items(s), message, line_info);
871 static void is_false(
bool condition,
const std::string& message) {
is_false(condition, message, line_info());}
886 if (condition ==
false)
901 template<
typename TValue1,
typename TValue2>
914 template<
typename TValue1,
typename TValue2>
927 template<
typename TValue1,
typename TValue2>
928 static void is_greater(
const TValue1& val1,
const TValue2& val2,
const std::string& message) {
is_greater(val1, val2, message, line_info());}
941 template<
typename TValue1,
typename TValue2>
946 base_assert::fail(
"greater than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
951 if (strcmp(val1, val2) > 0)
954 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
957 static void is_greater(
const char16_t* val1,
const char16_t* val2,
const std::string& message,
const tunit::line_info& line_info) {
958 if (std::u16string(val1) > std::u16string(val2))
961 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
964 static void is_greater(
const char32_t* val1,
const char32_t* val2,
const std::string& message,
const tunit::line_info& line_info) {
965 if (std::u32string(val1) > std::u32string(val2))
968 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
971 static void is_greater(
const wchar_t* val1,
const wchar_t* val2,
const std::string& message,
const tunit::line_info& line_info) {
972 if (wcscmp(val1, val2) > 0)
975 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
989 template<
typename TValue1,
typename TValue2>
1003 template<
typename TValue1,
typename TValue2>
1017 template<
typename TValue1,
typename TValue2>
1032 template<
typename TValue1,
typename TValue2>
1037 base_assert::fail(
"greater than or equal to " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1042 if (strcmp(val1, val2) >= 0)
1045 base_assert::fail(
"greather than or equal to " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1049 if (std::u16string(val1) >= std::u16string(val2))
1052 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1056 if (std::u32string(val1) >= std::u32string(val2))
1059 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1063 if (wcscmp(val1, val2) >= 0)
1066 base_assert::fail(
"greather than or equal to " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1079 template<
typename Type,
typename TValue>
1080 static void is_instance_of(
const TValue& value) {is_instance_of<Type>(value,
"", line_info());}
1092 template<
typename Type,
typename TValue>
1105 template<
typename Type,
typename TValue>
1106 static void is_instance_of(
const TValue& value,
const std::string& message) {is_instance_of<Type>(value, message, line_info());}
1119 template<
typename Type,
typename TValue>
1121 if (dynamic_cast<const Type*>(&value) !=
nullptr)
1124 base_assert::fail(
"instance of <" + __tunit_demangle(
typeid(Type).name()) +
">",
"<" + __tunit_demangle(
typeid(value).name()) +
">", message, line_info);
1136 template<
typename TValue1,
typename TValue2>
1137 static void is_less(
const TValue1& val1,
const TValue2& val2) {
is_less(val1, val2,
"", line_info());}
1149 template<
typename TValue1,
typename TValue2>
1162 template<
typename TValue1,
typename TValue2>
1163 static void is_less(
const TValue1& val1,
const TValue2& val2,
const std::string& message) {
is_less(val1, val2, message, line_info());}
1176 template<
typename TValue1,
typename TValue2>
1181 base_assert::fail(
"less than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1186 static void is_less(
const char* val1,
const char* val2,
const std::string& message,
const tunit::line_info& line_info) {
1187 if (strcmp(val1, val2) < 0)
1190 base_assert::fail(
"less than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1193 static void is_less(
const char16_t* val1,
const char16_t* val2,
const std::string& message,
const tunit::line_info& line_info) {
1194 if (std::u16string(val1) < std::u16string(val2))
1197 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1200 static void is_less(
const char32_t* val1,
const char32_t* val2,
const std::string& message,
const tunit::line_info& line_info) {
1201 if (std::u32string(val1) < std::u32string(val2))
1204 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1207 static void is_less(
const wchar_t* val1,
const wchar_t* val2,
const std::string& message,
const tunit::line_info& line_info) {
1208 if (wcscmp(val1, val2) < 0)
1211 base_assert::fail(
"less than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1225 template<
typename TValue1,
typename TValue2>
1239 template<
typename TValue1,
typename TValue2>
1253 template<
typename TValue1,
typename TValue2>
1268 template<
typename TValue1,
typename TValue2>
1273 base_assert::fail(
"less than or equal to " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1278 if (strcmp(val1, val1) <= 0)
1281 base_assert::fail(
"less than or equal to " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1285 if (std::u16string(val1) < std::u16string(val2))
1288 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1292 if (std::u32string(val1) < std::u32string(val2))
1295 base_assert::fail(
"greather than " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1299 if (wcscmp(val1, val1) <= 0)
1302 base_assert::fail(
"less than or equal to " + base_assert::to_string(val2), base_assert::to_string(val1), message, line_info);
1342 static void is_NaN(
double value,
const std::string& message) {
is_NaN(value, message, line_info());}
1357 if (std::isnan(value))
1399 static void is_NaN(
long double value,
const std::string& message) {
is_NaN(value, message, line_info());}
1414 if (std::isnan(value))
1456 static void is_NaN(
float value,
const std::string& message) {
is_NaN(value, message, line_info());}
1471 if (std::isnan(value))
1487 template<
typename TValue>
1501 template<
typename TValue>
1515 template<
typename TValue>
1530 template<
typename TValue>
1535 base_assert::fail(
"negative", base_assert::to_string(value), message, line_info);
1548 template<
typename TValue>
1562 template<
typename TValue>
1576 template<
typename TValue>
1591 template<
typename TValue>
1593 if (!std::empty(value))
1600 template<
typename TValue>
1602 template<
typename TValue>
1604 template<
typename TValue>
1605 static void is_not_empty(
const std::initializer_list<TValue>& value,
const std::string& message) {
is_not_empty(value, message, line_info());}
1606 template<
typename TValue>
1608 if (!std::empty(value))
1615 if (!std::empty(std::string(value)))
1622 if (!std::empty(std::u16string(value)))
1629 if (!std::empty(std::u32string(value)))
1636 if (!std::empty(std::wstring(value)))
1652 template<
typename Type,
typename TValue>
1665 template<
typename Type,
typename TValue>
1678 template<
typename Type,
typename TValue>
1679 static void is_not_instance_of(
const TValue& value,
const std::string& message) {is_not_instance_of<Type>(value, message, line_info());}
1692 template<
typename Type,
typename TValue>
1694 if (dynamic_cast<const Type*>(&value) ==
nullptr)
1697 base_assert::fail(
"not instance of <" + __tunit_demangle(
typeid(Type).name()) +
">",
"<" + __tunit_demangle(
typeid(value).name()) +
">", message, line_info);
1711 template<
typename TPo
inter>
1726 template<
typename TPo
inter>
1741 template<
typename TPo
inter>
1757 template<
typename TPo
inter>
1759 if (pointer !=
nullptr)
1775 template<
typename TPo
inter>
1789 template<
typename TPo
inter>
1803 template<
typename TPo
inter>
1804 static void is_not_null(
const std::unique_ptr<TPointer>& pointer,
const std::string& message) {
is_not_null(pointer, message, line_info());}
1818 template<
typename TPo
inter>
1820 if (pointer !=
nullptr)
1836 template<
typename TPo
inter>
1850 template<
typename TPo
inter>
1864 template<
typename TPo
inter>
1865 static void is_not_null(
const std::shared_ptr<TPointer>& pointer,
const std::string& message) {
is_not_null(pointer, message, line_info());}
1879 template<
typename TPo
inter>
1881 if (pointer !=
nullptr)
1898 template<
typename TPo
inter>
1913 template<
typename TPo
inter>
1928 template<
typename TPo
inter>
1929 static void is_not_null(
const std::weak_ptr<TPointer>& pointer,
const std::string& message) {
is_not_null(pointer, message, line_info());}
1944 template<
typename TPo
inter>
2001 template<
typename TValue>
2015 template<
typename TValue>
2029 template<
typename TValue>
2044 template<
typename TValue>
2063 template<
typename TPo
inter>
2078 template<
typename TPo
inter>
2093 template<
typename TPo
inter>
2094 static void is_null(
const TPointer* pointer,
const std::string& message) {
is_null(pointer, message, line_info());}
2109 template<
typename TPo
inter>
2111 if (pointer ==
nullptr)
2127 template<
typename TPo
inter>
2128 static void is_null(
const std::unique_ptr<TPointer>& pointer) {
is_null(pointer,
"", line_info());}
2141 template<
typename TPo
inter>
2155 template<
typename TPo
inter>
2156 static void is_null(
const std::unique_ptr<TPointer>& pointer,
const std::string& message) {
is_null(pointer, message, line_info());}
2170 template<
typename TPo
inter>
2172 if (pointer ==
nullptr)
2188 template<
typename TPo
inter>
2189 static void is_null(
const std::shared_ptr<TPointer>& pointer) {
is_null(pointer,
"", line_info());}
2202 template<
typename TPo
inter>
2216 template<
typename TPo
inter>
2217 static void is_null(
const std::shared_ptr<TPointer>& pointer,
const std::string& message) {
is_null(pointer, message, line_info());}
2231 template<
typename TPo
inter>
2233 if (pointer ==
nullptr)
2250 template<
typename TPo
inter>
2251 static void is_null(
const std::weak_ptr<TPointer>& pointer) {
is_null(pointer,
"", line_info());}
2265 template<
typename TPo
inter>
2280 template<
typename TPo
inter>
2281 static void is_null(
const std::weak_ptr<TPointer>& pointer,
const std::string& message) {
is_null(pointer, message, line_info());}
2296 template<
typename TPo
inter>
2329 static void is_null(std::nullptr_t pointer,
const std::string& message) {
is_null(pointer, message, line_info());}
2353 template<
typename TValue>
2367 template<
typename TValue>
2381 template<
typename TValue>
2396 template<
typename TValue>
2401 base_assert::fail(
"positive", base_assert::to_string(value), message, line_info);
2440 static void is_true(
bool condition,
const std::string& message) {
is_true(condition, message, line_info());}
2455 if (condition ==
true)
2471 template<
typename TValue>
2485 template<
typename TValue>
2499 template<
typename TValue>
2500 static void is_zero(
const TValue& value,
const std::string& message) {
is_zero(value, message, line_info());}
2514 template<
typename TValue>
2532 template<
typename TException>
2533 static void throws(
const std::function<
void()>& statement) {throws<TException>(statement,
"", line_info());}
2546 template<
typename TException>
2547 static void throws(
const std::function<
void()>& statement,
const tunit::line_info& line_info) {throws<TException>(statement,
"", line_info);}
2560 template<
typename TException>
2561 static void throws(
const std::function<
void()>& statement,
const std::string& message) {throws<TException>(statement, message, line_info());}
2575 template<
typename TException>
2576 static void throws(
const std::function<
void()>& statement,
const std::string& message,
const tunit::line_info& line_info) {
2579 base_assert::fail(
"<" + __tunit_demangle(
typeid(TException).name()) +
">",
"<nothing>", message, line_info);
2580 }
catch (
const TException&) {
2584 }
catch (
const std::exception& e) {
2585 base_assert::fail(
"<" + __tunit_demangle(
typeid(TException).name()) +
">",
"<" + __tunit_demangle(
typeid(e).name()) +
">", message, line_info);
2587 base_assert::fail(
"<" + __tunit_demangle(
typeid(TException).name()) +
">",
"<exception>", message, line_info);
2624 static void throws_any(
const std::function<
void()>& statement,
const std::string& message) {
throws_any(statement, message, line_info());}
2653 #define __CMD_ASSERT_0_ARGS__(cmd) cmd(line_info_) 2654 #define __CMD_ASSERT_1_ARGS__(cmd, arg1) cmd(arg1, line_info_) 2655 #define __CMD_ASSERT_2_ARGS__(cmd, arg1, arg2) cmd(arg1, arg2, line_info_) 2656 #define __CMD_ASSERT_3_ARGS__(cmd, arg1, arg2, arg3) cmd(arg1, arg2, arg3, line_info_) 2657 #define __CMD_ASSERT_4_ARGS__(cmd, arg1, arg2, arg3, arg4) cmd(arg1, arg2, arg3, arg4) 2658 #define __GET_LAST_ARG(arg1, arg2, arg3, arg4, arg5, ...) arg5 2659 #define __CMD_ASSERT_MACRO_CHOOSER(cmd, ...) __GET_LAST_ARG(__VA_ARGS__, __CMD_ASSERT_4_ARGS__, __CMD_ASSERT_3_ARGS__, __CMD_ASSERT_2_ARGS__, __CMD_ASSERT_1_ARGS__, __CMD_ASSERT_0_ARGS__, ) 2660 #define __CMD_ASSERT_ARGS(cmd, ...) __CMD_ASSERT_MACRO_CHOOSER(cmd, __VA_ARGS__)(cmd, __VA_ARGS__) 2663 #define abort_() abort(line_info_) 2665 #define are_equal_(...) __CMD_ASSERT_ARGS(are_equal, __VA_ARGS__) 2667 #define are_not_equal_(...) __CMD_ASSERT_ARGS(are_not_equal, __VA_ARGS__) 2669 #define are_not_same_(...) __CMD_ASSERT_ARGS(are_not_same, __VA_ARGS__) 2671 #define are_same_(...) __CMD_ASSERT_ARGS(are_same, __VA_ARGS__) 2673 #define contains_(...) __CMD_ASSERT_ARGS(contains, __VA_ARGS__) 2675 #define does_not_throw_(...) __CMD_ASSERT_ARGS(does_not_throw, __VA_ARGS__) 2677 #define fail_() base_assert::fail(line_info_) 2679 #define ignore_() ignore(line_info_) 2681 #define is_empty_(...) __CMD_ASSERT_ARGS(is_empty, __VA_ARGS__) 2683 #define is_false_(...) __CMD_ASSERT_ARGS(is_false, __VA_ARGS__) 2685 #define is_greater_(...) __CMD_ASSERT_ARGS(is_greater, __VA_ARGS__) 2687 #define is_greater_or_equal_(...) __CMD_ASSERT_ARGS(is_greater_or_equal, __VA_ARGS__) 2689 #define is_instance_of_(Type, ...) __CMD_ASSERT_ARGS(is_instance_of<Type>, __VA_ARGS__) 2691 #define is_less_(...) __CMD_ASSERT_ARGS(is_less, __VA_ARGS__) 2693 #define is_less_or_equal_(...) __CMD_ASSERT_ARGS(is_less_or_equal, __VA_ARGS__) 2695 #define is_NaN_(...) __CMD_ASSERT_ARGS(is_NaN, __VA_ARGS__) 2697 #define is_negative_(...) __CMD_ASSERT_ARGS(is_negative, __VA_ARGS__) 2699 #define is_not_empty_(...) __CMD_ASSERT_ARGS(is_not_empty, __VA_ARGS__) 2701 #define is_not_instance_of_(Type, ...) __CMD_ASSERT_ARGS(is_not_instance_of<Type>, __VA_ARGS__) 2703 #define is_not_null_(...) __CMD_ASSERT_ARGS(is_not_null, __VA_ARGS__) 2705 #define is_not_zero_(...) __CMD_ASSERT_ARGS(is_not_zero, __VA_ARGS__) 2707 #define is_null_(...) __CMD_ASSERT_ARGS(is_null, __VA_ARGS__) 2709 #define is_positive_(...) __CMD_ASSERT_ARGS(is_positive, __VA_ARGS__) 2711 #define is_true_(...) __CMD_ASSERT_ARGS(is_true, __VA_ARGS__) 2713 #define is_zero_(...) __CMD_ASSERT_ARGS(is_zero, __VA_ARGS__) 2715 #define succeed_() succeed(line_info_) 2717 #define throws_(TException, ...) __CMD_ASSERT_ARGS(throws<TException>, __VA_ARGS__) 2719 #define throws_any_(...) __CMD_ASSERT_ARGS(throws_any, __VA_ARGS__) static void is_not_empty(const TValue &value, const tunit::line_info &line_info)
Asserts that collection does not contain any item.
Definition: assert.h:1563
static void is_NaN(double value, const tunit::line_info &line_info)
that a value is NaN.
Definition: assert.h:1329
static void are_equal(long double expected, long double actual, long double tolerance, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:293
static void is_negative(const TValue &value, const std::string &message)
Asserts that ta condition is negative.
Definition: assert.h:1516
static void is_positive(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that ta condition is positive.
Definition: assert.h:2397
static void is_positive(const TValue &value, const tunit::line_info &line_info)
Asserts that ta condition is positive.
Definition: assert.h:2368
static void is_zero(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that ta condition is zero.
Definition: assert.h:2515
static void are_equal(const TExpected &expected, const TActual &actual, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:55
static void is_null(std::nullptr_t pointer, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2318
static void is_NaN(float value)
that a value is NaN.
Definition: assert.h:1430
static void is_greater(const TValue1 &val1, const TValue2 &val2, const tunit::line_info &line_info)
Asserts that the first value is greater than the second value.
Definition: assert.h:915
static void is_instance_of(const TValue &value, const std::string &message)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:1106
static void is_NaN(long double value, const std::string &message)
Asserts that a value is NaN.
Definition: assert.h:1399
static void are_equal(float expected, float actual, float tolerance, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:171
static void is_negative(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that ta condition is negative.
Definition: assert.h:1531
static void is_NaN(float value, const std::string &message)
Asserts that a value is NaN.
Definition: assert.h:1456
static void is_not_null(const std::unique_ptr< TPointer > &pointer, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1790
static void are_not_equal(const TExpected &expected, const TActual &actual, const std::string &message, const tunit::line_info &line_info)
Asserts that two type are not equal.
Definition: assert.h:379
static void is_not_null(const std::shared_ptr< TPointer > &pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1880
static void is_empty(const TValue &value, const std::string &message)
Asserts that collection contains an item.
Definition: assert.h:765
static void is_false(bool condition, const tunit::line_info &line_info)
Asserts that a condition is false.
Definition: assert.h:858
static void throws_any(const std::function< void()> &statement, const tunit::line_info &line_info)
Asserts that the staement does not throw an exception.
Definition: assert.h:2612
static void are_equal(double expected, double actual, double tolerance, const std::string &message)
Asserts that two type are equal.
Definition: assert.h:246
static void is_null(const std::unique_ptr< TPointer > &pointer, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2142
static void is_false(bool condition)
Asserts that ta condition is false.
Definition: assert.h:845
static void is_less_or_equal(const TValue1 &val1, const TValue2 &val2, const std::string &message)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:1254
static void is_NaN(long double value)
that a value is NaN.
Definition: assert.h:1373
static void is_true(bool condition)
Asserts that ta condition is true.
Definition: assert.h:2414
static void is_null(const std::shared_ptr< TPointer > &pointer)
Asserts that the pointer is null.
Definition: assert.h:2189
static void throws_any(const std::function< void()> &statement)
Asserts that the staement does not throw an exception.
Definition: assert.h:2600
static void is_less(const TValue1 &val1, const TValue2 &val2)
Asserts that the first value is is_less than the second value.
Definition: assert.h:1137
static void is_less(const TValue1 &val1, const TValue2 &val2, const std::string &message, const tunit::line_info &line_info)
Asserts that the first value is is_less than the second value.
Definition: assert.h:1177
static void are_equal(long double expected, long double actual, long double tolerance, const std::string &message)
Asserts that two type are equal.
Definition: assert.h:307
static void throws_any(const std::function< void()> &statement, const std::string &message)
Asserts that the staement does not throw an exception.
Definition: assert.h:2624
static void is_not_null(std::nullptr_t pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1989
static void is_not_null(const std::weak_ptr< TPointer > &pointer)
Asserts that the pointer is not null.
Definition: assert.h:1899
static void is_not_empty(const TValue &value)
Asserts that collection oes not contain any item.
Definition: assert.h:1549
static void is_NaN(long double value, const tunit::line_info &line_info)
that a value is NaN.
Definition: assert.h:1386
static void is_not_null(const std::shared_ptr< TPointer > &pointer, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1851
static void contains(const TItem &item, const TCollection &collection, const std::string &message)
Asserts that collection contains an item.
Definition: assert.h:593
The assert class contains a collection of static methods that implement the most common assertions us...
Definition: assert.h:26
static void is_null(const TPointer *pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2110
static void is_null(const std::shared_ptr< TPointer > &pointer, const std::string &message)
Asserts that the pointer is null.
Definition: assert.h:2217
static void is_not_null(const std::unique_ptr< TPointer > &pointer)
Asserts that the pointer is not null.
Definition: assert.h:1776
static void is_null(const std::weak_ptr< TPointer > &pointer, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2266
static void is_not_zero(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that ta condition is not zero.
Definition: assert.h:2045
static void are_equal(long double expected, long double actual, long double tolerance, const std::string &message, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:322
static void is_instance_of(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:1120
static void is_greater(const TValue1 &val1, const TValue2 &val2, const std::string &message)
Asserts that the first value is greater than the second value.
Definition: assert.h:928
static void is_positive(const TValue &value, const std::string &message)
Asserts that ta condition is positive.
Definition: assert.h:2382
static void is_not_null(const std::weak_ptr< TPointer > &pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1945
static void is_zero(const TValue &value)
Asserts that ta condition is zero.
Definition: assert.h:2472
static void are_not_equal(const TExpected &expected, const TActual &actual)
Asserts that two type are not equal.
Definition: assert.h:339
static void is_NaN(float value, const std::string &message, const tunit::line_info &line_info)
Asserts that a value is NaN.
Definition: assert.h:1470
static void are_equal(double expected, double actual, double tolerance, const std::string &message, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:261
static void contains(const TItem &item, const TCollection &collection)
Asserts that collection contains an item.
Definition: assert.h:565
static void is_not_null(const TPointer *pointer, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1727
static void is_null(const std::unique_ptr< TPointer > &pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2171
static void is_null(const std::unique_ptr< TPointer > &pointer, const std::string &message)
Asserts that the pointer is null.
Definition: assert.h:2156
#define line_info_
Get tunit::line_info informations.
Definition: line_info.h:75
static void is_null(const std::weak_ptr< TPointer > &pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2297
static void is_not_null(const std::weak_ptr< TPointer > &pointer, const std::string &message)
Asserts that the pointer is not null.
Definition: assert.h:1929
static void is_greater_or_equal(const TValue1 &val1, const TValue2 &val2, const std::string &message, const tunit::line_info &line_info)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:1033
static void is_false(bool condition, const std::string &message, const tunit::line_info &line_info)
Asserts that a condition is false.
Definition: assert.h:885
static void is_null(std::nullptr_t pointer)
Asserts that the pointer is null.
Definition: assert.h:2307
static void are_not_same(const TExpected &expected, const TActual &actual)
Asserts that two objects do refer to differents objects.
Definition: assert.h:429
static void is_less(const TValue1 &val1, const TValue2 &val2, const tunit::line_info &line_info)
Asserts that the first value is is_less than the second value.
Definition: assert.h:1150
static void does_not_throw(const std::function< void()> &statement)
Asserts that the staement does not throw an exception.
Definition: assert.h:678
static void are_equal(double expected, double actual, double tolerance, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:232
static void is_greater_or_equal(const TValue1 &val1, const TValue2 &val2)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:990
static void contains(const TItem &item, const TCollection &collection, const std::string &message, const tunit::line_info &line_info)
Asserts that collection contains an item.
Definition: assert.h:608
static void is_positive(const TValue &value)
Asserts that ta condition is positive.
Definition: assert.h:2354
static void are_not_same(const TExpected &expected, const TActual &actual, const std::string &message)
Asserts that two objects do refer to differents objects.
Definition: assert.h:461
static void is_null(std::nullptr_t pointer, const std::string &message)
Asserts that the pointer is null.
Definition: assert.h:2329
static void is_not_empty(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that collection does not contain any item.
Definition: assert.h:1592
static void is_greater_or_equal(const TValue1 &val1, const TValue2 &val2, const std::string &message)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:1018
static void is_not_zero(const TValue &value)
Asserts that ta condition is not zero.
Definition: assert.h:2002
static void is_not_null(const TPointer *pointer, const std::string &message)
Asserts that the pointer is not null.
Definition: assert.h:1742
static void is_false(bool condition, const std::string &message)
Asserts that a condition is false.
Definition: assert.h:871
static void is_empty(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that collection contains an item.
Definition: assert.h:780
static void is_zero(const TValue &value, const tunit::line_info &line_info)
Asserts that ta condition is zero.
Definition: assert.h:2486
static void are_same(const TExpected &expected, const TActual &actual, const std::string &message)
Asserts that two objects do refer to differents objects.
Definition: assert.h:530
static void is_null(const std::unique_ptr< TPointer > &pointer)
Asserts that the pointer is null.
Definition: assert.h:2128
static void is_NaN(double value, const std::string &message, const tunit::line_info &line_info)
Asserts that a value is NaN.
Definition: assert.h:1356
static void are_not_equal(const TExpected &expected, const TActual &actual, const tunit::line_info &line_info)
Asserts that two type are not equal.
Definition: assert.h:352
static void is_negative(const TValue &value)
Asserts that ta condition is negative.
Definition: assert.h:1488
static void is_not_empty(const TValue &value, const std::string &message)
Asserts that collection does not contain any item.
Definition: assert.h:1577
static void is_not_zero(const TValue &value, const std::string &message)
Asserts that ta condition is not zero.
Definition: assert.h:2030
static void is_not_instance_of(const TValue &value, const std::string &message, const tunit::line_info &line_info)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1693
static void are_not_same(const TExpected &expected, const TActual &actual, const tunit::line_info &line_info)
Asserts that two objects do refer to differents objects.
Definition: assert.h:445
line_info information class is used to store current file, current line and current function informat...
Definition: line_info.h:13
Exception thow when an assertion failed.
Definition: assert_error.h:10
static void is_less_or_equal(const TValue1 &val1, const TValue2 &val2)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:1226
static void is_zero(const TValue &value, const std::string &message)
Asserts that ta condition is zero.
Definition: assert.h:2500
static void fail()
Throws an tunit::assertion_error exception.
Definition: base_assert.h:60
static void is_true(bool condition, const std::string &message)
Asserts that a condition is true.
Definition: assert.h:2440
static void is_instance_of(const TValue &value)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:1080
static void is_less(const TValue1 &val1, const TValue2 &val2, const std::string &message)
Asserts that the first value is is_less than the second value.
Definition: assert.h:1163
static void is_null(const std::weak_ptr< TPointer > &pointer)
Asserts that the pointer is null.
Definition: assert.h:2251
static void is_null(const std::shared_ptr< TPointer > &pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2232
static void are_equal(const TExpected &expected, const TActual &actual)
Asserts that two type are equal.
Definition: assert.h:42
static void are_same(const TExpected &expected, const TActual &actual, const tunit::line_info &line_info)
Asserts that two objects do refer to differents objects.
Definition: assert.h:514
static void contains(const TItem &item, const TCollection &collection, const tunit::line_info &line_info)
Asserts that collection contains an item.
Definition: assert.h:579
static void is_negative(const TValue &value, const tunit::line_info &line_info)
Asserts that ta condition is negative.
Definition: assert.h:1502
static void is_null(const TPointer *pointer)
Asserts that the pointer is null.
Definition: assert.h:2064
static void is_not_null(std::nullptr_t pointer)
Asserts that the pointer is not null.
Definition: assert.h:1955
static void does_not_throw(const std::function< void()> &statement, const std::string &message)
Asserts that the staement does not throw an exception.
Definition: assert.h:702
static void is_instance_of(const TValue &value, const tunit::line_info &line_info)
Asserts that an object is of the type supplied or a derived type.
Definition: assert.h:1093
static void is_empty(const TValue &value)
Asserts that collection contains an item.
Definition: assert.h:737
static void is_less_or_equal(const TValue1 &val1, const TValue2 &val2, const std::string &message, const tunit::line_info &line_info)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:1269
static void is_not_instance_of(const TValue &value, const tunit::line_info &line_info)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1666
Definition: base_assert.h:15
static void succeed()
Generates a success with a generic message.
Definition: base_assert.h:130
static void is_greater_or_equal(const TValue1 &val1, const TValue2 &val2, const tunit::line_info &line_info)
Asserts that the first value is greater than or equal to the second value.
Definition: assert.h:1004
static void is_NaN(double value)
that a value is NaN.
Definition: assert.h:1316
static void is_greater(const TValue1 &val1, const TValue2 &val2, const std::string &message, const tunit::line_info &line_info)
Asserts that the first value is greater than the second value.
Definition: assert.h:942
static void does_not_throw(const std::function< void()> &statement, const tunit::line_info &line_info)
Asserts that the staement does not throw an exception.
Definition: assert.h:690
The tunit namespace contains a unit test library.
Definition: abort_error.h:8
static void is_null(std::nullptr_t pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2341
static void is_not_instance_of(const TValue &value)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1653
static void are_not_equal(const TExpected &expected, const TActual &actual, const std::string &message)
Asserts that two type are not equal.
Definition: assert.h:365
static void are_same(const TExpected &expected, const TActual &actual, const std::string &message, const tunit::line_info &line_info)
Asserts that two objects do refer to differents objects.
Definition: assert.h:547
static void is_not_null(const std::shared_ptr< TPointer > &pointer, const std::string &message)
Asserts that the pointer is not null.
Definition: assert.h:1865
static void are_equal(float expected, float actual, float tolerance, const std::string &message, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:200
static void are_equal(float expected, float actual, float tolerance)
Asserts that two type are equal.
Definition: assert.h:157
static void throws_any(const std::function< void()> &statement, const std::string &message, const tunit::line_info &line_info)
Asserts that the staement does not throw an exception.
Definition: assert.h:2637
static void is_not_null(const TPointer *pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1758
static void is_null(const TPointer *pointer, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2079
static void is_NaN(double value, const std::string &message)
Asserts that a value is NaN.
Definition: assert.h:1342
static void is_NaN(long double value, const std::string &message, const tunit::line_info &line_info)
Asserts that a value is NaN.
Definition: assert.h:1413
static void are_equal(float expected, float &actual, float tolerance, const std::string &message)
Asserts that two type are equal.
Definition: assert.h:185
static void is_not_null(const std::shared_ptr< TPointer > &pointer)
Asserts that the pointer is not null.
Definition: assert.h:1837
static void are_equal(double expected, double actual, double tolerance)
Asserts that two type are equal.
Definition: assert.h:218
static void is_greater(const TValue1 &val1, const TValue2 &val2)
Asserts that the first value is greater than the second value.
Definition: assert.h:902
static void are_equal(const TExpected &expected, const TActual &actual, const std::string &message)
Asserts that two type are equal.
Definition: assert.h:68
static void is_not_zero(const TValue &value, const tunit::line_info &line_info)
Asserts that ta condition is not zero.
Definition: assert.h:2016
static void is_not_null(const std::unique_ptr< TPointer > &pointer, const std::string &message)
Asserts that the pointer is not null.
Definition: assert.h:1804
static void are_not_same(const TExpected &expected, const TActual &actual, const std::string &message, const tunit::line_info &line_info)
Asserts that two objects do refer to differents objects.
Definition: assert.h:478
static void is_empty(const TValue &value, const tunit::line_info &line_info)
Asserts that collection contains an item.
Definition: assert.h:751
static void is_null(const std::shared_ptr< TPointer > &pointer, const tunit::line_info &line_info)
Asserts that the pointer is null.
Definition: assert.h:2203
static void are_equal(const TExpected &expected, const TActual &actual, const std::string &message, const tunit::line_info &line_info)
Asserts that two type are equal.
Definition: assert.h:82
static void is_not_null(std::nullptr_t pointer, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1966
static void is_true(bool condition, const std::string &message, const tunit::line_info &line_info)
Asserts that a condition is true.
Definition: assert.h:2454
static void is_NaN(float value, const tunit::line_info &line_info)
that a value is NaN.
Definition: assert.h:1443
static void is_null(const TPointer *pointer, const std::string &message)
Asserts that the pointer is null.
Definition: assert.h:2094
static void are_equal(long double expected, long double actual, long double tolerance)
Asserts that two type are equal.
Definition: assert.h:279
static void is_null(const std::weak_ptr< TPointer > &pointer, const std::string &message)
Asserts that the pointer is null.
Definition: assert.h:2281
static void is_not_null(const std::weak_ptr< TPointer > &pointer, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1914
static void is_less_or_equal(const TValue1 &val1, const TValue2 &val2, const tunit::line_info &line_info)
Asserts that the first value is is_less than or equal to the second value.
Definition: assert.h:1240
Contains tunit::assert class.
static void are_same(const TExpected &expected, const TActual &actual)
Asserts that two objects do refer to differents objects.
Definition: assert.h:498
static void is_not_null(const std::unique_ptr< TPointer > &pointer, const std::string &message, const tunit::line_info &line_info)
Asserts that the pointer is not null.
Definition: assert.h:1819
static void does_not_throw(const std::function< void()> &statement, const std::string &message, const tunit::line_info &line_info)
Asserts that the staement does not throw an exception.
Definition: assert.h:715
static void is_not_null(std::nullptr_t pointer, const std::string &message)
Asserts that the pointer is not null.
Definition: assert.h:1977
static void is_not_instance_of(const TValue &value, const std::string &message)
Asserts that an object is not of the type supplied or a derived type.
Definition: assert.h:1679
static void is_not_null(const TPointer *pointer)
Asserts that the pointer is not null.
Definition: assert.h:1712
static void is_true(bool condition, const tunit::line_info &line_info)
Asserts that a condition is true.
Definition: assert.h:2427