xtd 1.0.0
Loading...
Searching...
No Matches
xtd::tunit::base_assert Class Reference
Inheritance diagram for xtd::tunit::base_assert:
xtd::static_object xtd::tunit::assert xtd::tunit::assume xtd::tunit::collection_assert xtd::tunit::collection_assume xtd::tunit::collection_valid xtd::tunit::directory_assert xtd::tunit::directory_assume xtd::tunit::directory_valid xtd::tunit::file_assert xtd::tunit::file_assume xtd::tunit::file_valid xtd::tunit::string_assert xtd::tunit::string_assume xtd::tunit::string_valid xtd::tunit::valid

Definition

The base class for assert.

Namespace
xtd::tunit
Library
xtd.tunit
Examples
math_assert.cpp, math_assume.cpp, and math_valid.cpp.

Public Static Methods

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.

Protected Methods

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.

Protected Static Methods

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

◆ abort() [1/2]

auto xtd::tunit::base_assert::abort ( const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current()) -> void
static

Abort current test. This is used by the other assert functions.

Parameters
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::abort(); // test throws an abort_error exception.
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.
Examples
math_assume.cpp.

◆ abort() [2/2]

auto xtd::tunit::base_assert::abort ( const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Abort current test. This is used by the other assert functions.

Parameters
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::abort("User message..."); // test throws an abort_error exception.

◆ fail() [1/3]

auto xtd::tunit::base_assert::fail ( const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current()) -> void
static

Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.

Parameters
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::fail(); // test throws an assert_error exception.
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.
Examples
math_assert.cpp, math_assume.cpp, and math_valid.cpp.

◆ fail() [2/3]

auto xtd::tunit::base_assert::fail ( const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.

Parameters
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::fail("User message..."); // test throws an assert_error exception.

◆ ignore() [1/2]

auto xtd::tunit::base_assert::ignore ( const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current()) -> void
static

Ignore current test. This is used by the other assert functions.

Parameters
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::ignore(); // test throws an ignore_error exception.
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.

◆ ignore() [2/2]

auto xtd::tunit::base_assert::ignore ( const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Ignore current test. This is used by the other assert functions.

Parameters
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::ignore("User message..."); // test throws an ignore_error exception.

◆ succeed() [1/2]

auto xtd::tunit::base_assert::succeed ( const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current()) -> void
static

Generates a success with a generic message. This is used by the other assert functions.

Parameters
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Examples
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.
Examples
assert_succeed.cpp, math_assert.cpp, math_assume.cpp, and math_valid.cpp.

◆ succeed() [2/2]

auto xtd::tunit::base_assert::succeed ( const xtd::string & message,
const xtd::diagnostics::stack_frame & stack_frame = xtd::diagnostics::stack_frame::current() ) -> void
static

Generates a success with a generic message. This is used by the other assert functions.

Parameters
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::succeed("User message..."); // test ok.

◆ error() [1/3]

auto xtd::tunit::base_assert::error ( ) -> void
staticprotected

Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.

Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::error(); // test throws an assert_error exception.
static auto error() -> void
Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
Examples
math_valid.cpp.

◆ error() [2/3]

auto xtd::tunit::base_assert::error ( const xtd::string & message) -> void
staticprotected

Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.

Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::error("User message..."); // test throws an assert_error exception.

◆ error() [3/3]

auto xtd::tunit::base_assert::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
staticprotected

Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.

Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::error(actual_str, expected_str, "User message..."); // test throws an assert_error exception.

◆ fail() [3/3]

auto xtd::tunit::base_assert::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
inlinestaticprotected

Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.

Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::fail(actual_str, expected_str, "User message..."); // test throws an assert_error exception.

◆ to_string() [1/2]

template<typename value_t>
auto xtd::tunit::base_assert::to_string ( const value_t & value) -> xtd::string
inlinestaticprotected

Convert specified value to xtd::string.

Parameters
valueThe value to convert to xtd::string.
Returns
The xtd::string that contains the value.

◆ to_string() [2/2]

template<typename value_t>
auto xtd::tunit::base_assert::to_string ( const value_t * value) -> xtd::string
inlinestaticprotected

Convert specified value to xtd::string.

Parameters
valueThe value to convert to xtd::string.
Returns
The xtd::string that contains the value.

◆ join_items() [1/2]

template<typename collection_t>
auto xtd::tunit::base_assert::join_items ( const collection_t & collection) -> xtd::string
inlinestaticprotected

Join specified collection into xtd::string.

Parameters
collectionThe collection to join into xtd::string.
Returns
The xtd::string that contains the joined collection.

◆ join_items() [2/2]

auto xtd::tunit::base_assert::join_items ( const xtd::string & str) -> xtd::string
staticprotected

Join specified string into xtd::string.

Parameters
strThe joined to join into xtd::string.
Returns
The xtd::string that contains the joined string.

◆ equals() [1/9]

template<typename value_a_t, typename value_b_t>
auto xtd::tunit::base_assert::equals ( const value_a_t & value_a,
const value_b_t & value_b ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal.

Parameters
value_aThe first value.
value_aThe second value.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [2/9]

template<typename char_t>
auto xtd::tunit::base_assert::equals ( const char_t * value_a,
const string & value_b ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal.

Parameters
value_aThe first value.
value_aThe second value.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [3/9]

template<typename char_t>
auto xtd::tunit::base_assert::equals ( const string & value_a,
const char_t * value_b ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal.

Parameters
value_aThe first value.
value_aThe second value.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [4/9]

auto xtd::tunit::base_assert::equals ( long double value_a,
long double value_b ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal.

Parameters
value_aThe first value.
value_aThe second value.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [5/9]

auto xtd::tunit::base_assert::equals ( double value_a,
double value_b ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal.

Parameters
value_aThe first value.
value_aThe second value.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [6/9]

auto xtd::tunit::base_assert::equals ( float value_a,
float value_b ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal.

Parameters
value_aThe first value.
value_aThe second value.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [7/9]

auto xtd::tunit::base_assert::equals ( double value_a,
double value_b,
double tolerance ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal with tolerance.

Parameters
value_aThe first value.
value_aThe second value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001l repsesent 0.01%.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [8/9]

auto xtd::tunit::base_assert::equals ( long double value_a,
long double value_b,
long double tolerance ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal with tolerance.

Parameters
value_aThe first value.
value_aThe second value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001 repsesent 0.01%.
Returns
true if value_a is equal to value_b; otherwise false.

◆ equals() [9/9]

auto xtd::tunit::base_assert::equals ( float value_a,
float value_b,
float tolerance ) -> bool
inlinestaticnodiscardprotected

Determines if specified values are equal with tolerance.

Parameters
value_aThe first value.
value_aThe second value.
toleranceIndicates a tolerance within which they will be considered as equal in percent. For example 0.0001f repsesent 0.01%.
Returns
true if value_a is equal to value_b; otherwise false.

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