application.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2008 by Dr. Marc Boris Duerner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 #ifndef CXXTOOLS_UNIT_APPLICATION_H
29 #define CXXTOOLS_UNIT_APPLICATION_H
30 
31 #include <cxxtools/unit/reporter.h>
32 #include <cxxtools/unit/test.h>
33 #include <list>
34 #include <string>
35 
36 namespace cxxtools {
37 
38 namespace unit {
39 
62  class Application : public Test
63  {
64  public:
67  Application();
68 
71  virtual ~Application();
72 
73  static Application& instance();
74 
79  Test* findTest(const std::string& testname);
80 
85  void attachReporter(Reporter& r);
86 
92  void attachReporter(Reporter& r, const std::string& testname);
93 
101  void run(const std::string& testName);
102 
109  virtual void run();
110 
112  unsigned success() const
113  { return _success; }
114 
116  unsigned skipped() const
117  { return _skipped; }
118 
120  unsigned errors() const
121  { return _errors; }
122 
126  static std::list<Test*>& tests();
127 
135  static void staticRegisterTest(Test& test);
136 
144  void registerTest(Test& test);
145 
146  void deregisterTest(Test& test);
147 
148  private:
149  static Application* _app;
150 
151  unsigned _success;
152  unsigned _skipped;
153  unsigned _errors;
154  };
155 
156 } // namespace unit
157 
158 } // namespace cxxtools
159 
160 #endif