xtd 1.0.0
Loading...
Searching...
No Matches
xtd::tunit::assert Class Referencefinal
Inheritance diagram for xtd::tunit::assert:
xtd::tunit::base_assert xtd::static_object

Definition

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

Namespace
xtd::tunit
Library
xtd.tunit
Remarks
Assertions are central to unit testing in any of the xUnit frameworks, and xtd.tunit is no exception. xtd.tunit provides a rich set of assertions as static methods of the Assert class.
If an assertion fails, the method call does not return and an error is reported. If a test contains multiple assertions, any that follow the one that failed will not be executed. For this reason, it's usually best to try for one assertion per test.
Each method may be called without a message, with a simple text message or with a message and arguments. In the last case the message is formatted using the provided text and arguments.
Examples
This example show how to used some methods :
#include <xtd/xtd.tunit>
namespace unit_tests {
class test_class_(test) {
void test_method_(test_case1) {
}
void test_method_(test_case2) {
}
void test_method_(test_case3) {
assert::does_not_throw([] {throw index_out_of_range_exception("error");});
}
};
}
auto main() -> int {
return console_unit_test().run();
}
// This code can produce the following output :
//
// Start 3 tests from 1 test case
// Run tests:
// SUCCEED unit_tests::test.test_case1 [< 1 ms]
// FAILED unit_tests::test.test_case2 [< 1 ms]
// Expected: false
// But was: true
// Stack Trace: in |---OMITTED---|/assert.cpp:10
// FAILED unit_tests::test.test_case3 [< 1 ms]
// Expected: No Exception to be thrown
// But was: <xtd::index_out_of_range_exception>
// Stack Trace: in |---OMITTED---|/assert.cpp:14
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. [0.0006 seconds]
The exception that is thrown when an attempt is made to access an element of an array with an index t...
Definition index_out_of_range_exception.hpp:18
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_true(bool condition, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that a condition is true.
#define test_method_(method_name)
Add test method to class test.
Definition test_method_attribute.hpp:72

Public Static Methods

template<typename expected_t, typename actual_t>
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.
template<typename expected_t, typename actual_t>
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.
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 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 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 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 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 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.
template<typename expected_t, typename actual_t>
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.
template<typename expected_t, typename actual_t>
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.
template<typename expected_t, typename actual_t>
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.
template<typename expected_t, typename actual_t>
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.
template<typename expected_t, typename actual_t>
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.
template<typename expected_t, typename actual_t>
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.
template<typename item_t, typename collection_t>
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.
template<typename item_t, typename collection_t>
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.
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 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.
template<typename value_t>
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.
template<typename value_t>
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.
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_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.
template<typename value1_t, typename value2_t>
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.
template<typename value1_t, typename value2_t>
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.
template<typename value1_t, typename value2_t>
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.
template<typename value1_t, typename value2_t>
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.
template<typename type_t, typename value_t>
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.
template<typename type_t, typename value_t>
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.
template<typename value1_t, typename value2_t>
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.
template<typename value1_t, typename value2_t>
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.
template<typename value1_t, typename value2_t>
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.
template<typename value1_t, typename value2_t>
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.
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 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 (long double value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 that a value is NaN.
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 is_NaN (float value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 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.
template<typename value_t>
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.
template<typename value_t>
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.
template<typename value_t>
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.
template<typename value_t>
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.
template<typename type_t, typename value_t>
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.
template<typename type_t, typename value_t>
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.
template<typename pointer_t>
static auto is_not_null (const pointer_t *pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename pointer_t>
static auto is_not_null (const pointer_t *pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename optional_t>
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.
template<typename optional_t>
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.
template<typename pointer_t>
static auto is_not_null (const xtd::uptr< pointer_t > &pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename pointer_t>
static auto is_not_null (const xtd::uptr< pointer_t > &pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename pointer_t>
static auto is_not_null (const xtd::sptr< pointer_t > &pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename pointer_t>
static auto is_not_null (const xtd::sptr< pointer_t > &pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename pointer_t>
static auto is_not_null (const xtd::wptr< pointer_t > &pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename pointer_t>
static auto is_not_null (const xtd::wptr< pointer_t > &pointerpointer, 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_not_null (std::nullptr_t pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
static auto is_not_null (std::nullptr_t pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is not null.
template<typename value_t>
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.
template<typename value_t>
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.
template<typename pointer_t>
static auto is_null (const pointer_t *pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename pointer_t>
static auto is_null (const pointer_t *pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename optional_t>
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.
template<typename optional_t>
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.
template<typename pointer_t>
static auto is_null (const xtd::uptr< pointer_t > &pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename pointer_t>
static auto is_null (const xtd::uptr< pointer_t > &pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename pointer_t>
static auto is_null (const xtd::sptr< pointer_t > &pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename pointer_t>
static auto is_null (const xtd::sptr< pointer_t > &pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename pointer_t>
static auto is_null (const xtd::wptr< pointer_t > &pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename pointer_t>
static auto is_null (const xtd::wptr< pointer_t > &pointerpointer, 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 is_null (std::nullptr_t pointerpointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
static auto is_null (std::nullptr_t pointerpointer, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Asserts that the pointer is null.
template<typename value_t>
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.
template<typename value_t>
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.
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_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.
template<typename value_t>
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.
template<typename value_t>
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.
template<typename exception_t>
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.
template<typename exception_t>
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
 Asserts that the statement throws a particular exception when called.
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 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.

Additional Inherited Members

static auto abort (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Abort current test. This is used by the other assert functions.
static auto abort (const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Abort current test. 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 fail (const xtd::string &message, 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 ignore (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Ignore current test. This is used by the other assert functions.
static auto ignore (const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
 Ignore current test. This is used by the other assert functions.
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 succeed (const xtd::string &message, 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 error () -> void
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
static auto error (const xtd::string &message) -> void
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
static auto error (const xtd::string &actual, const xtd::string &expected, const xtd::string &message, 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 fail (const xtd::string &actual, const xtd::string &expected, const xtd::string &message, 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.
template<typename value_t>
static auto to_string (const value_t &value) -> xtd::string
 Convert specified value to xtd::string.
template<typename value_t>
static auto to_string (const value_t *value) -> xtd::string
 Convert specified value to xtd::string.
template<typename collection_t>
static auto join_items (const collection_t &collection) -> xtd::string
 Join specified collection into xtd::string.
static auto join_items (const xtd::string &str) -> xtd::string
 Join specified string into xtd::string.
template<typename value_a_t, typename value_b_t>
static auto equals (const value_a_t &value_a, const value_b_t &value_b) -> bool
 Determines if specified values are equal.
template<typename char_t>
static auto equals (const char_t *value_a, const string &value_b) -> bool
 Determines if specified values are equal.
template<typename char_t>
static auto equals (const string &value_a, const char_t *value_b) -> bool
 Determines if specified values are equal.
static auto equals (long double value_a, long double value_b) -> bool
 Determines if specified values are equal.
static auto equals (double value_a, double value_b) -> bool
 Determines if specified values are equal.
static auto equals (float value_a, float value_b) -> bool
 Determines if specified values are equal.
static auto equals (double value_a, double value_b, double tolerance) -> bool
 Determines if specified values are equal with tolerance.
static auto equals (long double value_a, long double value_b, long double tolerance) -> bool
 Determines if specified values are equal with tolerance.
static auto equals (float value_a, float value_b, float tolerance) -> bool
 Determines if specified values are equal with tolerance.

Member Function Documentation

◆ are_equal() [1/8]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::are_equal ( const expected_t & expected,
const actual_t & actual,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::are_equal(24, int(24)); // test ok.
xtd::tunit::assert::are_equal(23, int(24)); // test throws an assert_error exception.
static auto are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are equal.
Definition assert.hpp:50
Examples
class_with_insert_stream_operator.cpp, and class_without_insert_stream_operator.cpp.

◆ are_equal() [2/8]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::are_equal(24, int(24), "User message..."); // test ok.
xtd::tunit::assert::are_equal(23, int(24), "User message..."); // test throws an assert_error exception.

◆ are_equal() [3/8]

auto xtd::tunit::assert::are_equal ( float expected,
float actual,
float tolerance,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001f repsesent 0.01%.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
float f = 0.7999999999f;
xtd::tunit::assert::are_equal(0.79999f, f, 0.0001f); // test ok.
xtd::tunit::assert::are_equal(0.79999f, f, 0.00001f); // test throws an assert_error exception.
@ f
The F key.
Definition console_key.hpp:98

◆ are_equal() [4/8]

auto xtd::tunit::assert::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
static

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001f repsesent 0.01%.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
float f = 0.7999999999f;
xtd::tunit::assert::are_equal(0.79999f, f, 0.0001f, "User message..."); // test ok.
xtd::tunit::assert::are_equal(0.79999f, f, 0.00001f, "User message..."); // test throws an assert_error exception.

◆ are_equal() [5/8]

auto xtd::tunit::assert::are_equal ( double expected,
double actual,
double tolerance,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001 repsesent 0.01%.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
double d = 0.7999999999;
xtd::tunit::assert::are_equal(0.79999, d, 0.0001); // test ok.
xtd::tunit::assert::are_equal(0.79999, d, 0.00001); // test throws an assert_error exception.
@ d
The D key.
Definition console_key.hpp:94

◆ are_equal() [6/8]

auto xtd::tunit::assert::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
static

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001 repsesent 0.01%.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
double d = 0.7999999999;
xtd::tunit::assert::are_equal(0.79999, d, 0.0001, "User message..."); // test ok.
xtd::tunit::assert::are_equal(0.79999, d, 0.00001, "User message..."); // test throws an assert_error exception.

◆ are_equal() [7/8]

auto xtd::tunit::assert::are_equal ( long double expected,
long double actual,
long double tolerance,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001l repsesent 0.01%.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
long double ld = 0.7999999999l;
xtd::tunit::assert::are_equal(0.79999l, ld, 0.0001l); // test ok.
xtd::tunit::assert::are_equal(0.79999l, ld, 0.00001l); // test throws an assert_error exception.

◆ are_equal() [8/8]

auto xtd::tunit::assert::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
static

Asserts that two type are equal.

Parameters
expectedthe expected value.
actualthe actual value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001l repsesent 0.01%.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
long double ld = 0.7999999999l;
xtd::tunit::assert::are_equal(0.79999l, ld, 0.0001l, "User message..."); // test ok.
xtd::tunit::assert::are_equal(0.79999l, ld, 0.00001l, "User message..."); // test throws an assert_error exception.

◆ are_not_equal() [1/2]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::are_not_equal ( const expected_t & expected,
const actual_t & actual,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that two type are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::are_not_equal(23, int(24)); // test ok.
xtd::tunit::assert::are_not_equal(24, int(24)); // test throws an assert_error exception.
static auto are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two type are not equal.
Definition assert.hpp:171

◆ are_not_equal() [2/2]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that two type are not equal.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::are_not_equal(23, int(24), "User message..."); // test ok.
xtd::tunit::assert::are_not_equal(24, int(24), "User message..."); // test throws an assert_error exception.

◆ are_not_same() [1/2]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::are_not_same ( const expected_t & expected,
const actual_t & actual,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that two objects do refer to differents objects.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int a = 24;
int& b = a;
int c = 24;
xtd::tunit::assert::are_not_same(b, a, stack_frame); // test throws an assert_error exception.
static auto are_not_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two objects do refer to differents objects.
Definition assert.hpp:211
@ a
The A key.
Definition console_key.hpp:88
@ c
The C key.
Definition console_key.hpp:92
@ b
The B key.
Definition console_key.hpp:90

◆ are_not_same() [2/2]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that two objects do refer to differents objects.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int a = 24;
int& b = a;
int c = 24;
xtd::tunit::assert::are_not_same(c, a, "User message..."); // test ok.
xtd::tunit::assert::are_not_same(b, a, "User message...", stack_frame); // test throws an assert_error exception.

◆ are_same() [1/2]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::are_same ( const expected_t & expected,
const actual_t & actual,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that two objects do refer to differents objects.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int a = 24;
int& b = a;
int c = 24;
xtd::tunit::assert::are_same(c, a); // test throws an assert_error exception.
static auto are_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that two objects do refer to differents objects.
Definition assert.hpp:246

◆ are_same() [2/2]

template<typename expected_t, typename actual_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that two objects do refer to differents objects.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int a = 24;
int& b = a;
int c = 24;
xtd::tunit::assert::are_same(b, a, "User message..."); // test ok.
xtd::tunit::assert::are_same(c, a, "User message..."); // test throws an assert_error exception.

◆ contains() [1/2]

template<typename item_t, typename collection_t>
auto xtd::tunit::assert::contains ( const item_t & item,
const collection_t & collection,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that collection contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {0, 1, 2, 3};
xtd::tunit::assert::contains(2, v1); // test ok.
xtd::tunit::assert::contains(4, v1); // test throws an assert_error exception.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
static auto contains(const item_t &item, const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection contains an item.
Definition assert.hpp:279
Examples
many_valids_and_asserts.cpp.

◆ contains() [2/2]

template<typename item_t, typename collection_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that collection contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {0, 1, 2, 3};
xtd::tunit::assert::contains(2, v1, "User message..."); // test ok.
xtd::tunit::assert::contains(4, v1, "User message..."); // test throws an assert_error exception.

◆ does_not_throw() [1/2]

auto xtd::tunit::assert::does_not_throw ( const std::function< void()> & statement,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the staement does not throw an exception.

Parameters
statementThe statement that verify.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {1, 2, 3, 4};
xtd::tunit::assert::does_not_throw([&] {v1.at(2);}); // test ok.
xtd::tunit::assert::does_not_throw([&] {v1.at(5);}); // test throws an assert_error exception.
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.
Examples
many_asserts.cpp.

◆ does_not_throw() [2/2]

auto xtd::tunit::assert::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
static

Asserts that the staement does not throw an exception.

Parameters
statementThe statement that verify.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {1, 2, 3, 4};
xtd::tunit::assert::does_not_throw([&] {v1.at(2);}, "User message..."); // test ok.
xtd::tunit::assert::does_not_throw([&] {v1.at(5);}, "User message..."); // test throws an assert_error exception.

◆ is_empty() [1/2]

template<typename value_t>
auto xtd::tunit::assert::is_empty ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that collection contains an item.

Parameters
valueThe value to check is empty.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v2 = {0, 1, 2, 3};
xtd::tunit::assert::is_empty(v2); // test throws an assert_error exception.
static auto is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection contains an item.
Definition assert.hpp:351
Examples
assert_is_empty.cpp.

◆ is_empty() [2/2]

template<typename value_t>
auto xtd::tunit::assert::is_empty ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that collection contains an item.

Parameters
valueThe value to check is empty.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v2 = {0, 1, 2, 3};
xtd::tunit::assert::is_empty(v1, "User message..."); // test ok.
xtd::tunit::assert::is_empty(v2, "User message..."); // test throws an assert_error exception.

◆ is_false() [1/2]

auto xtd::tunit::assert::is_false ( bool condition,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a condition is false.

Parameters
conditionThe condition to check is false.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string s1 = "Anything";
std::string s2;
xtd::tunit::assert::is_false(std::empty(s1)); // test ok.
xtd::tunit::assert::is_false(std::empty(s2)); // test throws an assert_error exception.
Examples
assert_is_false.cpp, and many_asserts.cpp.

◆ is_false() [2/2]

auto xtd::tunit::assert::is_false ( bool condition,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a condition is false.

Parameters
conditionThe condition to check is false.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string s1 = "Anything";
std::string s2;
xtd::tunit::assert::is_false(std::empty(s1), "User message..."); // test ok.
xtd::tunit::assert::is_false(std::empty(s2), "User message..."); // test throws an assert_error exception.

◆ is_greater() [1/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::is_greater ( const value1_t & val1,
const value2_t & val2,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the first value is greater than the second value.

Parameters
val1the first value.
val2the second value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_greater(24, 12); // test ok.
xtd::tunit::assert::is_greater(24, 48); // test throws an assert_error exception.
static auto is_greater(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is greater than the second value.
Definition assert.hpp:422
Examples
assert_is_greater.cpp.

◆ is_greater() [2/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the first value is greater than the second value.

Parameters
val1the first value.
val2the second value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_greater(24, 12, "User message..."); // test ok.
xtd::tunit::assert::is_greater(24, 48, "User message..."); // test throws an assert_error exception.

◆ is_greater_or_equal() [1/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the first value is greater than or equal to the second value.

Parameters
val1the first value.
val2the second value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_greater_or_equal(24, 48); // test throws an assert_error exception.
static auto is_greater_or_equal(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is greater than or equal to the second value.
Definition assert.hpp:460
Examples
assert_is_greater_or_equal.cpp.

◆ is_greater_or_equal() [2/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the first value is greater than or equal to the second value.

Parameters
val1the first value.
val2the second value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_greater_or_equal(24, 12, "User message..."); // test ok.
xtd::tunit::assert::is_greater_or_equal(24, 24, "User message..."); // test ok.
xtd::tunit::assert::is_greater_or_equal(24, 48, "User message..."); // test throws an assert_error exception.

◆ is_instance_of() [1/2]

template<typename type_t, typename value_t>
auto xtd::tunit::assert::is_instance_of ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that an object is of the type supplied or a derived type.

Parameters
valueThe object to verify
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::invalid_argument except("invalid argument");
xtd::tunit::assert::is_instance_of<std::bad_cast>(except); // test throws an assert_error exception.
static auto is_instance_of(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that an object is of the type supplied or a derived type.
Definition assert.hpp:498
Examples
assert_is_instance_of.cpp.

◆ is_instance_of() [2/2]

template<typename type_t, typename value_t>
auto xtd::tunit::assert::is_instance_of ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that an object is of the type supplied or a derived type.

Parameters
valueThe object to verify
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::invalid_argument except("invalid argument");
xtd::tunit::assert::is_instance_of<std::logic_error>(except, "User message..."); // test ok.
xtd::tunit::assert::is_instance_of<std::bad_cast>(except, "User message..."); // test throws an assert_error exception.

◆ is_less() [1/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::is_less ( const value1_t & val1,
const value2_t & val2,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the first value is is_less than the second value.

Parameters
val1the first value.
val2the second value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_less(24, 48); // test ok.
xtd::tunit::assert::is_less(24, 12); // test throws an assert_error exception.
static auto is_less(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is is_less than the second value.
Definition assert.hpp:528
Examples
assert_is_less.cpp.

◆ is_less() [2/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the first value is is_less than the second value.

Parameters
val1the first value.
val2the second value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_less(24, 48, "User message..."); // test ok.
xtd::tunit::assert::is_less(24, 12, "User message..."); // test throws an assert_error exception.

◆ is_less_or_equal() [1/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the first value is is_less than or equal to the second value.

Parameters
val1the first value.
val2the second value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_less_or_equal(24, 12); // test throws an assert_error exception.
static auto is_less_or_equal(const value1_t &val1, const value2_t &val2, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the first value is is_less than or equal to the second value.
Definition assert.hpp:566
Examples
assert_is_less_or_equal.cpp.

◆ is_less_or_equal() [2/2]

template<typename value1_t, typename value2_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the first value is is_less than or equal to the second value.

Parameters
val1the first value.
val2the second value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_less_or_equal(24, 48, "User message..."); // test ok.
xtd::tunit::assert::is_less_or_equal(24, 24, "User message..."); // test ok.
xtd::tunit::assert::is_less_or_equal(24, 12, "User message..."); // test throws an assert_error exception.

◆ is_NaN() [1/6]

auto xtd::tunit::assert::is_NaN ( double value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

that a value is NaN.

Parameters
valueThe value to check is NaN.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
double v1 = std::numeric_limits<double>::quiet_NaN();
double v2 = 3.14159265358979323846;
xtd::tunit::assert::is_NaN(v2); // test throws an assert_error exception.
static auto is_NaN(double value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
that a value is NaN.
Examples
assert_is_NaN.cpp.

◆ is_NaN() [2/6]

auto xtd::tunit::assert::is_NaN ( double value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a value is NaN.

Parameters
valueThe value to check is NaN.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
double v1 = std::numeric_limits<double>::quiet_NaN();
double v2 = 3.14159265358979323846;
xtd::tunit::assert::is_NaN(v1, "User message..."); // test ok.
xtd::tunit::assert::is_NaN(v2, "User message..."); // test throws an assert_error exception.

◆ is_NaN() [3/6]

auto xtd::tunit::assert::is_NaN ( long double value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

that a value is NaN.

Parameters
valueThe value to check is NaN.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
long double v1 = std::numeric_limits<long double>::quiet_NaN();
long double v2 = 3.14159265358979323846l;
xtd::tunit::assert::is_NaN(v2); // test throws an assert_error exception.

◆ is_NaN() [4/6]

auto xtd::tunit::assert::is_NaN ( long double value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a value is NaN.

Parameters
valueThe value to check is NaN.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
long double v1 = std::numeric_limits<long double>::quiet_NaN();
long double v2 = 3.14159265358979323846l;
xtd::tunit::assert::is_NaN(v1, "User message..."); // test ok.
xtd::tunit::assert::is_NaN(v2, "User message..."); // test throws an assert_error exception.

◆ is_NaN() [5/6]

auto xtd::tunit::assert::is_NaN ( float value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

that a value is NaN.

Parameters
valueThe value to check is NaN.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
float v1 = std::numeric_limits<float>::quiet_NaN();
float v2 = 3.14159265358979323846;
xtd::tunit::assert::is_NaN(v2); // test throws an assert_error exception.

◆ is_NaN() [6/6]

auto xtd::tunit::assert::is_NaN ( float value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a value is NaN.

Parameters
valueThe value to check is NaN.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
float v1 = std::numeric_limits<float>::quiet_NaN();
float v2 = 3.14159265358979323846;
xtd::tunit::assert::is_NaN(v1, "User message..."); // test ok.
xtd::tunit::assert::is_NaN(v2, "User message..."); // test throws an assert_error exception.

◆ is_negative() [1/2]

template<typename value_t>
auto xtd::tunit::assert::is_negative ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is negative.

Parameters
valueThe value to check is negative.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = -1;
int i2 = 1;
xtd::tunit::assert::is_negative(i2); // test throws an assert_error exception.
static auto is_negative(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is negative.
Definition assert.hpp:681
Examples
assert_is_negative.cpp.

◆ is_negative() [2/2]

template<typename value_t>
auto xtd::tunit::assert::is_negative ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is negative.

Parameters
valueThe value to check is negative.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = -1;
int i2 = 1;
xtd::tunit::assert::is_negative(i1, "User message..."); // test ok.
xtd::tunit::assert::is_negative(i2, "User message..."); // test throws an assert_error exception.

◆ is_not_empty() [1/2]

template<typename value_t>
auto xtd::tunit::assert::is_not_empty ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that collection does not contain any item.

Parameters
valueThe value to check is empty.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {0, 1, 2, 3};
xtd::tunit::assert::is_not_empty(v2); // test throws an assert_error exception.
static auto is_not_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that collection does not contain any item.
Definition assert.hpp:712
Examples
assert_is_not_empty.cpp.

◆ is_not_empty() [2/2]

template<typename value_t>
auto xtd::tunit::assert::is_not_empty ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that collection does not contain any item.

Parameters
valueThe value to check is empty.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {0, 1, 2, 3};
xtd::tunit::assert::is_not_empty(v1, "User message..."); // test ok.
xtd::tunit::assert::is_not_empty(v2, "User message..."); // test throws an assert_error exception.

◆ is_not_instance_of() [1/2]

template<typename type_t, typename value_t>
auto xtd::tunit::assert::is_not_instance_of ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that an object is not of the type supplied or a derived type.

Parameters
valueThe object to verify
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::invalid_argument except("invalid argument");
xtd::tunit::assert::is_not_instance_of<std::logic_error>(except); // test throws an assert_error exception.
static auto is_not_instance_of(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that an object is not of the type supplied or a derived type.
Definition assert.hpp:757
Examples
assert_is_not_instance_of.cpp.

◆ is_not_instance_of() [2/2]

template<typename type_t, typename value_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that an object is not of the type supplied or a derived type.

Parameters
valueThe object to verify
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::invalid_argument except("invalid argument");
xtd::tunit::assert::is_not_instance_of<std::bad_cast>(except, "User message..."); // test ok.
xtd::tunit::assert::is_not_instance_of<std::logic_error>(except, "User message..."); // test throws an assert_error exception.

◆ is_not_null() [1/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_not_null ( const pointer_t * pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string str = "Anything";
std::string* s1 = &str;
std::string* s2 = nullptr;
xtd::tunit::assert::is_not_null(s2); // test throws an assert_error exception.
static auto is_not_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is not null.
Definition assert.hpp:789
Examples
assert_is_not_null.cpp.

◆ is_not_null() [2/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_not_null ( const pointer_t * pointer,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string str = "Anything";
std::string* s1 = &str;
std::string* s2 = nullptr;
xtd::tunit::assert::is_not_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_not_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_not_null() [3/12]

template<typename optional_t>
auto xtd::tunit::assert::is_not_null ( const std::optional< optional_t > & opt,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the optional is not std::nullopt.

Parameters
optThe optional to check is std::nullopt.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::optional<std::string> s1 = "Anything";
std::optional<std::string> s2;
xtd::tunit::assert::is_not_null(s2); // test throws an assert_error exception.

◆ is_not_null() [4/12]

template<typename optional_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the optional is not std::nullopt.

Parameters
optThe optional to check is std::nullopt.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::optional<std::string> s1 = "Anything";
std::optional<std::string> s2;
xtd::tunit::assert::is_not_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_not_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_not_null() [5/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_not_null ( const xtd::uptr< pointer_t > & pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_not_null(s2); // test throws an assert_error exception.
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
auto new_uptr(args_t &&... args) -> xtd::uptr< type_t >
xtd::new_uptr operator. This operator creates a xtd::uptr object.
Definition new_uptr.hpp:24

◆ is_not_null() [6/12]

template<typename pointer_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_not_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_not_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_not_null() [7/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_not_null ( const xtd::sptr< pointer_t > & pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_not_null(s2); // test throws an assert_error exception.
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
auto new_sptr(args_t &&... args) -> xtd::sptr< type_t >
xtd::new_sptr operator creates a xtd::sptr object.
Definition new_sptr.hpp:24

◆ is_not_null() [8/12]

template<typename pointer_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_not_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_not_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_not_null() [9/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_not_null ( const xtd::wptr< pointer_t > & pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Examples
std::weak_ptr< type_t > wptr
The xtd::uptr object is a weak pointer.
Definition wptr.hpp:17
@ s
The S key.
Definition console_key.hpp:124

◆ is_not_null() [10/12]

template<typename pointer_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Examples
xtd::tunit::assert::is_not_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_not_null(s2, "User message..."); // test ok.

◆ is_not_null() [11/12]

auto xtd::tunit::assert::is_not_null ( std::nullptr_t pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Remarks
Always false, a std::nullptr_t is always equal to nullptr.
Examples
xtd::tunit::assert::is_not_null(nullptr); // test throws an assert_error exception.

◆ is_not_null() [12/12]

auto xtd::tunit::assert::is_not_null ( std::nullptr_t pointer,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the pointer is not null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Remarks
Always false, a std::nullptr_t is always equal to nullptr.
Examples
xtd::tunit::assert::is_not_null(nullptr, "User message..."); // test throws an assert_error exception.

◆ is_not_zero() [1/2]

template<typename value_t>
auto xtd::tunit::assert::is_not_zero ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is not zero.

Parameters
valueThe value to check is not zero.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = 42;
int i2 = 0;
xtd::tunit::assert::is_not_zero(i2); // test throws an assert_error exception.
static auto is_not_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is not zero.
Definition assert.hpp:962
Examples
assert_is_not_zero.cpp.

◆ is_not_zero() [2/2]

template<typename value_t>
auto xtd::tunit::assert::is_not_zero ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is not zero.

Parameters
valueThe value to check is not zero.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = 42;
int i2 = 0;
xtd::tunit::assert::is_not_zero(i1, "User message..."); // test ok.
xtd::tunit::assert::is_not_zero(i2, "User message..."); // test throws an assert_error exception.

◆ is_null() [1/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_null ( const pointer_t * pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string str = "Anything";
std::string* s1 = nullptr;
std::string* s2 = &str;
xtd::tunit::assert::is_null(s2); // test throws an assert_error exception.
static auto is_null(const pointer_t *pointer, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the pointer is null.
Definition assert.hpp:994
Examples
assert_is_null.cpp.

◆ is_null() [2/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_null ( const pointer_t * pointer,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string str = "Anything";
std::string* s1 = nullptr;
std::string* s2 = &str;
xtd::tunit::assert::is_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_null() [3/12]

template<typename optional_t>
auto xtd::tunit::assert::is_null ( const std::optional< optional_t > & opt,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the optional is std::nullopt.

Parameters
optThe optional to check is std::nullopt.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::optional<std::string> s1;
std::optional<std::string> s2 = "Anything";
xtd::tunit::assert::is_null(s2); // test throws an assert_error exception.

◆ is_null() [4/12]

template<typename optional_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the optional is std::nullopt.

Parameters
optThe optional to check is std::nullopt.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::optional<std::string> s1;
std::optional<std::string> s2 = "Anything";
xtd::tunit::assert::is_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_null() [5/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_null ( const xtd::uptr< pointer_t > & pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_null(s2); // test throws an assert_error exception.

◆ is_null() [6/12]

template<typename pointer_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_null() [7/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_null ( const xtd::sptr< pointer_t > & pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_null(s2); // test throws an assert_error exception.

◆ is_null() [8/12]

template<typename pointer_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::is_null(s1, "User message..."); // test ok.
xtd::tunit::assert::is_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_null() [9/12]

template<typename pointer_t>
auto xtd::tunit::assert::is_null ( const xtd::wptr< pointer_t > & pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Remarks
Always false, a weaptr can't be equal to nullptr by contruction or assignation.
Examples
xtd::tunit::assert::is_null(s1); // test throws an assert_error exception.
xtd::tunit::assert::is_null(s2); // test throws an assert_error exception.

◆ is_null() [10/12]

template<typename pointer_t>
auto xtd::tunit::assert::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
inlinestatic

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Remarks
Always false, a weaptr can't be equal to nullptr by contruction or assignation.
Examples
xtd::tunit::assert::is_null(s1, "User message..."); // test throws an assert_error exception.
xtd::tunit::assert::is_null(s2, "User message..."); // test throws an assert_error exception.

◆ is_null() [11/12]

auto xtd::tunit::assert::is_null ( std::nullptr_t pointer,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Remarks
Always false, a std::nullptr_t is always equal to nullptr.
Examples
xtd::tunit::assert::is_null(nullptr); // test ok.

◆ is_null() [12/12]

auto xtd::tunit::assert::is_null ( std::nullptr_t pointer,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the pointer is null.

Parameters
pointerThe pointer to check is null.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Remarks
Always false, a std::nullptr_t is always equal to nullptr.
Examples
xtd::tunit::assert::is_null(nullptr, "User message..."); // test ok.

◆ is_positive() [1/2]

template<typename value_t>
auto xtd::tunit::assert::is_positive ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is positive.

Parameters
valueThe value to check is positive.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = 1;
int i2 = -1;
xtd::tunit::assert::is_positive(i2); // test throws an assert_error exception.
static auto is_positive(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is positive.
Definition assert.hpp:1169
Examples
assert_is_positive.cpp.

◆ is_positive() [2/2]

template<typename value_t>
auto xtd::tunit::assert::is_positive ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is positive.

Parameters
valueThe value to check is positive.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = 1;
int i2 = -1;
xtd::tunit::assert::is_positive(i1, "User message..."); // test ok.
xtd::tunit::assert::is_positive(i2, "User message..."); // test throws an assert_error exception.

◆ is_true() [1/2]

auto xtd::tunit::assert::is_true ( bool condition,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a condition is true.

Parameters
conditionThe condition to check is true.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string s1;
std::string s2 = "Anything";
xtd::tunit::assert::is_false(std::empty(s1)); // test ok.
xtd::tunit::assert::is_false(std::empty(s2)); // test throws an assert_error exception.
Examples
assert_is_true.cpp, many_asserts.cpp, and tunit_config_main.cpp.

◆ is_true() [2/2]

auto xtd::tunit::assert::is_true ( bool condition,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that a condition is true.

Parameters
conditionThe condition to check is true.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::string s1;
std::string s2 = "Anything";
xtd::tunit::assert::is_false(std::empty(s1), "User message..."); // test ok.
xtd::tunit::assert::is_false(std::empty(s2), "User message..."); // test throws an assert_error exception.

◆ is_zero() [1/2]

template<typename value_t>
auto xtd::tunit::assert::is_zero ( const value_t & value,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is zero.

Parameters
valueThe value to check is zero.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = 0;
int i2 = 42;
xtd::tunit::assert::is_zero(i2); // test throws an assert_error exception.
static auto is_zero(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that ta condition is zero.
Definition assert.hpp:1226
Examples
assert_is_zero.cpp.

◆ is_zero() [2/2]

template<typename value_t>
auto xtd::tunit::assert::is_zero ( const value_t & value,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that ta condition is zero.

Parameters
valueThe value to check is zero.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
int i1 = 0;
int i2 = 42;
xtd::tunit::assert::is_zero(i1, "User message..."); // test ok.
xtd::tunit::assert::is_zero(i2, "User message..."); // test throws an assert_error exception.

◆ throws() [1/2]

template<typename exception_t>
auto xtd::tunit::assert::throws ( const std::function< void()> & statement,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the statement throws a particular exception when called.

Template Parameters
exception_tThe exception type that must be throw.
Parameters
statementThe statement that verify.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {1, 2, 3, 4};
xtd::tunit::assert::throws<std::out_of_range>([&] {v1.at(5);}); // test ok.
xtd::tunit::assert::throws<std::out_of_range>([&] {v1.at(2);}); // test throws an assert_error exception.
static auto throws(const std::function< void()> &statement, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that the statement throws a particular exception when called.
Definition assert.hpp:1257
Examples
assert_throws.cpp.

◆ throws() [2/2]

template<typename exception_t>
auto xtd::tunit::assert::throws ( const std::function< void()> & statement,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
inlinestatic

Asserts that the statement throws a particular exception when called.

Template Parameters
exception_tThe exception type that must be throw.
Parameters
statementThe statement that verify.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {1, 2, 3, 4};
xtd::tunit::assert::throws<std::out_of_range>([&] {v1.at(5);}, "User message..."); // test ok.
xtd::tunit::assert::throws<std::out_of_range>([&] {v1.at(2);}, "User message..."); // test throws an assert_error exception.

◆ throws_any() [1/2]

auto xtd::tunit::assert::throws_any ( const std::function< void()> & statement,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the staement does not throw an exception.

Parameters
statementThe statement that verify.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {1, 2, 3, 4};
xtd::tunit::assert::throws_any([&] {v1.at(5);}); // test ok.
xtd::tunit::assert::throws_any([&] {v1.at(2);}); // test throws an assert_error exception.
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.
Examples
assert_throws_any.cpp.

◆ throws_any() [2/2]

auto xtd::tunit::assert::throws_any ( const std::function< void()> & statement,
const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Asserts that the staement does not throw an exception.

Parameters
statementThe statement that verify.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::array<int> v1 = {1, 2, 3, 4};
xtd::tunit::assert::throws_any([&] {v1.at(5);}, "User message..."); // test ok.
xtd::tunit::assert::throws_any([&] {v1.at(2);}, "User message..."); // test throws an assert_error exception.

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