Generated on Fri Jan 28 2022 04:43:06 for Gecode by doxygen 1.8.13
test.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Contributing authors:
7  * Mikael Lagerkvist <lagerkvist@gecode.org>
8  *
9  * Copyright:
10  * Christian Schulte, 2005
11  * Mikael Lagerkvist, 2005
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_TEST_TEST_HH__
39 #define __GECODE_TEST_TEST_HH__
40 
41 #include <gecode/kernel.hh>
42 #include <gecode/search.hh>
43 
44 #include <iostream>
45 #include <sstream>
46 #include <string>
47 
49 namespace Test {
50 
63  extern std::ostringstream olog;
64 
66  class ind {
67  public:
69  int l;
71  ind(int i) : l(i) {}
72  };
73 
74 
76  class Options {
77  public:
79  unsigned int seed;
81  unsigned int iter;
83  static const int defiter = 5;
85  unsigned int fixprob;
87  static const unsigned int deffixprob = 10;
89  bool stop;
91  bool log;
92 
94  Options(void);
96  void parse(int argc, char* argv[]);
97  };
98 
100  extern Options opt;
101 
103  class Base {
104  private:
106  std::string _name;
108  Base* _next;
110  static Base* _tests;
112  static unsigned int _n_tests;
113  public:
115  Base(const std::string& s);
117  static void sort(void);
119  const std::string& name(void) const;
121  static Base* tests(void);
123  Base* next(void) const;
125  void next(Base* n);
127  virtual bool run(void) = 0;
129  static bool fixpoint(void);
131  virtual ~Base(void);
132 
135  };
137 
138 }
139 
144 int main(int argc, char* argv[]);
145 
150 std::ostream&
151 operator<<(std::ostream& os, const Test::ind& i);
152 
153 #include "test/test.hpp"
154 
155 #endif
156 
157 // STATISTICS: test-core
Simple class for describing identation.
Definition: test.hh:66
static Gecode::Support::RandomGenerator rand
Random number generator.
Definition: test.hh:134
GECODE_FLATZINC_EXPORT FlatZincSpace * parse(const std::string &fileName, Printer &p, std::ostream &err=std::cerr, FlatZincSpace *fzs=NULL, Rnd &rnd=defrnd)
Parse FlatZinc file fileName into fzs and return it.
unsigned int seed
The random seed to be used.
Definition: test.hh:79
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
Definition: sort.hpp:133
unsigned int iter
Number of iterations for each test.
Definition: test.hh:81
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Options opt
The options.
Definition: test.cpp:97
Gecode::IntArgs i({1, 2, 3, 4})
Base class for all tests to be run
Definition: test.hh:103
bool log
Whether to log the tests.
Definition: test.hh:91
Template for linear congruential generators.
Definition: random.hpp:46
General test support.
Definition: afc.cpp:39
Commandline options.
Definition: test.hh:76
std::ostringstream olog
Stream used for logging.
Definition: test.cpp:53
ind(int i)
Indent by level i.
Definition: test.hh:71
unsigned int fixprob
The probability for computing a fixpoint.
Definition: test.hh:85
std::ostream & operator<<(std::ostream &os, const Test::ind &i)
Print indentation.
Definition: test.cpp:284
int main(int argc, char *argv[])
Definition: test.cpp:208
bool stop
Whether to stop on an error.
Definition: test.hh:89
int l
Which indentation level.
Definition: test.hh:69