xtd - Reference Guide  0.1.0
Modern c++17 framework to create console, gui and unit test applications on Windows, macOS and Linux.
xtd::tunit::collection_assume Class Referencefinal

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

#include <collection_assume.h>

Inheritance diagram for xtd::tunit::collection_assume:
xtd::tunit::base_assert

Static Public Member Functions

template<typename TExpected , typename TCollection >
static void all_items_are_instances_of (const TCollection &collection)
 Assumes that all collection items are of the type supplied or a derived type. More...
 
template<typename TExpected , typename TCollection >
static void all_items_are_instances_of (const TCollection &collection, const std::string &message)
 Assumes that all collection items are of the type supplied or a derived type. More...
 
template<typename TExpected , typename TCollection >
static void all_items_are_instances_of (const TCollection &collection, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are of the type supplied or a derived type. More...
 
template<typename TExpected , typename TCollection >
static void all_items_are_instances_of (const TCollection &collection, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are of the type supplied or a derived type. More...
 
template<typename TCollection >
static void all_items_are_not_null (const TCollection &collection)
 Assumes that all collection items are not null. More...
 
template<typename TCollection >
static void all_items_are_not_null (const TCollection &collection, const std::string &message)
 Assumes that all collection items are not null. More...
 
template<typename TCollection >
static void all_items_are_not_null (const TCollection &collection, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are not null. More...
 
template<typename TCollection >
static void all_items_are_not_null (const TCollection &collection, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are not null. More...
 
template<typename TCollection >
static void all_items_are_unique (const TCollection &collection)
 Assumes that all collection items are unique. More...
 
template<typename TCollection >
static void all_items_are_unique (const TCollection &collection, const std::string &message)
 Assumes that all collection items are unique. More...
 
template<typename TCollection >
static void all_items_are_unique (const TCollection &collection, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are unique. More...
 
template<typename TCollection >
static void all_items_are_unique (const TCollection &collection, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are unique. More...
 
template<typename TExpected , typename TAcutal >
static void are_equal (const TExpected &expected, const TAcutal &actual)
 Assumes that all collection items are equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_equal (const TExpected &expected, const TAcutal &actual, const std::string &message)
 Assumes that all collection items are equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_equal (const TExpected &expected, const TAcutal &actual, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_equal (const TExpected &expected, const TAcutal &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_equivalent (const TExpected &expected, const TAcutal &actual)
 Assumes that all collection items are equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_equivalent (const TExpected &expected, const TAcutal &actual, const std::string &message)
 Assumes that all collection items are equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_equivalent (const TExpected &expected, const TAcutal &actual, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_equivalent (const TExpected &expected, const TAcutal &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equal (const TExpected &expected, const TAcutal &actual)
 Assumes that all collection items are not equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equal (const TExpected &expected, const TAcutal &actual, const std::string &message)
 Assumes that all collection items are not equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equal (const TExpected &expected, const TAcutal &actual, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are not equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equal (const TExpected &expected, const TAcutal &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items arenot equal. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equivalent (const TExpected &expected, const TAcutal &actual)
 Assumes that all collection items are not equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equivalent (const TExpected &expected, const TAcutal &actual, const std::string &message)
 Assumes that all collection items are not equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equivalent (const TExpected &expected, const TAcutal &actual, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are not equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void are_not_equivalent (const TExpected &expected, const TAcutal &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that all collection items are not equivalent. More...
 
template<typename TExpected , typename TAcutal >
static void contains (const TExpected &expected, const TAcutal &actual)
 Assumes that ollection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void contains (const TExpected &expected, const TAcutal &actual, const std::string &message)
 Assumes that collection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void contains (const TExpected &expected, const TAcutal &actual, const xtd::tunit::line_info &line_info)
 Assumes that collection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void contains (const TExpected &expected, const TAcutal &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that collection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void does_not_contain (const TExpected &expected, const TAcutal &actual)
 Assumes that ollection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void does_not_contain (const TExpected &expected, const TAcutal &actual, const std::string &message)
 Assumes that collection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void does_not_contain (const TExpected &expected, const TAcutal &actual, const xtd::tunit::line_info &line_info)
 Assumes that collection contains all items. More...
 
template<typename TExpected , typename TAcutal >
static void does_not_contain (const TExpected &expected, const TAcutal &actual, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that collection contains all items. More...
 
template<typename TValue >
static void is_empty (const TValue &value)
 Assumes that collection contains an item. More...
 
template<typename TValue >
static void is_empty (const TValue &value, const xtd::tunit::line_info &line_info)
 Assumes that collection contains an item. More...
 
template<typename TValue >
static void is_empty (const TValue &value, const std::string &message)
 Assumes that collection contains an item. More...
 
template<typename TValue >
static void is_empty (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that collection contains an item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value)
 Assumes that collection does not contain any item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value, const xtd::tunit::line_info &line_info)
 Assumes that collection or traits does not contain any item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value, const std::string &message)
 Assumes that collection or traits does not contain any item. More...
 
template<typename TValue >
static void is_not_empty (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that collection or traits does not contain any item. More...
 
template<typename TValue >
static void is_ordered (const TValue &value)
 Assumes that collection is ordered. More...
 
template<typename TValue >
static void is_ordered (const TValue &value, const xtd::tunit::line_info &line_info)
 Assumes that collection is ordered. More...
 
template<typename TValue >
static void is_ordered (const TValue &value, const std::string &message)
 Assumes that collection is ordered. More...
 
template<typename TValue >
static void is_ordered (const TValue &value, const std::string &message, const xtd::tunit::line_info &line_info)
 Assumes that collection is ordered. More...
 

Static Private Member Functions

static void abort ()
 Abort current test. This is used by the other Assert functions. More...
 
static void abort (const xtd::tunit::line_info &line_info)
 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::tunit::line_info &line_info)
 Abort current test. This is used by the other Assert functions. More...
 
static void error ()
 
static void error (const std::string &actual, const std::string &expected, const std::string &message, const xtd::tunit::line_info &line_info)
 
static void fail ()
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void fail (const xtd::tunit::line_info &line_info)
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void fail (const std::string &message)
 Throws an xtd::tunit::assertion_error exception. This is used by the other Assert functions. More...
 
static void fail (const std::string &message, const xtd::tunit::line_info &line_info)
 Throws an xtd::tunit::assertion_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::tunit::line_info &line_info)
 
static void ignore ()
 Ignore current test. This is used by the other Assert functions. More...
 
static void ignore (const xtd::tunit::line_info &line_info)
 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::tunit::line_info &line_info)
 Ignore current test. This is used by the other Assert functions. More...
 
template<typename TCollection >
static std::string join_items (const TCollection &collection)
 
static std::string join_items (const std::string &str)
 
static void succeed ()
 Generates a success with a generic message. This is used by the other Assert functions. More...
 
static void succeed (const xtd::tunit::line_info &line_info)
 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::tunit::line_info &line_info)
 Generates a success with a generic message. This is used by the other Assert functions. More...
 
template<typename TValue >
static std::string to_string (const TValue &value)
 
template<typename TValue >
static std::string to_string (const TValue *value)
 

Detailed Description

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

Examples
This example show how to used some methods :
#include <xtd/xtd.tunit>
#include <stdexcept>
using namespace xtd::tunit;
namespace unit_tests {
// The class test must be declared with test_class_ helper.
class test_class_(test) {
public:
void test_method_(test_case1) {
}
void test_method_(test_case2) {
}
void test_method_(test_case3) {
assert::does_not_throw([] {throw std::range_error("error");});
}
};
}
int main() {
return console_unit_test().run();
}
// This code can produce the following output:
//
// Start 3 tests from 1 test case
// Run tests:
// SUCCEED test.test_case1 (0 ms total)
// FAILED test.test_case2 (0 ms total)
// Expected: false
// But was: true
// Stack Trace: in /Users/yves/Projects/xtd/examples/xtd.tunit.examples/assert/src/assert.cpp:14
// FAILED test.test_case3 (0 ms total)
// Expected: No Exception to be thrown
// But was: <std::range_error>
// Stack Trace: in /Users/yves/Projects/xtd/examples/xtd.tunit.examples/assert/src/assert.cpp:18
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. (0 ms total)

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