Run a single test, returning true iff the test succeeded
| 249 | |
| 250 | /// Run a single test, returning true iff the test succeeded |
| 251 | bool run_test(Base* test, unsigned int test_seed, const Options& options, std::ostream& ostream) { |
| 252 | try { |
| 253 | ostream << test->name() << " "; |
| 254 | ostream.flush(); |
| 255 | test->_rand.seed(test_seed); |
| 256 | for (unsigned int i = options.iter; i--;) { |
| 257 | unsigned int seed = test->_rand.seed(); |
| 258 | if (test->run()) { |
| 259 | ostream << '+'; |
| 260 | ostream.flush(); |
| 261 | } else { |
| 262 | ostream << "-" << std::endl; |
| 263 | report_error(test->name(), seed, opt, ostream); |
| 264 | return false; |
| 265 | } |
| 266 | } |
| 267 | ostream << std::endl; |
| 268 | return true; |
| 269 | } catch (Gecode::Exception& e) { |
| 270 | ostream << "Exception in \"Gecode::" << e.what() |
| 271 | << "." << std::endl |
| 272 | << "Stopping..." << std::endl; |
| 273 | report_error(test->name(), options.seed, opt, ostream); |
| 274 | return false; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /// Run all the tests with the supplied options. |
| 279 | int run_tests(const std::vector<Base*>& tests, const Options& options) { |