Lumiera  0.pre.03
»edit your freedom«
query-diagnostics.hpp
Go to the documentation of this file.
1 /*
2  QUERY-DIAGNOSTICS.hpp - helpers for writing tests covering config queries
3 
4  Copyright (C)
5  2008, 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 
14 
20 #ifndef LIB_QUERY_DIAGNOSTICS_H
21 #define LIB_QUERY_DIAGNOSTICS_H
22 
23 
24 #include "lib/format-string.hpp"
25 #include "lib/random.hpp"
26 
27 using util::_Fmt;
28 using std::string;
29 using std::rand;
30 
31 
32 
33 namespace lib {
34 namespace query{
35 namespace test {
36 
37  namespace {// implementation constants
38 
39  _Fmt predicatePattern{"%s_%02i( %s )"};
40  const string garbage {"asanisimasasmicksmaggtutti"};
41 
42  const uint MAX_DEGREE_RAND = 9;
43 
44  }
45 
46 
47 
48  inline string
49  garbage_term ()
50  {
51  return predicatePattern
52  % char ('a'+ rani(26))
53  % rani (100)
54  % garbage.substr (rani(23) , 3);
55  }
56 
57  inline string
58  garbage_query (int degree=0)
59  {
60  string fake;
61  if (!degree)
62  degree = 1 + rani(MAX_DEGREE_RAND);
63  while (0 < --degree)
64  fake += garbage_term() + ", ";
65  fake += garbage_term() + ".";
66  return fake;
67  }
68 
69 
70 
71 
72 }}} // namespace lib::query::test
73 #endif
Definition: run.hpp:40
Front-end for printf-style string template interpolation.
int rani(uint bound=_iBOUND())
Definition: random.hpp:135
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
string garbage_query(int degree=0)
Generating (pseudo) random numbers with controlled seed.