6#include "../tunit_export.h"
25 enum class test_status {
36 test(
const std::string& name,
const std::function<
void()>& method,
bool ignore,
const xtd::diagnostics::stack_frame& stack_frame) noexcept : stack_frame_(stack_frame), method_(method), name_(name), status_(ignore ? test_status::ignored : test_status::not_started) {}
38 bool aborted()
const noexcept {
return status_ == test_status::aborted;}
40 const std::string& actual()
const noexcept {
return actual_;}
42 const std::string& expect()
const noexcept {
return expect_;}
44 bool failed()
const noexcept {
return status_ == test_status::failed;}
46 bool ignored()
const noexcept {
return status_ == test_status::ignored;}
48 bool not_started()
const noexcept {
return status_ == test_status::not_started;}
50 bool succeed()
const noexcept {
return status_ == test_status::succeed;}
54 std::function<void()> method()
const noexcept {
return method_;}
56 const std::string& message()
const noexcept {
return message_;}
58 const std::string& name()
const noexcept {
return name_;}
60 const std::string& user_message()
const noexcept {
return user_message_;}
62 std::chrono::milliseconds elapsed_time()
const noexcept {
63 using namespace std::chrono_literals;
64 if (start_time_point.time_since_epoch() == 0ms && end_time_point.time_since_epoch() == 0ms)
return 0ms;
65 if (end_time_point.time_since_epoch() == 0ms)
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start_time_point);
66 return std::chrono::duration_cast<std::chrono::milliseconds>(end_time_point - start_time_point);
70 static intptr_t __internal_tunit_unit_tests_mode__;
78 static test& current_test() {
return *current_test_;}
79 static const test_class& current_test_class() {
return *current_test_class_;}
80 static const unit_test& current_unit_test() {
return *current_unit_test_;}
84 std::chrono::high_resolution_clock::time_point end_time_point;
85 static test* current_test_;
87 static const unit_test* current_unit_test_;
92 std::function<void()> method_;
94 std::chrono::high_resolution_clock::time_point start_time_point;
95 test_status status_ = test_status::not_started;
96 std::string user_message_;
Contains xtd::tunit::assert class.
Contains xtd::tunit::assert_error exception.
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:29
static stack_frame empty() noexcept
Return an empty stack frame.
The assert class contains a collection of static methods that implement the most common assertions us...
Definition assert.h:34
The base class for assert.
Definition base_assert.h:25
Definition test_class.h:25
The template class.
Definition unit_test.h:32
The valid class contains a collection of static methods that implement the most common assertions use...
Definition valid.h:20
#define tunit_export_
Define shared library export.
Definition tunit_export.h:13
@ ignored
Test is ignored.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::diagnostics::stack_frame class.