xtd 0.2.0
Loading...
Searching...
No Matches
xtd::tunit::collection_assert Class Referencefinal
Inheritance diagram for xtd::tunit::collection_assert:
xtd::tunit::base_assert

Definition

The collection_assert class contains a collection of static methods that implement the most collection 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>
using namespace xtd::collections::generic;
using namespace xtd::tunit;
namespace unit_tests {
// The class test must be declared with test_class_ helper.
class test_class_(test) {
void test_method_(test_case1) {
collection_assert::is_empty(list<int> {});
}
void test_method_(test_case2) {
collection_assert::is_empty(list {1, 2, 3});
}
void test_method_(test_case3) {
collection_assert::is_ordered(list {1, 3, 2});
}
};
}
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 (0 ms total)
// FAILED unit_tests::test.test_case2 (0 ms total)
// Expected: <empty>
// But was: < 1, 2, 3 >
// Stack Trace: in |---OMITTED---|/collection_assert.cpp:14
// FAILED unit_tests::test.test_case3 (0 ms total)
// Expected: < 1, 2, 3 >
// But was: < 1, 3, 2 >
// Stack Trace: in |---OMITTED---|/collection_assert.cpp:18
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. (0 ms total)
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:71
The console_unit_test class is console unit test interface.
Definition console_unit_test.h:23
int32 run() noexcept
Runs all tests in this unit_test object and prints the result.
#define test_method_(method_name)
Add test method to class test.
Definition test_method_attribute.h:89
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.h:15
The tunit namespace contains a unit test library.
Definition abort_error.h:10

Public Static Methods

template<typename expected_t , typename collection_t >
static void all_items_are_instances_of (const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are of the type supplied or a derived type.
 
template<typename expected_t , typename collection_t >
static void all_items_are_instances_of (const collection_t &collection, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are of the type supplied or a derived type.
 
template<typename collection_t >
static void all_items_are_not_null (const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are not null.
 
template<typename collection_t >
static void all_items_are_not_null (const collection_t &collection, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are not null.
 
template<typename collection_t >
static void all_items_are_unique (const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are unique.
 
template<typename collection_t >
static void all_items_are_unique (const collection_t &collection, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are unique.
 
template<typename expected_t , typename actual_t >
static void are_equal (const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are equal.
 
template<typename expected_t , typename actual_t >
static void are_equal (const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are equal.
 
template<typename expected_t , typename actual_t >
static void are_equivalent (const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are equivalent.
 
template<typename expected_t , typename actual_t >
static void are_equivalent (const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are equivalent.
 
template<typename expected_t , typename actual_t >
static void are_not_equal (const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are not equal.
 
template<typename expected_t , typename actual_t >
static void are_not_equal (const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are not equal.
 
template<typename expected_t , typename actual_t >
static void are_not_equivalent (const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are not equivalent.
 
template<typename expected_t , typename actual_t >
static void are_not_equivalent (const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that all collection items are not equivalent.
 
template<typename expected_t , typename actual_t >
static void contains (const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection contains all items.
 
template<typename expected_t , typename actual_t >
static void contains (const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection contains all items.
 
template<typename expected_t , typename actual_t >
static void does_not_contain (const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection contains all items.
 
template<typename expected_t , typename actual_t >
static void does_not_contain (const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection contains all items.
 
template<typename value_t >
static void is_empty (const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection contains an item.
 
template<typename value_t >
static void is_empty (const value_t &value, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection contains an item.
 
template<typename value_t >
static void is_not_empty (const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection or traits does not contain any item.
 
template<typename value_t >
static void is_not_empty (const value_t &value, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection or traits does not contain any item.
 
template<typename value_t >
static void is_ordered (const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection is ordered.
 
template<typename value_t >
static void is_ordered (const value_t &value, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Asserts that collection is ordered.
 

Member Function Documentation

◆ all_items_are_instances_of() [1/2]

template<typename expected_t , typename collection_t >
static void xtd::tunit::collection_assert::all_items_are_instances_of ( const collection_t &  collection,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are 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::vector<std::ios_base*> a = {&std::cout, &std::cerr, &std::cin};
xtd::tunit::collection_assert::all_items_are_instances_of<std::ios_base*>(a); // test ok.
xtd::tunit::collection_assert::all_items_are_instances_of<std::basic_ostream<char>*>(a); // test throws an assert_error exception.
@ a
The A key.

◆ all_items_are_instances_of() [2/2]

template<typename expected_t , typename collection_t >
static void xtd::tunit::collection_assert::all_items_are_instances_of ( const collection_t &  collection,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are 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::vector<std::ios_base*> a = {&std::cout, &std::cerr, &std::cin};
xtd::tunit::collection_assert::all_items_are_instances_of<std::ios_base*>(a, "User message..."); // test ok.
xtd::tunit::collection_assert::all_items_are_instances_of<std::basic_ostream<char>*>(a, "User message..."); // test throws an assert_error exception.

◆ all_items_are_not_null() [1/2]

template<typename collection_t >
static void xtd::tunit::collection_assert::all_items_are_not_null ( const collection_t &  collection,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are not null.

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
int i1 = 0, i2 = 3;
std::vector<int*> a1 = {&i1, &i2};
std::vector<int*> a2 = {&i1, &i2, nullptr};
xtd::tunit::collection_assert::all_items_are_not_null(a2); // test throws an assert_error exception.
static void all_items_are_not_null(const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not null.
Definition collection_assert.h:94

◆ all_items_are_not_null() [2/2]

template<typename collection_t >
static void xtd::tunit::collection_assert::all_items_are_not_null ( const collection_t &  collection,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are not null.

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
int i1 = 0, i2 = 3;
std::vector<int*> a1 = {&i1, &i2};
xtd::tunit::collection_assert::all_items_are_not_null(a1, "User message..."); // test ok.
std::vector<int*> a2 = {&i1, &i2, nullptr};
xtd::tunit::collection_assert::all_items_are_not_null(a2, "User message..."); // test throws an assert_error exception.

◆ all_items_are_unique() [1/2]

template<typename collection_t >
static void xtd::tunit::collection_assert::all_items_are_unique ( const collection_t &  collection,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are unique.

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::vector<int> a1 = {1, 2, 3, 4};
std::vector<int> a2 = {1, 2, 3, 4, 1};
xtd::tunit::collection_assert::all_items_are_unique(a2); // test throws an assert_error exception.
static void all_items_are_unique(const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are unique.
Definition collection_assert.h:145

◆ all_items_are_unique() [2/2]

template<typename collection_t >
static void xtd::tunit::collection_assert::all_items_are_unique ( const collection_t &  collection,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are unique.

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::vector<int> a1 = {1, 2, 3, 4};
xtd::tunit::collection_assert::all_items_are_unique(a1, "User message..."); // test ok.
std::vector<int> a2 = {1, 2, 3, 4, 1};
xtd::tunit::collection_assert::all_items_are_unique(a2, "User message..."); // test throws an assert_error exception.

◆ are_equal() [1/2]

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

Asserts that all collection items are equal.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_equal({1, 2, 3, 4}, a); // test ok.
xtd::tunit::collection_assert::are_equal({4, 3, 2, 1}, a); // test throws an assert_error exception.
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are equal.
Definition collection_assert.h:197

◆ are_equal() [2/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::are_equal ( const expected_t &  expected,
const actual_t &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are equal.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_equal({1, 2, 3, 4}, a, "User message..."); // test ok.
xtd::tunit::collection_assert::are_equal({4, 3, 2, 1}, a, "User message..."); // test throws an assert_error exception.

◆ are_equivalent() [1/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::are_equivalent ( const expected_t &  expected,
const actual_t &  actual,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are equivalent.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_equivalent({1, 2, 3, 5}, a); // test throws an assert_error exception.
static void are_equivalent(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are equivalent.
Definition collection_assert.h:259

◆ are_equivalent() [2/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::are_equivalent ( const expected_t &  expected,
const actual_t &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are equivalent.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_equivalent({4, 3, 2, 1}, a, "User message..."); // test ok.
xtd::tunit::collection_assert::are_equivalent({1, 2, 3, 5}, a, "User message..."); // test throws an assert_error exception.

◆ are_not_equal() [1/2]

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

Asserts that all collection items are not equal.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_not_equal({1, 2, 3, 4}, a); // test throws an assert_error exception.
static void are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not equal.
Definition collection_assert.h:321

◆ are_not_equal() [2/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::are_not_equal ( const expected_t &  expected,
const actual_t &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are not equal.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_not_equal({4, 3, 2, 1}, a, "User message..."); // test ok.
xtd::tunit::collection_assert::are_not_equal({1, 2, 3, 4}, a, "User message..."); // test throws an assert_error exception.

◆ are_not_equivalent() [1/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::are_not_equivalent ( const expected_t &  expected,
const actual_t &  actual,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are not equivalent.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_not_equivalent({4, 3, 2, 1}, a); // test throws an assert_error exception.
static void are_not_equivalent(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not equivalent.
Definition collection_assert.h:383

◆ are_not_equivalent() [2/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::are_not_equivalent ( const expected_t &  expected,
const actual_t &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that all collection items are not equivalent.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::are_not_equivalent({1, 2, 3, 5}, a, "User message..."); // test ok.
xtd::tunit::collection_assert::are_not_equivalent({4, 3, 2, 1}, a, "User message..."); // test throws an assert_error exception.

◆ contains() [1/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::contains ( const expected_t &  expected,
const actual_t &  actual,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection contains all items.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::contains({1, 2, 6}, a); // test throws an assert_error exception.
static void contains(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains all items.
Definition collection_assert.h:445

◆ contains() [2/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::contains ( const expected_t &  expected,
const actual_t &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection contains all items.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::contains({1, 2}, a, "User message..."); // test ok.
xtd::tunit::collection_assert::contains({1, 2, 6}, a, "User message..."); // test throws an assert_error exception.

◆ does_not_contain() [1/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::does_not_contain ( const expected_t &  expected,
const actual_t &  actual,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection contains all items.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::does_not_contain({1, 2}, a); // test throws an assert_error exception.
static void does_not_contain(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains all items.
Definition collection_assert.h:519

◆ does_not_contain() [2/2]

template<typename expected_t , typename actual_t >
static void xtd::tunit::collection_assert::does_not_contain ( const expected_t &  expected,
const actual_t &  actual,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection contains all items.

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::vector<int> a = {1, 2, 3, 4};
xtd::tunit::collection_assert::does_not_contain({1, 2, 6}, a, "User message..."); // test ok.
xtd::tunit::collection_assert::does_not_contain({1, 2}, a, "User message..."); // test throws an assert_error exception.

◆ is_empty() [1/2]

template<typename value_t >
static void xtd::tunit::collection_assert::is_empty ( const value_t &  value,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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
std::vector<int> v1;
std::vector<int> v2 = {0, 1, 2, 3};
xtd::tunit::collection_assert::is_empty(v2); // test throws an assert_error exception.
static void is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains an item.
Definition collection_assert.h:593

◆ is_empty() [2/2]

template<typename value_t >
static void xtd::tunit::collection_assert::is_empty ( const value_t &  value,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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
std::vector<int> v1;
std::vector<int> v2 = {0, 1, 2, 3};
xtd::tunit::collection_assert::is_empty(v1, "User message..."); // test ok.
xtd::tunit::collection_assert::is_empty(v2, "User message..."); // test throws an assert_error exception.

◆ is_not_empty() [1/2]

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

Asserts that collection or traits 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
std::vector<int> v1 = {0, 1, 2, 3};
std::vector<int> v2;
xtd::tunit::collection_assert::is_not_empty(v2); // test throws an assert_error exception.
static void is_not_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection or traits does not contain any item.
Definition collection_assert.h:638

◆ is_not_empty() [2/2]

template<typename value_t >
static void xtd::tunit::collection_assert::is_not_empty ( const value_t &  value,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection or traits 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
std::vector<int> v1 = {0, 1, 2, 3};
std::vector<int> v2;
xtd::tunit::collection_assert::is_not_empty(v1, "User message..."); // test ok.
xtd::tunit::collection_assert::is_not_empty(v2, "User message..."); // test throws an assert_error exception.

◆ is_ordered() [1/2]

template<typename value_t >
static void xtd::tunit::collection_assert::is_ordered ( const value_t &  value,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection is ordered.

Parameters
valueThe value to check is empty.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
std::vector<int> v1 = {1, 2, 3, 4};
std::vector<int> v2 = {1, 2, 4, 3};
xtd::tunit::collection_assert::is_ordered(v2); // test throws an assert_error exception.
static void is_ordered(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection is ordered.
Definition collection_assert.h:683

◆ is_ordered() [2/2]

template<typename value_t >
static void xtd::tunit::collection_assert::is_ordered ( const value_t &  value,
const std::string &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inlinestatic

Asserts that collection is ordered.

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
std::vector<int> v1 = {1, 2, 3, 4};
std::vector<int> v2 = {1, 2, 4, 3};
xtd::tunit::collection_assert::is_ordered(v1, "User message..."); // test ok.
xtd::tunit::collection_assert::is_ordered(v2, "User message..."); // test throws an assert_error exception.

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