xtd 0.2.0
ostream_unit_test.cpp

Shows how to use generic xtd::tunit::ostream_unit_test class.

#include <xtd/xtd.tunit>
#include <sstream>
using namespace xtd;
using namespace xtd::tunit;
using namespace xtd::text;
namespace unit_tests {
class test_class_(test) {
void test_method_(test_case1) {
}
};
}
auto main() -> int {
// create your own ostream in this case a string stream for example
auto ss = std::stringstream {};
// create and run an ostream_unit_test
auto result = ostream_unit_test(ss).run();
// display string stream on console::out line by line
auto line = string_builder {};
while (std::getline(ss, line.chars()))
console::out << line << environment::new_line;
return result;
}
// This code can produce the following output :
//
// Start 1 test from 1 test case
// Run tests:
// SUCCEED unit_tests::test.test_case1 (0 ms total)
//
// Test results:
// SUCCEED 1 test.
// End 1 test from 1 test case ran. (0 ms total)
xtd::text::basic_string_builder< char > string_builder
Represents a mutable string of characters of UTF-8 code units. This class cannot be inherited.
Definition string_builder.hpp:19
#define test_method_(method_name)
Add test method to class test.
Definition test_method_attribute.hpp:72
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:17
The tunit namespace contains a unit test library.
Definition abort_error.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8