Generated on for Gecode by doxygen 1.17.0
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.dev>
5 *
6 * Contributing authors:
7 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
8 *
9 * Copyright:
10 * Christian Schulte, 2005
11 * Mikael Zayenz Lagerkvist, 2005
12 *
13 * This file is part of Gecode, the generic constraint
14 * development environment:
15 * http://www.gecode.dev
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#include <gecode/int.hh>
44
45#include <iostream>
46#include <sstream>
47#include <string>
48
50namespace Test {
51
58
64 extern std::ostringstream olog;
65
67 class ind {
68 public:
70 int l;
72 ind(int i) : l(i) {}
73 };
74
76 enum MatchType {
77 MT_ANY, //< Positive match anywhere in string
78 MT_NOT, //< Negative match
79 MT_FIRST //< Positive match at beginning
80 };
81
83 class Options {
84 public:
86 unsigned int threads;
88 unsigned int seed;
90 unsigned int iter;
92 static const int defiter = 5;
94 unsigned int fixprob;
96 static const unsigned int deffixprob = 10;
98 bool stop;
100 bool log;
102 std::vector<std::pair<MatchType, const char*> > testpat;
104 const char* start_from;
106 bool list;
107
109 Options(void);
111 void parse(int argc, char* argv[]);
112
114 bool is_test_name_matching(const std::string& test_name);
115 };
116
118 extern Options opt;
119
121 class Base {
122 private:
124 std::string _name;
126 Base* _next;
128 static Base* _tests;
130 static unsigned int _n_tests;
131 public:
133 Base(std::string s);
135 static void sort(void);
137 const std::string& name(void) const;
139 static Base* tests(void);
141 Base* next(void) const;
143 void next(Base* n);
145 virtual bool run(void) = 0;
147 bool fixpoint(void);
151 virtual ~Base(void);
152
154
155
156 static std::string str(bool b);
158 static std::string str(int i);
160 static std::string str(const Gecode::IntArgs& i);
162
165 };
166
167
168}
169
174int main(int argc, char* argv[]);
175
180std::ostream&
181operator<<(std::ostream& os, const Test::ind& i);
182
183#include "test/test.hpp"
184
185#endif
186
187// STATISTICS: test-core
Passing integer arguments.
Definition int.hh:652
int main(int argc, char *argv[])
Main function.
Gecode::Support::RandomGenerator _rand
Random number generator.
Definition test.hh:164
Base(std::string s)
Create and register test with name s.
static void sort(void)
Sort tests alphabetically.
virtual ~Base(void)
Destructor.
static Base * tests(void)
Return all tests.
Definition test.hpp:55
bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
Definition test.hpp:67
Base * next(void) const
Return next test.
Definition test.hpp:59
virtual bool run(void)=0
Run test.
const std::string & name(void) const
Return name of test.
Definition test.hpp:51
static std::string str(bool b)
Map bool to string.
Definition test.hpp:77
Commandline options.
Definition test.hh:83
std::vector< std::pair< MatchType, const char * > > testpat
Patterns to test against.
Definition test.hh:102
bool is_test_name_matching(const std::string &test_name)
True iff a test name should be executed according to the patterns. With no patterns,...
void parse(int argc, char *argv[])
Parse commandline arguments.
bool log
Whether to log the tests.
Definition test.hh:100
unsigned int seed
The random seed to be used.
Definition test.hh:88
const char * start_from
Name of first test to start with.
Definition test.hh:104
Options(void)
Initialize options with defaults.
Definition test.hpp:41
static const unsigned int deffixprob
Default fixpoint probability.
Definition test.hh:96
bool list
Whether to list all tests.
Definition test.hh:106
unsigned int iter
Number of iterations for each test.
Definition test.hh:90
bool stop
Whether to stop on an error.
Definition test.hh:98
unsigned int threads
Number of threads to use.
Definition test.hh:86
unsigned int fixprob
The probability for computing a fixpoint.
Definition test.hh:94
static const int defiter
Default number of iterations.
Definition test.hh:92
Simple class for describing indentation.
Definition test.hh:67
int l
Which indentation level.
Definition test.hh:70
ind(int i)
Indent by level i.
Definition test.hh:72
LinearCongruentialGenerator< 2147483647, 48271, 44488, 3399 > RandomGenerator
Default values for linear congruential generator.
Definition random.hpp:183
General test support.
Definition assign.hh:52
std::ostringstream olog
Stream used for logging.
MatchType
How to match.
Definition test.hh:76
@ MT_FIRST
Definition test.hh:79
@ MT_ANY
Definition test.hh:77
@ MT_NOT
Definition test.hh:78
Options opt
The options.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Definition scowl.hpp:13625