xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
class_cleanup_attribute.h
Go to the documentation of this file.
1 #pragma once
5 #include "test.h"
6 
8 namespace xtd {
10  namespace tunit {
18  public:
23  template<typename test_class_t>
24  class_cleanup_attribute(const std::string& name, test_class_t& test_class, void (*method)()) noexcept : class_cleanup_attribute(name, test_class, method, xtd::diagnostics::stack_frame()) {}
25 
31  template<typename test_class_t>
32  class_cleanup_attribute(const std::string& name, test_class_t& test_class, void (*method)(), const xtd::diagnostics::stack_frame& stack_frame) noexcept {test_class.add_class_cleanup({name, method, stack_frame});}
33  };
34  }
35 }
36 
42 #define class_cleanup_(method_name) \
43  __##method_name##_static() {} \
44  class __class_cleanup_attribute : public xtd::tunit::class_cleanup_attribute { \
45  public:\
46  template<typename test_class> __class_cleanup_attribute(test_class& test) : class_cleanup_attribute(#method_name, test, &method_name, {__FILE__, __LINE__, __func__}) {__##method_name##_static();} \
47  } __class_cleanup_attribute {*this}; \
48  static void method_name()
49 
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:29
This attribute is use to add cleanup class method to class test attribute.
Definition: class_cleanup_attribute.h:17
class_cleanup_attribute(const std::string &name, test_class_t &test_class, void(*method)(), const xtd::diagnostics::stack_frame &stack_frame) noexcept
Creates new instance of class_cleanup_attribute attribute.
Definition: class_cleanup_attribute.h:32
class_cleanup_attribute(const std::string &name, test_class_t &test_class, void(*method)()) noexcept
Creates new instance of class_cleanup_attribute attribute.
Definition: class_cleanup_attribute.h:24
Definition: test_class.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::tunit::test class.