Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
testManager.h
Go to the documentation of this file.
1 
14 #ifndef TESTMANAGER_INCLUDED
15 #define TESTMANAGER_INCLUDED
16 
17 #include <map>
18 
21 #include "test.h"
22 
23 #include "IO/bridgeIO.h"
24 using Bridge::vout;
25 
26 // typedef Functor<int> Test_function;
27 typedef int (*Test_function)(void);
28 
29 // null function
30 int DoNothing();
31 
32 
34 
53 {
54  public:
55  static const std::string class_name;
56 
57  public:
58  void interactive();
59  void batch(const std::string& arg);
60  void batch_recursive(const std::string& arg = "");
61  void batch_recursive(const int argc, char **argv);
62 
63  bool registerTest(const std::string& key, const Test_function func);
64 
65  void list();
66 
67  static TestManager& Instance();
68 
69  static bool RegisterTest(const std::string& key, const Test_function func)
70  { return Instance().registerTest(key, func); }
71 
72  // for test result verification
73  int getCheckPrecision() const
74  { return m_precision; }
75 
76  private:
77  // singleton
78  TestManager();
79 
80  TestManager(const TestManager&); // not implemented
81  TestManager& operator=(const TestManager&); // not implemented
82 
83  ~TestManager();
84 
85  static void CreateInstance();
86 
88 
89  // bi-directional tree representation of key
90  struct Node
91  {
93  std::vector<Node *> m_next;
94  std::string m_name; // key
96 
97  Node(const std::string& name, Node *const prev = 0)
98  : m_prev(prev), m_next(), m_name(name), m_function(DoNothing) {}
100  {
101  for (size_t i = 0; i < m_next.size(); ++i) { delete m_next[i]; }
102  }
103  };
104 
105  Node *find_node(Node *p, const std::vector<std::string>& v);
106  Node *append_key(Node *p, const std::vector<std::string>& v);
107  Node *append_key(Node *p, int argc, char **argv);
108 
109  // statistics
110  struct Stat
111  {
116  std::vector<std::string> m_list_failure;
117  std::vector<std::string> m_list_skip;
118 
119  void reset();
120  void success(const std::string& test_name);
121  void failure(const std::string& test_name);
122  void skip(const std::string& test_name);
123  };
124 
125  void stat_report() const;
126 
127  std::string find_fullpath(const Node *p, const std::string& path = "");
128 
129  void interactive_master();
130  void interactive_slave();
131 
132  void run(const Node *p);
133  void run_traversal(const Node *p);
134 
135  bool menu(const Node *p, const bool is_top = false);
136  void banner();
137 
138  void set_precision();
139 
140  void list_traverse(const Node *p, const std::string& prefix);
141 
142  // for debug
143  void traverse(const Node *p, const std::string& indent = "");
144 
145 
147 
149 
150  // for test result verification
152 
153  // for statistics report
155 };
156 #endif // TEST_MANAGER_H
TestManager class for managing and performing tests.
Definition: testManager.h:52
BridgeIO vout
Definition: bridgeIO.cpp:503
Node(const std::string &name, Node *const prev=0)
Definition: testManager.h:97
bool menu(const Node *p, const bool is_top=false)
void success(const std::string &test_name)
const std::string test_name
static void CreateInstance()
Definition: testManager.cpp:60
void run_traversal(const Node *p)
void failure(const std::string &test_name)
void batch_recursive(const std::string &arg="")
void interactive_slave()
std::string find_fullpath(const Node *p, const std::string &path="")
void list_traverse(const Node *p, const std::string &prefix)
void stat_report() const
void skip(const std::string &test_name)
int(* Test_function)(void)
Definition: testManager.h:27
void interactive_master()
Definition: testManager.cpp:96
void traverse(const Node *p, const std::string &indent="")
std::string m_name
Definition: testManager.h:94
void run(const Node *p)
std::vector< std::string > m_list_skip
Definition: testManager.h:117
TestManager & operator=(const TestManager &)
Test_function m_function
Definition: testManager.h:95
Bridge::VerboseLevel m_vl
Definition: testManager.h:146
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
int getCheckPrecision() const
Definition: testManager.h:73
std::vector< std::string > m_list_failure
Definition: testManager.h:116
Node m_root_node
Definition: testManager.h:148
static TestManager & Instance()
Definition: testManager.cpp:41
void interactive()
Definition: testManager.cpp:85
VerboseLevel
Definition: bridgeIO.h:42
static TestManager * s_instance
Definition: testManager.h:87
Node * find_node(Node *p, const std::vector< std::string > &v)
bool registerTest(const std::string &key, const Test_function func)
std::vector< Node * > m_next
Definition: testManager.h:93
void banner()
Definition: testManager.cpp:30
static const std::string class_name
Definition: testManager.h:55
void set_precision()
int DoNothing()
Definition: testManager.cpp:23
Node * append_key(Node *p, const std::vector< std::string > &v)
void batch(const std::string &arg)