tunit - Reference Guide  1.0.0
Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android.
class_cleanup_attribute.h
Go to the documentation of this file.
1 #pragma once
4 #include "test.h"
5 
7 namespace tunit {
10  public:
15  template<typename TestClass>
16  class_cleanup_attribute(const std::string& name, TestClass& test_class, void (*method)()) noexcept : class_cleanup_attribute(name, test_class, method, tunit::line_info()) {}
17 
23  template<typename TestClass>
24  class_cleanup_attribute(const std::string& name, TestClass& test_class, void (*method)(), const tunit::line_info& line_info) noexcept {test_class.add_class_cleanup({name, method, line_info});}
25  };
26 }
27 
31 #define class_cleanup_(method_name) \
32  __##method_name##_static() {} \
33  class __class_cleanup_attribute : public tunit::class_cleanup_attribute { \
34  public:\
35  template<typename test_class> __class_cleanup_attribute(test_class& test) : class_cleanup_attribute(#method_name, test, &method_name, {__func__, __FILE__, __LINE__}) {__##method_name##_static();} \
36  } __class_cleanup_attribute {*this}; \
37  static void method_name()
38 
Definition: test_class.h:21
Contains tunit::test class.
This attribute is use to add cleaup class method to class test attribute.
Definition: class_cleanup_attribute.h:9
line_info information class is used to store current file, current line and current function informat...
Definition: line_info.h:13
class_cleanup_attribute(const std::string &name, TestClass &test_class, void(*method)(), const tunit::line_info &line_info) noexcept
Creates new instance of class_cleanup_attribute attribute.
Definition: class_cleanup_attribute.h:24
The tunit namespace contains a unit test library.
Definition: abort_error.h:8
class_cleanup_attribute(const std::string &name, TestClass &test_class, void(*method)()) noexcept
Creates new instance of class_cleanup_attribute attribute.
Definition: class_cleanup_attribute.h:16