tunit - Reference Guide  1.0.0
Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android.
test_method_attribute.h
Go to the documentation of this file.
1 #pragma once
4 #include "test.h"
5 #include "test_state.h"
6 
8 namespace tunit {
10  public:
11  template<typename TestClass>
12  test_method_attribute(const std::string& name, TestClass& test_class, void (TestClass::*method)()) noexcept : test_method_attribute(name, test_class, method, tunit::test_state::considered, tunit::line_info()) {}
13 
14  template<typename TestClass>
15  test_method_attribute(const std::string& name, TestClass& test_class, void (TestClass::*method)(), const tunit::line_info& line_info) noexcept : test_method_attribute(name, test_class, method, tunit::test_state::considered, line_info) {}
16 
17  template<typename TestClass>
18  test_method_attribute(const std::string& name, TestClass& test_class, void (TestClass::*method)(), tunit::test_state test_state) noexcept : test_method_attribute(name, test_class, method, test_state, tunit::line_info()) {}
19 
20  template<typename TestClass>
21  test_method_attribute(const std::string& name, TestClass& test_class, void (TestClass::*method)(), tunit::test_state test_state, const tunit::line_info& line_info) noexcept {test_class.add_test_method({name, std::bind(method, &test_class), test_state == tunit::test_state::ignored, line_info});}
22  };
23 }
24 
25 #define ignore_test_method_(method_name) \
26  __##method_name##_unused() = delete; \
27  class __##method_name##_attribute##_class : public tunit::test_method_attribute { \
28  public:\
29  template<typename test_class> __##method_name##_attribute##_class(test_class& test) : test_method_attribute(#method_name, test, &test_class::method_name, tunit::test_state::ignored, {__func__, __FILE__, __LINE__}) {} \
30  } __##method_name##_attribute {*this}; \
31  void method_name()
32 
33 #define test_method_(method_name) \
34  __##method_name##_unused() = delete; \
35  class __##method_name##_attribute##_class : public tunit::test_method_attribute { \
36  public:\
37  template<typename test_class> __##method_name##_attribute##_class(test_class& test) : test_method_attribute(#method_name, test, &test_class::method_name, {__func__, __FILE__, __LINE__}) {} \
38  } __##method_name##_attribute {*this}; \
39  void method_name()
Definition: test_class.h:21
test_state
Represent the test state enumeration used bu test.
Definition: test_state.h:9
Definition: test_method_attribute.h:9
Contains tunit::test class.
line_info information class is used to store current file, current line and current function informat...
Definition: line_info.h:13
Test is considered.
The tunit namespace contains a unit test library.
Definition: abort_error.h:8
Contains tunit::test_state enum class.