Go to the documentation of this file.
42 #ifdef GECODE_HAS_MTRACE
64 : _name(s), _next(_tests) {
65 _tests =
this; _n_tests++;
68 Base* Base::_tests = NULL;
69 unsigned int Base::_n_tests = 0;
76 return x->name() >
y->name();
84 for (
Base*
t = _tests;
t != NULL;
t =
t->next())
90 for ( ;
i < _n_tests;
i++) {
91 b[
i]->next(_tests); _tests =
b[
i];
104 std::cout <<
"Options: -seed " <<
opt.
seed;
107 std::cout <<
" -test " << name << std::endl;
109 std::cout <<
olog.str();
119 std::vector<std::pair<MatchType, const char*> >
testpat;
127 if (!strcmp(argv[
i],
"-help") || !strcmp(argv[
i],
"--help")) {
128 std::cerr <<
"Options for testing:" << std::endl
129 <<
"\t-seed (unsigned int or \"time\") default: "
131 <<
"\t\tseed for random number generator (unsigned int),"
133 <<
"\t\tor \"time\" for a random seed based on "
134 <<
"current time" << std::endl
135 <<
"\t-fixprob (unsigned int) default: "
137 <<
"\t\t1/fixprob is the probability of computing a fixpoint"
139 <<
"\t-iter (unsigned int) default: " <<
iter<< std::endl
140 <<
"\t\tthe number of iterations" << std::endl
141 <<
"\t-test (string) default: (none)" << std::endl
142 <<
"\t\tsimple pattern for the tests to run" << std::endl
143 <<
"\t\tprefixing with \"-\" negates the pattern" << std::endl
144 <<
"\t\tprefixing with \"^\" requires a match at the beginning" << std::endl
145 <<
"\t\tmultiple pattern-options may be given"
147 <<
"\t-start (string) default: (none)" << std::endl
148 <<
"\t\tsimple pattern for the first test to run" << std::endl
151 <<
"\t\tlog execution of tests"
153 <<
"\t\tthe optional argument determines the style of the log"
155 <<
"\t\twith text as the default style"
157 <<
"\t-stop (boolean) default: "
158 << (
stop ?
"true" :
"false") << std::endl
159 <<
"\t\tstop on first error or continue" << std::endl
160 <<
"\t-list" << std::endl
161 <<
"\t\toutput list of all test cases and exit" << std::endl
164 }
else if (!strcmp(argv[
i],
"-seed")) {
165 if (++
i == argc)
goto missing;
166 if (!strcmp(argv[
i],
"time")) {
167 seed =
static_cast<unsigned int>(time(NULL));
169 seed =
static_cast<unsigned int>(atoi(argv[
i]));
171 }
else if (!strcmp(argv[
i],
"-iter")) {
172 if (++
i == argc)
goto missing;
173 iter =
static_cast<unsigned int>(atoi(argv[
i]));
174 }
else if (!strcmp(argv[
i],
"-fixprob")) {
175 if (++
i == argc)
goto missing;
176 fixprob =
static_cast<unsigned int>(atoi(argv[
i]));
177 }
else if (!strcmp(argv[
i],
"-test")) {
178 if (++
i == argc)
goto missing;
179 if (argv[
i][0] ==
'^')
181 else if (argv[
i][0] ==
'-')
185 }
else if (!strcmp(argv[
i],
"-start")) {
186 if (++
i == argc)
goto missing;
188 }
else if (!strcmp(argv[
i],
"-log")) {
190 }
else if (!strcmp(argv[
i],
"-stop")) {
191 if (++
i == argc)
goto missing;
192 if(argv[
i][0] ==
't') {
194 }
else if (argv[
i][0] ==
'f') {
197 }
else if (!strcmp(argv[
i],
"-list")) {
204 std::cerr <<
"Erroneous argument (" << argv[
i-1] <<
")" << std::endl
205 <<
" missing parameter" << std::endl;
213 using namespace Test;
214 #ifdef GECODE_HAS_MTRACE
224 std::cout <<
t->name() << std::endl;
231 bool started =
startFrom == NULL ? true :
false;
236 if (
t->name().find(
startFrom) != std::string::npos)
242 bool match_found =
false;
243 bool some_positive =
false;
244 for (
unsigned int i = 0;
i <
testpat.size(); ++
i) {
246 if (
t->name().find(
testpat[
i].second) != std::string::npos)
249 some_positive =
true;
251 (
t->name().find(
testpat[
i].second) != std::string::npos)) ||
253 (
t->name().find(
testpat[
i].second) == 0)))
257 if (some_positive && !match_found)
goto next;
259 std::cout <<
t->name() <<
" ";
267 std::cout <<
"-" << std::endl;
273 std::cout << std::endl;
275 std::cout <<
"Exception in \"Gecode::" << e.
what()
277 <<
"Stopping..." << std::endl;
289 for (
int j=
i.l; j--; )
void seed(unsigned int s)
Set the current seed to s.
Post propagator for SetVar SetOpType SetVar y
bool operator()(Base *x, Base *y)
int main(int argc, char *argv[])
Main-function.
virtual const char * what(void) const
Return information.
void report_error(std::string name)
Gecode::IntArgs i(4, 1, 2, 3, 4)
static void sort(void)
Sort tests alphabetically.
LinearCongruentialGenerator< 2147483647, 48271, 44488, 3399 > RandomGenerator
Default values for linear congruential generator.
static Base * tests(void)
Return all tests.
static Gecode::Support::RandomGenerator rand
Random number generator.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
unsigned int iter
Number of iterations for each test.
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Base class for all tests to be run
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
Node * x
Pointer to corresponding Boolean expression node.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
std::vector< std::pair< MatchType, const char * > > testpat
bool log
Whether to log the tests.
static const unsigned int deffixprob
Default fixpoint probaibility.
Template for linear congruential generators.
unsigned int fixprob
The probability for computing a fixpoint.
Heap heap
The single global heap.
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Simple class for describing identation.
void parse(int argc, char *argv[])
Parse commandline arguments.
virtual ~Base(void)
Destructor.
std::ostringstream olog
Stream used for logging.
Base(const std::string &s)
Create and register test with name s.
unsigned int seed
The random seed to be used.
Exception: Base-class for exceptions
bool stop
Whether to stop on an error.