xtd 0.2.0
test_method_attribute.h
Go to the documentation of this file.
1 #pragma once
5 #include "test.h"
6 #include "test_state.h"
7 
9 namespace xtd {
11  namespace tunit {
23  public:
25 
31  template<typename test_class_t>
32  test_method_attribute(const std::string& name, test_class_t& test_class, void (test_class_t::*method)()) noexcept : test_method_attribute(name, test_class, method, xtd::tunit::test_state::considered, xtd::diagnostics::stack_frame()) {}
33 
39  template<typename test_class_t>
40  test_method_attribute(const std::string& name, test_class_t& test_class, void (test_class_t::*method)(), const xtd::diagnostics::stack_frame& stack_frame) noexcept : test_method_attribute(name, test_class, method, xtd::tunit::test_state::considered, stack_frame) {}
41 
47  template<typename test_class_t>
48  test_method_attribute(const std::string& name, test_class_t& test_class, void (test_class_t::*method)(), xtd::tunit::test_state test_state) noexcept : test_method_attribute(name, test_class, method, test_state, xtd::diagnostics::stack_frame()) {}
49 
56  template<typename test_class_t>
57  test_method_attribute(const std::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) noexcept {test_class.add_test_method({name, std::bind(method, &test_class), test_state == xtd::tunit::test_state::ignored, stack_frame});}
59  };
60  }
61 }
62 
72 #define ignore_test_method_(method_name) \
73  __##method_name##_unused() = delete; \
74  class __##method_name##_attribute##_class : public xtd::tunit::test_method_attribute { \
75  public:\
76  template<typename test_class> __##method_name##_attribute##_class(test_class& test) : test_method_attribute(#method_name, test, &test_class::method_name, xtd::tunit::test_state::ignored, {__FILE__, __LINE__, __func__}) {} \
77  } __##method_name##_attribute {*this}; \
78  void method_name()
79 
88 #define test_method_(method_name) \
89  __##method_name##_unused() = delete; \
90  class __##method_name##_attribute##_class : public xtd::tunit::test_method_attribute { \
91  public:\
92  template<typename test_class> __##method_name##_attribute##_class(test_class& test) : test_method_attribute(#method_name, test, &test_class::method_name, {__FILE__, __LINE__, __func__}) {} \
93  } __##method_name##_attribute {*this}; \
94  void method_name()
test_method_attribute(const std::string &name, test_class_t &test_class, void(test_class_t::*method)()) noexcept
Creates a new instance of test_method_attribute with specified name, test_class, and method...
Definition: test_method_attribute.h:32
Contains xtd::tunit::test class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
test_method_attribute(const std::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) noexcept
Creates a new instance of test_method_attribute with specified name, test_class, method, stack frame and tes state.
Definition: test_method_attribute.h:57
Represents a test class.
Definition: test_class.h:39
test_method_attribute(const std::string &name, test_class_t &test_class, void(test_class_t::*method)(), xtd::tunit::test_state test_state) noexcept
Creates a new instance of test_method_attribute with specified name, test_class, method, and tes state.
Definition: test_method_attribute.h:48
Represents a test method attribute.
Definition: test_method_attribute.h:22
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:37
test_method_attribute(const std::string &name, test_class_t &test_class, void(test_class_t::*method)(), const xtd::diagnostics::stack_frame &stack_frame) noexcept
Creates a new instance of test_method_attribute with specified name, test_class, method, and stack frame.
Definition: test_method_attribute.h:40
test_state
Represent the test state enumeration used bu test.
Definition: test_state.h:18
Contains xtd::tunit::test_state enum class.