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)
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
19 #include "lib/test/run.hpp"
20 #include "lib/meta/generator.hpp"
23 #include "lib/format-string.hpp"
24 #include "lib/format-cout.hpp"
25 
26 
27 using ::test::Test;
28 using std::string;
29 
30 
31 namespace lib {
32 namespace meta {
33 namespace test {
34 
35 
36  namespace { // test cases and data....
37 
38  typedef Types< Num<1>
39  , Num<3>
40  , Num<5>
41  > Types1;
42  typedef Types< Num<2>
43  , Num<4>
44  , Num<6>
45  > Types2;
46 
47 
48  using util::_Fmt;
49 
55  template<class T1, class T2, class BASE>
56  struct TestCase
57  : BASE
58  {
59  static string
60  visitAll()
61  {
62  T1 param1;
63  T2 param2;
64  return _Fmt("-<%u%u>%s") % uint(param1)
65  % uint(param2)
66  % BASE::visitAll();
67  }
68  };
69 
70  template<>
71  struct TestCase<void,void,NullType>
72  {
73  static string
74  visitAll()
75  {
76  return "-|";
77  }
78  };
80 
81  } // (End) test data
82 
83 
84 
85 
86 
87 
88  /*********************************************************************/
95  class GeneratorCombinations_test : public Test
96  {
97  virtual void
98  run (Arg)
99  {
100  checkCartesian();
101  checkCaseInstantiation();
102  }
103 
104 
105  void
106  checkCartesian ()
107  {
108  typedef CartesianProduct<Types1,Types2> Cartesian;
109  DISPLAY (Cartesian);
110  }
111 
112 
113  void
114  checkCaseInstantiation ()
115  {
116  typedef InstantiateChainedCombinations< Types1,Types2
117  , TestCase
118  , IterationEnd > CombnationCases;
119 
120  cout << "All-Test-Combinations-" << CombnationCases::visitAll() << endl;
121  }
122 
123  };
124 
125 
127  LAUNCHER (GeneratorCombinations_test, "unit common");
128 
129 
130 
131 }}} // namespace lib::meta::test
Automatically use custom string conversion in C++ stream output.
Definition: run.hpp:40
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.
Simplistic 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}...