Manak  2.0.0
test_monitor.hpp
Go to the documentation of this file.
1 #ifndef MANAK_TEST_MONITOR_HPP_INCLUDED
2 #define MANAK_TEST_MONITOR_HPP_INCLUDED
3 
4 #include <iostream>
5 #include <string>
6 #include <list>
7 #include <tuple>
8 #include <sstream>
9 
10 #include "monitor_entry.hpp"
11 
13 
14 namespace manak
15 {
16 
18 {
19  enum class Type {ASSERT, CHECK, WARN, TEXT};
20 
22 
24 
25  MANAK_INLINE void AddAssert(TestEntry* entry);
26 
27  MANAK_INLINE void AddCheck(TestEntry* entry);
28 
29  MANAK_INLINE void AddText(TestEntry* entry);
30 
31  MANAK_INLINE void AddWarn(TestEntry* entry);
32 
33  MANAK_INLINE void GetFailMsg(std::list<std::string>& l_str) const;
34 
35  std::list<std::tuple<Type, TestEntry*>> entries;
36 };
37 
38 struct TestResult
39 {
41  : new_entry(false) {}
42 
43  enum class Res {PASS, FAIL};
44 
45  MANAK_INLINE void Clear();
46 
47  MANAK_INLINE void NewEntry();
48 
49  MANAK_INLINE void AddAssert(TestEntry* entry);
50 
51  MANAK_INLINE void AddCheck(TestEntry* entry);
52 
53  MANAK_INLINE void AddText(TestEntry* entry);
54 
56 
57  MANAK_INLINE bool GetStatus(double success_p) const;
58 
59  MANAK_INLINE bool GetFailMsg(size_t& n_itr, std::list<std::string>& l_str) const;
60 
61  MANAK_INLINE double GetSP() const;
62 
63  std::list<std::tuple<Res, TestResultEntry>> entries;
64  bool new_entry;
65 };
66 
68 {
69  public:
71  : tr(NULL),
72  isEnabled(false),
73  isTest(false){}
74 
76  {
77  delete tr;
78  }
79 
81  {
82  static TestMonitor singleton;
83  return singleton;
84  }
85 
86  MANAK_INLINE void Initialize();
87 
88  MANAK_INLINE void NewEntry();
89 
91 
92  MANAK_INLINE bool AddAssert(TestEntry* entry);
93 
94  MANAK_INLINE bool AddCheck(TestEntry* entry);
95 
96  MANAK_INLINE bool AddText(TestEntry* entry);
97 
98  MANAK_INLINE void Enable();
99 
100  MANAK_INLINE void Disable();
101 
102  MANAK_INLINE const bool& IsTest() const;
103 
105 
106  private:
108 
109  bool isEnabled;
110  bool isTest;
111 };
112 
113 }
114 
115 #ifndef MANAK_USE_DYN_LINK
116 #include "test_monitor.cpp"
117 #endif // MANAK_USE_DYN_LINK
118 
119 #endif // MANAK_TEST_MONITOR_HPP_INCLUDED
MANAK_INLINE const bool & IsTest() const
MANAK_INLINE bool AddText(TestEntry *entry)
MANAK_INLINE void AddAssert(TestEntry *entry)
MANAK_INLINE void AddText(TestEntry *entry)
MANAK_INLINE void Clear()
MANAK_INLINE bool AddAssert(TestEntry *entry)
MANAK_INLINE void ConfirmEntry()
MANAK_INLINE void AddCheck(TestEntry *entry)
MANAK_INLINE bool GetStatus(double success_p) const
std::list< std::tuple< Type, TestEntry * > > entries
MANAK_INLINE void Enable()
MANAK_INLINE bool GetFailMsg(size_t &n_itr, std::list< std::string > &l_str) const
MANAK_INLINE void ConfirmEntry()
std::list< std::tuple< Res, TestResultEntry > > entries
MANAK_INLINE void NewEntry()
#define MANAK_INLINE
Check if user has opt for dynamic linking.
Definition: macro_utils.hpp:25
MANAK_INLINE void AddText(TestEntry *entry)
MANAK_INLINE ~TestResultEntry()
MANAK_INLINE void GetFailMsg(std::list< std::string > &l_str) const
MANAK_INLINE void AddWarn(TestEntry *entry)
MANAK_INLINE double GetSP() const
MANAK_INLINE void Disable()
MANAK_INLINE void Initialize()
MANAK_INLINE TestResult *& Result()
MANAK_INLINE void AddAssert(TestEntry *entry)
static TestMonitor & GetGlobalTestMonitor()
MANAK_INLINE void AddCheck(TestEntry *entry)
MANAK_INLINE bool AddCheck(TestEntry *entry)
MANAK_INLINE void NewEntry()