Lumiera  0.pre.03
»edit your freedom«
run.hpp
Go to the documentation of this file.
1 /*
2  RUN.hpp - helper class for grouping, registering and invoking testcases
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6  Hermann Vosseler <Ichthyostega@web.de>
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of
11  the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 
22 */
23 
36 #ifndef TESTHELPER_RUN_H
37 #define TESTHELPER_RUN_H
38 
39 #include "steam/common.hpp"
40 #include "include/logging.h"
41 
42 #include "lib/test/suite.hpp"
43 #include "lib/util.hpp"
44 
45 #include <memory>
46 #include <string>
47 
48 
49 namespace test {
50 
51  using std::string;
52  using std::shared_ptr;
53 
54  typedef std::vector<string> & Arg;
55 
56 
57 
62  class Test
63  {
64  public:
65  virtual ~Test() {}
66  virtual void run(Arg arg) = 0;
67  };
68 
69 
70 
72  class Launcher
73  {
74  public:
75  virtual ~Launcher() {}
76  virtual shared_ptr<Test> makeInstance() =0;
77  };
78 
79 
91  template<class TEST>
92  class Launch : public Launcher
93  {
94  public:
95  Launch (string testID, string groups)
96  {
97  Suite::enrol (this,testID,groups);
98  }
99 
100  virtual shared_ptr<Test>
101  makeInstance () override
102  {
103  return shared_ptr<Test> (new TEST );
104  }
105  };
106 
107 } // namespace test
108 
109 // make them global for convenience
110 using ::test::Arg;
111 using ::test::Test;
112 using ::test::Launch;
113 
114 // and provide shortcut for registration
115 #define LAUNCHER(_TEST_CLASS_, _GROUPS_) \
116  \
117  Launch<_TEST_CLASS_> run_##_TEST_CLASS_##_(STRINGIFY(_TEST_CLASS_), _GROUPS_);
118 
119 
120 #endif
Basic set of definitions and includes commonly used together.
Definition: run.hpp:49
This header is for including and configuring NoBug.
Helper class for running a collection of tests.
Definition: run.hpp:92
Abstract Base Class for all testcases.
Definition: run.hpp:62
Building and running a suite of tests, implemented as test classes.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
interface: generic testcase creating functor.
Definition: run.hpp:72
static void enrol(Launcher *test, string testID, string groups)
register the given test-launcher, so it can be later accessed either as a member of one of the specif...
Definition: suite.cpp:117