xtd 0.2.0
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 void abort (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Abort current test. This is used by the other assert functions.
 
static void abort (const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Abort current test. This is used by the other assert functions.
 
static void fail (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
 
static void fail (const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
 
static void ignore (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Ignore current test. This is used by the other assert functions.
 
static void ignore (const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Ignore current test. This is used by the other assert functions.
 
static void succeed (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Generates a success with a generic message. This is used by the other assert functions.
 
static void succeed (const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Generates a success with a generic message. This is used by the other assert functions.
 

Protected Methods

static void error ()
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
 
static void error (const xtd::string &message)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
 
static void 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())
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
 
static void 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())
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
 
template<class value_t >
static xtd::string to_string (const value_t &value)
 Convert specified value to xtd::string.
 
template<class value_t >
static xtd::string to_string (const value_t *value)
 Convert specified value to xtd::string.
 
template<class collection_t >
static xtd::string join_items (const collection_t &collection)
 Join specified collection into xtd::string.
 
static xtd::string join_items (const xtd::string &str)
 Join specified string into xtd::string.
 

Protected Static Methods

template<class value_a_t , class value_b_t >
static bool equals (const value_a_t &value_a, const value_b_t &value_b)
 Determines if specified values are equal.
 
template<class char_t >
static bool equals (const char_t *value_a, const string &value_b)
 Determines if specified values are equal.
 
template<class char_t >
static bool equals (const string &value_a, const char_t *value_b)
 Determines if specified values are equal.
 
static bool equals (long double value_a, long double value_b)
 Determines if specified values are equal.
 
static bool equals (double value_a, double value_b)
 Determines if specified values are equal.
 
static bool equals (float value_a, float value_b)
 Determines if specified values are equal.
 
static bool equals (double value_a, double value_b, double tolerance)
 Determines if specified values are equal with tolerance.
 
static bool equals (long double value_a, long double value_b, long double tolerance)
 Determines if specified values are equal with tolerance.
 
static bool equals (float value_a, float value_b, float tolerance)
 Determines if specified values are equal with tolerance.
 

Member Function Documentation

◆ abort() [1/2]

static void xtd::tunit::base_assert::abort ( const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current())
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 void abort(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Abort current test. This is used by the other assert functions.
Examples
math_assume.cpp.

◆ abort() [2/2]

static void xtd::tunit::base_assert::abort ( const xtd::string message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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]

static void xtd::tunit::base_assert::fail ( const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current())
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 void fail(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
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]

static void xtd::tunit::base_assert::fail ( const xtd::string message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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]

static void xtd::tunit::base_assert::ignore ( const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current())
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 void ignore(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Ignore current test. This is used by the other assert functions.

◆ ignore() [2/2]

static void xtd::tunit::base_assert::ignore ( const xtd::string message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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]

static void xtd::tunit::base_assert::succeed ( const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current())
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 void succeed(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Generates a success with a generic message. This is used by the other assert functions.
Examples
math_assert.cpp, math_assume.cpp, and math_valid.cpp.

◆ succeed() [2/2]

static void xtd::tunit::base_assert::succeed ( const xtd::string message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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]

static void xtd::tunit::base_assert::error ( )
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 void error()
Throws an xtd::tunit::assert_error exception. This is used by the other assert functions.
Examples
math_valid.cpp.

◆ error() [2/3]

static void xtd::tunit::base_assert::error ( const xtd::string message)
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]

static void 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() 
)
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]

static void 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() 
)
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::fail(actual_str, expected_str, "User message..."); // test throws an assert_error exception.

◆ to_string() [1/2]

template<class value_t >
static xtd::string xtd::tunit::base_assert::to_string ( const value_t &  value)
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<class value_t >
static xtd::string xtd::tunit::base_assert::to_string ( const value_t *  value)
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<class collection_t >
static xtd::string xtd::tunit::base_assert::join_items ( const collection_t &  collection)
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]

static xtd::string xtd::tunit::base_assert::join_items ( const xtd::string str)
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<class value_a_t , class value_b_t >
static bool xtd::tunit::base_assert::equals ( const value_a_t &  value_a,
const value_b_t &  value_b 
)
inlinestaticprotected

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<class char_t >
static bool xtd::tunit::base_assert::equals ( const char_t *  value_a,
const string value_b 
)
inlinestaticprotected

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<class char_t >
static bool xtd::tunit::base_assert::equals ( const string value_a,
const char_t *  value_b 
)
inlinestaticprotected

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]

static bool xtd::tunit::base_assert::equals ( long double  value_a,
long double  value_b 
)
inlinestaticprotected

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]

static bool xtd::tunit::base_assert::equals ( double  value_a,
double  value_b 
)
inlinestaticprotected

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]

static bool xtd::tunit::base_assert::equals ( float  value_a,
float  value_b 
)
inlinestaticprotected

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]

static bool xtd::tunit::base_assert::equals ( double  value_a,
double  value_b,
double  tolerance 
)
inlinestaticprotected

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]

static bool xtd::tunit::base_assert::equals ( long double  value_a,
long double  value_b,
long double  tolerance 
)
inlinestaticprotected

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]

static bool xtd::tunit::base_assert::equals ( float  value_a,
float  value_b,
float  tolerance 
)
inlinestaticprotected

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: