tunit - Reference Guide  1.0.0
Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android.
test_cleanup_attribute.h
Go to the documentation of this file.
1 #pragma once
4 #include "test.h"
5 
7 namespace tunit {
9  public:
10  template<typename TestClass>
11  test_cleanup_attribute(const std::string& name, TestClass& test_class, void (*method)()) noexcept : test_cleanup_attribute(name, test_class, method, tunit::line_info()) {}
12 
13  template<typename TestClass>
14  test_cleanup_attribute(const std::string& name, TestClass& test_class, void (*method)(), const tunit::line_info& caller) noexcept {test_class.add_test_cleanup({name, method, caller});}
15  };
16 }
17 
18 #define test_cleanup_(method_name) \
19  __##method_name##_unused() = delete; \
20  class __test_cleanup_attribute : public tunit::test_cleanup_attribute { \
21  public:\
22  template<typename test_class> __test_cleanup_attribute(test_class& test) : test_cleanup_attribute(#method_name, test, &test_class::method_name, {__func__, __FILE__, __LINE__}) {} \
23  } __test_cleanup_attribute {*this}; \
24  static void method_name()
Definition: test_class.h:21
Contains tunit::test class.
Definition: test_cleanup_attribute.h:8
line_info information class is used to store current file, current line and current function informat...
Definition: line_info.h:13
The tunit namespace contains a unit test library.
Definition: abort_error.h:8