xtd 0.2.0
xtd::tunit::base_assert Class Reference

#include <base_assert.h>

Definition

The base class for assert.

Namespace
xtd::tunit
Library
xtd.tunit
Examples:
math_assert.cpp.

Methods

static void abort ()
 Abort current test. This is used by the other assert functions. More...
 
static void abort (const xtd::diagnostics::stack_frame &stack_frame)
 Abort current test. This is used by the other assert functions. More...
 
static void abort (const std::string &message)
 Abort current test. This is used by the other assert functions. More...
 
static void abort (const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Abort current test. This is used by the other assert functions. More...
 
static void fail ()
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void fail (const xtd::diagnostics::stack_frame &stack_frame)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void fail (const std::string &message)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void fail (const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void ignore ()
 Ignore current test. This is used by the other assert functions. More...
 
static void ignore (const xtd::diagnostics::stack_frame &stack_frame)
 Ignore current test. This is used by the other assert functions. More...
 
static void ignore (const std::string &message)
 Ignore current test. This is used by the other assert functions. More...
 
static void ignore (const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Ignore current test. This is used by the other assert functions. More...
 
static void succeed ()
 Generates a success with a generic message. This is used by the other assert functions. More...
 
static void succeed (const xtd::diagnostics::stack_frame &stack_frame)
 Generates a success with a generic message. This is used by the other assert functions. More...
 
static void succeed (const std::string &message)
 Generates a success with a generic message. This is used by the other assert functions. More...
 
static void succeed (const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Generates a success with a generic message. This is used by the other assert functions. More...
 

Protected methods

static void error ()
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void error (const std::string &message)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void error (const std::string &actual, const std::string &expected, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
static void fail (const std::string &actual, const std::string &expected, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame)
 Throws an xtd::tunit::assert_error exception. This is used by the other assert functions. More...
 
template<typename value_t >
static std::string to_string (const value_t &value)
 Convert specified value to std::string. More...
 
template<typename value_t >
static std::string to_string (const value_t *value)
 Convert specified value to std::string. More...
 
template<typename collection_t >
static std::string join_items (const collection_t &collection)
 Join specified collection into std::string. More...
 
static std::string join_items (const std::string &str)
 Join specified string into std::string. More...
 

Member Function Documentation

◆ abort() [1/4]

static void xtd::tunit::base_assert::abort ( )
static

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

Examples
xtd::tunit::assert::abort(); // test throws an abort_error exception.
Examples:
assert_abort.cpp.

◆ abort() [2/4]

static void xtd::tunit::base_assert::abort ( const xtd::diagnostics::stack_frame stack_frame)
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(csf_); // test throws an abort_error exception.

◆ abort() [3/4]

static void xtd::tunit::base_assert::abort ( const std::string &  message)
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.
Examples
xtd::tunit::assert::abort("User message..."); // test throws an abort_error exception.

◆ abort() [4/4]

static void xtd::tunit::base_assert::abort ( const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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...", csf_); // test throws an abort_error exception.

◆ 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.

◆ error() [2/3]

static void xtd::tunit::base_assert::error ( const std::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 std::string &  actual,
const std::string &  expected,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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...", csf_); // test throws an assert_error exception.

◆ fail() [1/5]

static void xtd::tunit::base_assert::fail ( )
static

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(); // test throws an assert_error exception.
Examples:
assert_fail.cpp, generic_test_class.cpp, and math_assert.cpp.

◆ fail() [2/5]

static void xtd::tunit::base_assert::fail ( const xtd::diagnostics::stack_frame stack_frame)
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(csf_); // test throws an assert_error exception.

◆ fail() [3/5]

static void xtd::tunit::base_assert::fail ( const std::string &  message)
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.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::assert::fail("User message..."); // test throws an assert_error exception.

◆ fail() [4/5]

static void xtd::tunit::base_assert::fail ( const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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...", csf_); // test throws an assert_error exception.

◆ fail() [5/5]

static void xtd::tunit::base_assert::fail ( const std::string &  actual,
const std::string &  expected,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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...", csf_); // test throws an assert_error exception.

◆ ignore() [1/4]

static void xtd::tunit::base_assert::ignore ( )
static

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

Examples
xtd::tunit::assert::ignore(); // test throws an ignore_error exception.
Examples:
assert_ignore.cpp.

◆ ignore() [2/4]

static void xtd::tunit::base_assert::ignore ( const xtd::diagnostics::stack_frame stack_frame)
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(csf_); // test throws an ignore_error exception.

◆ ignore() [3/4]

static void xtd::tunit::base_assert::ignore ( const std::string &  message)
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.
Examples
xtd::tunit::assert::ignore("User message..."); // test throws an ignore_error exception.

◆ ignore() [4/4]

static void xtd::tunit::base_assert::ignore ( const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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...", csf_); // test throws an ignore_error exception.

◆ join_items() [1/2]

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

Join specified collection into std::string.

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

◆ join_items() [2/2]

static std::string xtd::tunit::base_assert::join_items ( const std::string &  str)
staticprotected

Join specified string into std::string.

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

◆ succeed() [1/4]

static void xtd::tunit::base_assert::succeed ( )
static

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

Examples
Examples:
assert_succeed.cpp, and math_assert.cpp.

◆ succeed() [2/4]

static void xtd::tunit::base_assert::succeed ( const xtd::diagnostics::stack_frame stack_frame)
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

◆ succeed() [3/4]

static void xtd::tunit::base_assert::succeed ( const std::string &  message)
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
xtd::tunit::assert::succeed("User message..."); // test ok.

◆ succeed() [4/4]

static void xtd::tunit::base_assert::succeed ( const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame 
)
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...", csf_); // test ok.

◆ to_string() [1/2]

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

Convert specified value to std::string.

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

◆ to_string() [2/2]

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

Convert specified value to std::string.

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

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