xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
collection_assert_all_items_are_instances_of.cpp
Shows how to use
xtd::tunit::collection_assert::all_items_are_instances_of
method.
#include <xtd/xtd.tunit>
using namespace
xtd
;
using namespace
xtd::collections
;
using namespace
xtd::tunit
;
namespace
unit_tests {
class
test_class_(test) {
void
test_method_
(test_case_succeed) {
auto
a =
generic::list<std::ios_base*>
{&
console::out
, &
console::error
, &
console::in
};
collection_assert::all_items_are_instances_of<std::ios_base*>
(a);
}
void
test_method_
(test_case_failed) {
auto
a =
generic::list<std::ios_base*>
{&
console::out
, &
console::error
, &
console::in
};
collection_assert::all_items_are_instances_of<std::basic_ostream<char>
*>(a);
}
};
}
auto
main() ->
int
{
return
console_unit_test
().
run
();
}
// This code produces the following output :
//
// Start 2 tests from 1 test case
// Run tests:
// SUCCEED unit_tests::test.test_case_succeed (0 ms total)
// FAILED unit_tests::test.test_case_failed (0 ms total)
// Expected: all items instance of <std::basic_ostream<char, std::char_traits<char> >*>
// But was: < 8-byte object <78-37 1D-8C FF-7F 00-00>, 8-byte object <B8-38 1D-8C FF-7F 00-00>, 8-byte object <30-36 1D-8C FF-7F 00-00> >
// Stack Trace: in |---OMITTED---|/collection_assert_all_items_are_instances_of.cpp:13
//
// Test results:
// SUCCEED 1 test.
// FAILED 1 test.
// End 2 tests from 1 test case ran. (1 ms total)
xtd::collections::generic::list
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition
list.hpp:80
xtd::console::error
static std::ostream error
Gets the error output stream. A std::basic_ostream<char_t> that represents the error output stream.
Definition
console.hpp:42
xtd::console::in
static std::istream in
Gets the standard input stream. A std::basic_istream<char_t> that represents the standard input strea...
Definition
console.hpp:47
xtd::console::out
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition
console.hpp:52
xtd::tunit::collection_assert::all_items_are_instances_of
static auto all_items_are_instances_of(const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) -> void
Asserts that all collection items are of the type supplied or a derived type.
Definition
collection_assert.hpp:44
xtd::tunit::console_unit_test
The console_unit_test class is console unit test interface.
Definition
console_unit_test.hpp:23
xtd::tunit::console_unit_test::run
auto run() noexcept -> xtd::int32
Runs all tests in this unit_test object and prints the result.
test_method_
#define test_method_(method_name)
Add test method to class test.
Definition
test_method_attribute.hpp:72
xtd::collections
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition
any_pair.hpp:10
xtd::tunit
The tunit namespace contains a unit test library.
Definition
abort_error.hpp:10
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
Generated on
for xtd by
Gammasoft
. All rights reserved.