Manak  2.0.0
manak_suite.hpp
Go to the documentation of this file.
1 #ifndef MANAK_MANAK_SUITE_HPP_INCLUDED
2 #define MANAK_MANAK_SUITE_HPP_INCLUDED
3 
4 #include <string>
5 #include <list>
6 #include <map>
7 #include <regex>
8 #include <vector>
9 #include <fstream>
10 
11 #include "manak_case.hpp"
12 #include "t_manak_case.hpp"
13 
15 
16 namespace manak
17 {
18 
20 {
21  public:
23  : current_manak_suite(this),
24  parent(NULL){}
25 
26  ManakSuite(const std::string& name)
27  : name(name),
28  current_manak_suite(this),
29  parent(NULL) {}
30 
32 
33  MANAK_INLINE bool Run(const std::string& uname = "",
34  const std::string& pattern = "",
35  const bool compare = false);
36 
37  MANAK_INLINE bool Find(const std::string& name, std::list<ManakCase*>& lbc);
38 
39  MANAK_INLINE bool LoadData(const std::string& name);
40 
42  {
43  static ManakSuite singleton;
44  return singleton;
45  }
46 
48  {
49  child_suits[suite->Name()] = suite;
50  suite->parent = this;
51  return suite;
52  }
53 
55  {
56  return current_manak_suite;
57  }
58 
60  {
61  return (current_manak_suite = suite);
62  }
63 
64  MANAK_INLINE ManakSuite* SetCurrentSuite(const std::string& name);
65 
67  {
69  }
70 
72 
73  template<typename T, typename... Args>
74  bool AddGroup(Args... args)
75  {
76  T& gr = T::Global();
77  gr.InitCaller(args...);
78  gr.ACCaller();
79  for(auto it : gr.cases)
80  {
81  AddCase(it);
82  }
83  gr.cases.clear();
84  return true;
85  }
86 
87  const std::string& Name() const
88  {
89  return name;
90  }
91  std::string& Name()
92  {
93  return name;
94  }
95  const std::string& UName() const
96  {
97  return uname;
98  }
99  std::string& UName()
100  {
101  return uname;
102  }
103 
104  private:
105  std::string name;
106  std::string uname;
107 
108  std::map<std::string, std::list<ManakCase*>> children;
109  std::map<std::string, ManakSuite*> child_suits;
110 
113 };
114 
115 }
116 
117 #include "result_collector.hpp"
118 
119 #ifndef MANAK_USE_DYN_LINK
120 #include "manak_suite.cpp"
121 #endif // MANAK_USE_DYN_LINK
122 
123 namespace manak
124 {
125 
127 {
128  public:
129  RegisterManakSuite(const std::string& name)
130  {
131  if(name == "")
132  {
133  std::cerr << "Invalid suite name!!" << std::endl;
134  exit(1);
135  }
137  }
138 };
139 
141 {
142  public:
144  {
146  }
147 };
148 
149 }
150 
151 #endif // MANAK_MANAK_SUITE_HPP_INCLUDED
MANAK_INLINE ManakCase * AddCase(ManakCase *obj)
MANAK_INLINE bool LoadData(const std::string &name)
std::map< std::string, std::list< ManakCase * > > children
ManakSuite(const std::string &name)
Definition: manak_suite.hpp:26
std::map< std::string, ManakSuite * > child_suits
std::string & Name()
Definition: manak_suite.hpp:91
static ManakSuite & GetMasterSuite()
Definition: manak_suite.hpp:41
ManakSuite * GetCurrentSuite() const
Definition: manak_suite.hpp:54
std::string & UName()
Definition: manak_suite.hpp:99
MANAK_INLINE ~ManakSuite()
#define MANAK_INLINE
Check if user has opt for dynamic linking.
Definition: macro_utils.hpp:25
bool AddGroup(Args...args)
Definition: manak_suite.hpp:74
MANAK_INLINE bool Run(const std::string &uname="", const std::string &pattern="", const bool compare=false)
ManakSuite * AddSuite(ManakSuite *suite)
Definition: manak_suite.hpp:47
const std::string & Name() const
Definition: manak_suite.hpp:87
const std::string & UName() const
Definition: manak_suite.hpp:95
ManakSuite * parent
ManakSuite * SetCurrentSuite(ManakSuite *suite)
Definition: manak_suite.hpp:59
MANAK_INLINE bool Find(const std::string &name, std::list< ManakCase * > &lbc)
ManakSuite * SetCurrentSuiteToParent()
Definition: manak_suite.hpp:66
ManakSuite * current_manak_suite
RegisterManakSuite(const std::string &name)
std::string name
std::string uname