Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.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.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
49namespace 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
144int main(int argc, char* argv[]);
145
150std::ostream&
151operator<<(std::ostream& os, const Test::ind& i);
152
153#include "test/test.hpp"
154
155#endif
156
157// STATISTICS: test-core
int n
Number of negative literals for node type.
Template for linear congruential generators.
Definition random.hpp:46
Base class for all tests to be run
Definition test.hh:103
static Gecode::Support::RandomGenerator rand
Random number generator.
Definition test.hh:134
Base(const std::string &s)
Create and register test with name s.
Definition test.cpp:59
static Base * tests(void)
Return all tests.
Definition test.hpp:54
virtual ~Base(void)
Destructor.
Definition test.cpp:92
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
Definition test.hpp:66
Base * next(void) const
Return next test.
Definition test.hpp:58
virtual bool run(void)=0
Run test.
const std::string & name(void) const
Return name of test.
Definition test.hpp:50
static void sort(void)
Sort tests alphabetically.
Definition test.cpp:77
Commandline options.
Definition test.hh:76
void parse(int argc, char *argv[])
Parse commandline arguments.
Definition test.cpp:120
bool log
Whether to log the tests.
Definition test.hh:91
unsigned int seed
The random seed to be used.
Definition test.hh:79
Options(void)
Initialize options with defaults.
Definition test.hpp:41
static const unsigned int deffixprob
Default fixpoint probaibility.
Definition test.hh:87
unsigned int iter
Number of iterations for each test.
Definition test.hh:81
bool stop
Whether to stop on an error.
Definition test.hh:89
unsigned int fixprob
The probability for computing a fixpoint.
Definition test.hh:85
static const int defiter
Default number of iterations.
Definition test.hh:83
Simple class for describing identation.
Definition test.hh:66
int l
Which indentation level.
Definition test.hh:69
ind(int i)
Indent by level i.
Definition test.hh:71
General test support.
Definition afc.cpp:39
std::ostringstream olog
Stream used for logging.
Definition test.cpp:53
Options opt
The options.
Definition test.cpp:97
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Definition scowl.hpp:13625
int main(int argc, char *argv[])
Definition test.cpp:208