xtd 0.2.0
test_method_attribute.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "test_state.hpp"
6#include <xtd/diagnostics/stack_frame>
7#include <xtd/string>
8
10namespace xtd {
12 namespace tunit {
24 public:
26
33 template<class test_class_t>
34 test_method_attribute(const xtd::string& name, test_class_t& test_class, void (test_class_t::*method)(), const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) noexcept : test_method_attribute(name, test_class, method, xtd::tunit::test_state::considered, stack_frame) {}
41 template<class test_class_t>
42 test_method_attribute(const xtd::string& name, test_class_t& test_class, void (test_class_t::*method)(), xtd::tunit::test_state test_state, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) noexcept {test_class.add_test_method({name, std::bind(method, &test_class), test_state == xtd::tunit::test_state::ignored, stack_frame});}
44 };
45 }
46}
47
57#define ignore_test_method_(method_name) \
58 __##method_name##_unused() = delete; \
59 struct __##method_name##_attribute##_class : xtd::tunit::test_method_attribute { \
60 template<class test_class> __##method_name##_attribute##_class(test_class& test) : test_method_attribute(#method_name, test, &test_class::method_name, xtd::tunit::test_state::ignored) {} \
61 } __##method_name##_attribute {*this}; \
62 void method_name()
63
72#define test_method_(method_name) \
73 __##method_name##_unused() = delete; \
74 struct __##method_name##_attribute##_class : xtd::tunit::test_method_attribute { \
75 template<class test_class> __##method_name##_attribute##_class(test_class& test) : test_method_attribute(#method_name, test, &test_class::method_name) {} \
76 } __##method_name##_attribute {*this}; \
77 void method_name()
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:48
static stack_frame current(const xtd::diagnostics::source_location &value=xtd::diagnostics::source_location::current()) noexcept
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
Represents a test class.
Definition test_class.hpp:39
void add_test_method(const xtd::tunit::test &test) noexcept
Adds a test method.
test_method_attribute(const xtd::string &name, test_class_t &test_class, void(test_class_t::*method)(), xtd::tunit::test_state test_state, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) noexcept
Creates a new instance of test_method_attribute with specified name, test_class, method,...
Definition test_method_attribute.hpp:42
test_method_attribute(const xtd::string &name, test_class_t &test_class, void(test_class_t::*method)(), const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) noexcept
Creates a new instance of test_method_attribute with specified name, test_class, method,...
Definition test_method_attribute.hpp:34
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
test_state
Represent the test state enumeration used bu test.
Definition test_state.hpp:17
@ considered
Test is considered.
Definition test_state.hpp:19
@ ignored
Test is ignored.
Definition test_state.hpp:21
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
Contains xtd::tunit::test_state enum class.