xtd - Reference Guide  0.1.0
Modern c++17 framework to create console, gui and unit test applications on Windows, macOS and Linux.
xtd::tunit::assert Class Referencefinal

The assert class contains a collection of static methods that implement the most common assertions used in xtd::tUnit. More...

#include <assert.h>

Inheritance diagram for xtd::tunit::assert:
xtd::tunit::base_assert

Static Public Member Functions

static void abort ()
 Abort current test. This is used by the other Assert functions. More...
 
static void abort (const xtd::tunit::line_info &line_info)
 Abort current test. This is used by the other Assert functions. More...
 
static void abort (const std::string &message)
 Abort current test. This is used by the other Assert functions. More...
 
static void abort (const std::string &message, const xtd::tunit::line_info &line_info)
 Abort current test. This is used by the other Assert functions. More...
 
template<typename TExpected , typename TActual >
static void are_equal (const TExpected &expected, const TActual &actual)
 Asserts that two type are equal. More...
 
template<typename TExpected , typename TActual >
static void are_equal (const TExpected &expected, const TActual &actual, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
template<typename TExpected , typename TActual >
static void are_equal (const TExpected &expected, const TActual &actual, const std::string &message)
 Asserts that two type are equal. More...
 
template<typename TExpected , typename TActual >
static void are_equal (const TExpected &expected, const TActual &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
static void are_equal (float expected, float actual, float tolerance)
 Asserts that two type are equal. More...
 
static void are_equal (float expected, float actual, float tolerance, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
static void are_equal (float expected, float &actual, float tolerance, const std::string &message)
 Asserts that two type are equal. More...
 
static void are_equal (float expected, float actual, float tolerance, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
static void are_equal (double expected, double actual, double tolerance)
 Asserts that two type are equal. More...
 
static void are_equal (double expected, double actual, double tolerance, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
static void are_equal (double expected, double actual, double tolerance, const std::string &message)
 Asserts that two type are equal. More...
 
static void are_equal (double expected, double actual, double tolerance, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
static void are_equal (long double expected, long double actual, long double tolerance)
 Asserts that two type are equal. More...
 
static void are_equal (long double expected, long double actual, long double tolerance, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
static void are_equal (long double expected, long double actual, long double tolerance, const std::string &message)
 Asserts that two type are equal. More...
 
static void are_equal (long double expected, long double actual, long double tolerance, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two type are equal. More...
 
template<typename TExpected , typename TActual >
static void are_not_equal (const TExpected &expected, const TActual &actual)
 Asserts that two type are not equal. More...
 
template<typename TExpected , typename TActual >
static void are_not_equal (const TExpected &expected, const TActual &actual, const xtd::tunit::line_info &line_info)
 Asserts that two type are not equal. More...
 
template<typename TExpected , typename TActual >
static void are_not_equal (const TExpected &expected, const TActual &actual, const std::string &message)
 Asserts that two type are not equal. More...
 
template<typename TExpected , typename TActual >
static void are_not_equal (const TExpected &expected, const TActual &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two type are not equal. More...
 
template<typename TExpected , typename TActual >
static void are_not_same (const TExpected &expected, const TActual &actual)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_not_same (const TExpected &expected, const TActual &actual, const xtd::tunit::line_info &line_info)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_not_same (const TExpected &expected, const TActual &actual, const std::string &message)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_not_same (const TExpected &expected, const TActual &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_same (const TExpected &expected, const TActual &actual)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_same (const TExpected &expected, const TActual &actual, const xtd::tunit::line_info &line_info)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_same (const TExpected &expected, const TActual &actual, const std::string &message)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TExpected , typename TActual >
static void are_same (const TExpected &expected, const TActual &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that two objects do refer to differents objects. More...
 
template<typename TItem , typename TCollection >
static void contains (const TItem &item, const TCollection &collection)
 Asserts that collection contains an item. More...
 
template<typename TItem , typename TCollection >
static void contains (const TItem &item, const TCollection &collection, const xtd::tunit::line_info &line_info)
 Asserts that collection contains an item. More...
 
template<typename TItem , typename TCollection >
static void contains (const TItem &item, const TCollection &collection, const std::string &message)
 Asserts that collection contains an item. More...
 
template<typename TItem , typename TCollection >
static void contains (const TItem &item, const TCollection &collection, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that collection contains an item. More...
 
static void does_not_throw (const std::function< void()> &statement)
 Asserts that the staement does not throw an exception. More...
 
static void does_not_throw (const std::function< void()> &statement, const xtd::tunit::line_info &line_info)
 Asserts that the staement does not throw an exception. More...
 
static void does_not_throw (const std::function< void()> &statement, const std::string &message)
 Asserts that the staement does not throw an exception. More...
 
static void does_not_throw (const std::function< void()> &statement, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the staement does not throw an exception. More...
 
static void fail ()
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void fail (const xtd::tunit::line_info &line_info)
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void fail (const std::string &message)
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void fail (const std::string &message, const xtd::tunit::line_info &line_info)
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void ignore ()
 Ignore current test. This is used by the other Assert functions. More...
 
static void ignore (const xtd::tunit::line_info &line_info)
 Ignore current test. This is used by the other Assert functions. More...
 
static void ignore (const std::string &message)
 Ignore current test. This is used by the other Assert functions. More...
 
static void ignore (const std::string &message, const xtd::tunit::line_info &line_info)
 Ignore current test. This is used by the other Assert functions. More...
 
template<typename TValue >
static void is_empty (const TValue &value)
 Asserts that collection contains an item. More...
 
template<typename TValue >
static void is_empty (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that collection contains an item. More...
 
template<typename TValue >
static void is_empty (const TValue &value, const std::string &message)
 Asserts that collection contains an item. More...
 
template<typename TValue >
static void is_empty (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that collection contains an item. More...
 
static void is_false (bool condition)
 Asserts that ta condition is false. More...
 
static void is_false (bool condition, const xtd::tunit::line_info &line_info)
 Asserts that a condition is false. More...
 
static void is_false (bool condition, const std::string &message)
 Asserts that a condition is false. More...
 
static void is_false (bool condition, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that a condition is false. More...
 
template<typename TValue1 , typename TValue2 >
static void is_greater (const TValue1 &val1, const TValue2 &val2)
 Asserts that the first value is greater than the second value. More...
 
template<typename TValue1 , typename TValue2 >
static void is_greater (const TValue1 &val1, const TValue2 &val2, const xtd::tunit::line_info &line_info)
 Asserts that the first value is greater than the second value. More...
 
template<typename TValue1 , typename TValue2 >
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. More...
 
template<typename TValue1 , typename TValue2 >
static void is_greater (const TValue1 &val1, const TValue2 &val2, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the first value is greater than the second value. More...
 
template<typename TValue1 , typename TValue2 >
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. More...
 
template<typename TValue1 , typename TValue2 >
static void is_greater_or_equal (const TValue1 &val1, const TValue2 &val2, const xtd::tunit::line_info &line_info)
 Asserts that the first value is greater than or equal to the second value. More...
 
template<typename TValue1 , typename TValue2 >
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. More...
 
template<typename TValue1 , typename TValue2 >
static void is_greater_or_equal (const TValue1 &val1, const TValue2 &val2, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the first value is greater than or equal to the second value. More...
 
template<typename Type , typename TValue >
static void is_instance_of (const TValue &value)
 Asserts that an object is of the type supplied or a derived type. More...
 
template<typename Type , typename TValue >
static void is_instance_of (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that an object is of the type supplied or a derived type. More...
 
template<typename Type , typename TValue >
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. More...
 
template<typename Type , typename TValue >
static void is_instance_of (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that an object is of the type supplied or a derived type. More...
 
template<typename TValue1 , typename TValue2 >
static void is_less (const TValue1 &val1, const TValue2 &val2)
 Asserts that the first value is is_less than the second value. More...
 
template<typename TValue1 , typename TValue2 >
static void is_less (const TValue1 &val1, const TValue2 &val2, const xtd::tunit::line_info &line_info)
 Asserts that the first value is is_less than the second value. More...
 
template<typename TValue1 , typename TValue2 >
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. More...
 
template<typename TValue1 , typename TValue2 >
static void is_less (const TValue1 &val1, const TValue2 &val2, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the first value is is_less than the second value. More...
 
template<typename TValue1 , typename TValue2 >
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. More...
 
template<typename TValue1 , typename TValue2 >
static void is_less_or_equal (const TValue1 &val1, const TValue2 &val2, const xtd::tunit::line_info &line_info)
 Asserts that the first value is is_less than or equal to the second value. More...
 
template<typename TValue1 , typename TValue2 >
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. More...
 
template<typename TValue1 , typename TValue2 >
static void is_less_or_equal (const TValue1 &val1, const TValue2 &val2, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the first value is is_less than or equal to the second value. More...
 
static void is_NaN (double value)
 that a value is NaN. More...
 
static void is_NaN (double value, const xtd::tunit::line_info &line_info)
 that a value is NaN. More...
 
static void is_NaN (double value, const std::string &message)
 Asserts that a value is NaN. More...
 
static void is_NaN (double value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that a value is NaN. More...
 
static void is_NaN (long double value)
 that a value is NaN. More...
 
static void is_NaN (long double value, const xtd::tunit::line_info &line_info)
 that a value is NaN. More...
 
static void is_NaN (long double value, const std::string &message)
 Asserts that a value is NaN. More...
 
static void is_NaN (long double value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that a value is NaN. More...
 
static void is_NaN (float value)
 that a value is NaN. More...
 
static void is_NaN (float value, const xtd::tunit::line_info &line_info)
 that a value is NaN. More...
 
static void is_NaN (float value, const std::string &message)
 Asserts that a value is NaN. More...
 
static void is_NaN (float value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that a value is NaN. More...
 
template<typename TValue >
static void is_negative (const TValue &value)
 Asserts that ta condition is negative. More...
 
template<typename TValue >
static void is_negative (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is negative. More...
 
template<typename TValue >
static void is_negative (const TValue &value, const std::string &message)
 Asserts that ta condition is negative. More...
 
template<typename TValue >
static void is_negative (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is negative. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value)
 Asserts that collection oes not contain any item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that collection does not contain any item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value, const std::string &message)
 Asserts that collection does not contain any item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that collection does not contain any item. More...
 
template<typename Type , typename TValue >
static void is_not_instance_of (const TValue &value)
 Asserts that an object is not of the type supplied or a derived type. More...
 
template<typename Type , typename TValue >
static void is_not_instance_of (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that an object is not of the type supplied or a derived type. More...
 
template<typename Type , typename TValue >
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. More...
 
template<typename Type , typename TValue >
static void is_not_instance_of (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that an object is not of the type supplied or a derived type. More...
 
template<typename TPointer >
static void is_not_null (const TPointer *pointer)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const TPointer *pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const TPointer *pointer, const std::string &message)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const TPointer *pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::unique_ptr< TPointer > &pointer)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::unique_ptr< TPointer > &pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::unique_ptr< TPointer > &pointer, const std::string &message)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::unique_ptr< TPointer > &pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::shared_ptr< TPointer > &pointer)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::shared_ptr< TPointer > &pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::shared_ptr< TPointer > &pointer, const std::string &message)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::shared_ptr< TPointer > &pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::weak_ptr< TPointer > &pointer)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::weak_ptr< TPointer > &pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::weak_ptr< TPointer > &pointer, const std::string &message)
 Asserts that the pointer is not null. More...
 
template<typename TPointer >
static void is_not_null (const std::weak_ptr< TPointer > &pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
static void is_not_null (std::nullptr_t pointer)
 Asserts that the pointer is not null. More...
 
static void is_not_null (std::nullptr_t pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
static void is_not_null (std::nullptr_t pointer, const std::string &message)
 Asserts that the pointer is not null. More...
 
static void is_not_null (std::nullptr_t pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is not null. More...
 
template<typename TValue >
static void is_not_zero (const TValue &value)
 Asserts that ta condition is not zero. More...
 
template<typename TValue >
static void is_not_zero (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is not zero. More...
 
template<typename TValue >
static void is_not_zero (const TValue &value, const std::string &message)
 Asserts that ta condition is not zero. More...
 
template<typename TValue >
static void is_not_zero (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is not zero. More...
 
template<typename TPointer >
static void is_null (const TPointer *pointer)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const TPointer *pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const TPointer *pointer, const std::string &message)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const TPointer *pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::unique_ptr< TPointer > &pointer)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::unique_ptr< TPointer > &pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::unique_ptr< TPointer > &pointer, const std::string &message)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::unique_ptr< TPointer > &pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::shared_ptr< TPointer > &pointer)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::shared_ptr< TPointer > &pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::shared_ptr< TPointer > &pointer, const std::string &message)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::shared_ptr< TPointer > &pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::weak_ptr< TPointer > &pointer)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::weak_ptr< TPointer > &pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::weak_ptr< TPointer > &pointer, const std::string &message)
 Asserts that the pointer is null. More...
 
template<typename TPointer >
static void is_null (const std::weak_ptr< TPointer > &pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
static void is_null (std::nullptr_t pointer)
 Asserts that the pointer is null. More...
 
static void is_null (std::nullptr_t pointer, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
static void is_null (std::nullptr_t pointer, const std::string &message)
 Asserts that the pointer is null. More...
 
static void is_null (std::nullptr_t pointer, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the pointer is null. More...
 
template<typename TValue >
static void is_positive (const TValue &value)
 Asserts that ta condition is positive. More...
 
template<typename TValue >
static void is_positive (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is positive. More...
 
template<typename TValue >
static void is_positive (const TValue &value, const std::string &message)
 Asserts that ta condition is positive. More...
 
template<typename TValue >
static void is_positive (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is positive. More...
 
static void is_true (bool condition)
 Asserts that ta condition is true. More...
 
static void is_true (bool condition, const xtd::tunit::line_info &line_info)
 Asserts that a condition is true. More...
 
static void is_true (bool condition, const std::string &message)
 Asserts that a condition is true. More...
 
static void is_true (bool condition, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that a condition is true. More...
 
template<typename TValue >
static void is_zero (const TValue &value)
 Asserts that ta condition is zero. More...
 
template<typename TValue >
static void is_zero (const TValue &value, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is zero. More...
 
template<typename TValue >
static void is_zero (const TValue &value, const std::string &message)
 Asserts that ta condition is zero. More...
 
template<typename TValue >
static void is_zero (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that ta condition is zero. More...
 
static void succeed ()
 Generates a success with a generic message. This is used by the other Assert functions. More...
 
static void succeed (const xtd::tunit::line_info &line_info)
 Generates a success with a generic message. This is used by the other Assert functions. More...
 
static void succeed (const std::string &message)
 Generates a success with a generic message. This is used by the other Assert functions. More...
 
static void succeed (const std::string &message, const xtd::tunit::line_info &line_info)
 Generates a success with a generic message. This is used by the other Assert functions. More...
 
template<typename TException >
static void throws (const std::function< void()> &statement)
 Asserts that the statement throws a particular exception when called. More...
 
template<typename TException >
static void throws (const std::function< void()> &statement, const xtd::tunit::line_info &line_info)
 Asserts that the statement throws a particular exception when called. More...
 
template<typename TException >
static void throws (const std::function< void()> &statement, const std::string &message)
 Asserts that the statement throws a particular exception when called. More...
 
template<typename TException >
static void throws (const std::function< void()> &statement, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the statement throws a particular exception when called. More...
 
static void throws_any (const std::function< void()> &statement)
 Asserts that the staement does not throw an exception. More...
 
static void throws_any (const std::function< void()> &statement, const xtd::tunit::line_info &line_info)
 Asserts that the staement does not throw an exception. More...
 
static void throws_any (const std::function< void()> &statement, const std::string &message)
 Asserts that the staement does not throw an exception. More...
 
static void throws_any (const std::function< void()> &statement, const std::string &message, const xtd::tunit::line_info &line_info)
 Asserts that the staement does not throw an exception. More...
 

Static Protected Member Functions

static void error ()
 
static void error (const std::string &actual, const std::string &expected, const std::string &message, const xtd::tunit::line_info &line_info)
 
static void fail (const std::string &actual, const std::string &expected, const std::string &message, const xtd::tunit::line_info &line_info)
 
template<typename TCollection >
static std::string join_items (const TCollection &collection)
 
static std::string join_items (const std::string &str)
 
template<typename TValue >
static std::string to_string (const TValue &value)
 
template<typename TValue >
static std::string to_string (const TValue *value)
 

Detailed Description

The assert class contains a collection of static methods that implement the most common assertions used in xtd::tUnit.

Examples
This example show how to used some methods :
#include <xtd/xtd.tunit>
#include <stdexcept>
using namespace xtd::tunit;
namespace unit_tests {
// The class test must be declared with test_class_ helper.
class test_class_(test) {
public:
void test_method_(test_case1) {
}
void test_method_(test_case2) {
}
void test_method_(test_case3) {
assert::does_not_throw([] {throw std::range_error("error");});
}
};
}
int main() {
return console_unit_test().run();
}
// This code can produce the following output:
//
// Start 3 tests from 1 test case
// Run tests:
// SUCCEED test.test_case1 (0 ms total)
// FAILED test.test_case2 (0 ms total)
// Expected: false
// But was: true
// Stack Trace: in /Users/yves/Projects/xtd/examples/xtd.tunit.examples/assert/src/assert.cpp:14
// FAILED test.test_case3 (0 ms total)
// Expected: No Exception to be thrown
// But was: <std::range_error>
// Stack Trace: in /Users/yves/Projects/xtd/examples/xtd.tunit.examples/assert/src/assert.cpp:18
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. (0 ms total)

The documentation for this class was generated from the following file: