xtd 0.2.0
Loading...
Searching...
No Matches
collection_assume_all_items_are_instances_of.cpp

Shows how to use xtd::tunit::collection_assume::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_assume::all_items_are_instances_of<std::ios_base*>(a);
}
void test_method_(test_case_aborted) {
auto a = generic::list<std::ios_base*>{&console::out, &console::error, &console::in};
collection_assume::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)
// ABORTED test.test_case_aborted (0 ms total)
// Test aborted
// 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_assume_all_items_are_instances_of.cpp:13
//
// Test results:
// SUCCEED 1 test.
// ABORTED 1 test.
// End 2 tests from 1 test case ran. (1 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 namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.h:12
The tunit namespace contains a unit test library.
Definition abort_error.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10