Lumiera  0.pre.03
»edit your freedom«
generator-combinations-test.cpp
Go to the documentation of this file.
1 /*
2  GeneratorCombinations(Test) - verify generating case combinations
3 
4  Copyright (C) Lumiera.org
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
28 #include "lib/test/run.hpp"
29 #include "lib/meta/generator.hpp"
32 #include "lib/format-string.hpp"
33 #include "lib/format-cout.hpp"
34 
35 
36 using ::test::Test;
37 using std::string;
38 
39 
40 namespace lib {
41 namespace meta {
42 namespace test {
43 
44 
45  namespace { // test cases and data....
46 
47  typedef Types< Num<1>
48  , Num<3>
49  , Num<5>
50  > Types1;
51  typedef Types< Num<2>
52  , Num<4>
53  , Num<6>
54  > Types2;
55 
56 
57  using util::_Fmt;
58 
64  template<class T1, class T2, class BASE>
65  struct TestCase
66  : BASE
67  {
68  static string
69  visitAll()
70  {
71  T1 param1;
72  T2 param2;
73  return _Fmt("-<%u%u>%s") % uint(param1)
74  % uint(param2)
75  % BASE::visitAll();
76  }
77  };
78 
79  template<>
80  struct TestCase<void,void,NullType>
81  {
82  static string
83  visitAll()
84  {
85  return "-|";
86  }
87  };
89 
90  } // (End) test data
91 
92 
93 
94 
95 
96 
97  /*********************************************************************/
104  class GeneratorCombinations_test : public Test
105  {
106  virtual void
107  run (Arg)
108  {
109  checkCartesian();
110  checkCaseInstantiation();
111  }
112 
113 
114  void
115  checkCartesian ()
116  {
117  typedef CartesianProduct<Types1,Types2> Cartesian;
118  DISPLAY (Cartesian);
119  }
120 
121 
122  void
123  checkCaseInstantiation ()
124  {
125  typedef InstantiateChainedCombinations< Types1,Types2
126  , TestCase
127  , IterationEnd > CombnationCases;
128 
129  cout << "All-Test-Combinations-" << CombnationCases::visitAll() << endl;
130  }
131 
132  };
133 
134 
136  LAUNCHER (GeneratorCombinations_test, "unit common");
137 
138 
139 
140 }}} // namespace lib::meta::test
Automatically use custom string conversion in C++ stream output.
Definition: run.hpp:49
Front-end for printf-style string template interpolation.
Helpers for working with lib::meta::Types (i.e.
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Metaprogramming facilities to generate combination cases.
Simple test class runner.
Support for writing metaprogramming unit-tests dealing with typelists and flags.
constant-wrapper type for debugging purposes, usable for generating lists of distinguishable types ...
A Test-Template to be instantiated for all possible combinations of the {Types1} x {Types2}...