AIToolbox
A library that offers tools for AI problem solving.
GlobalFixtures.hpp
Go to the documentation of this file.
1
#ifndef AI_TOOLBOX_TEST_GLOBAL_FIXTURES_HEADER_FILE
2
#define AI_TOOLBOX_TEST_GLOBAL_FIXTURES_HEADER_FILE
3
4
#include <boost/test/unit_test.hpp>
5
#include <boost/test/results_collector.hpp>
6
#include <boost/test/tree/visitor.hpp>
7
#include <boost/test/tree/traverse.hpp>
8
9
#include <
AIToolbox/Seeder.hpp
>
10
11
struct
SeedPrinter
{
12
struct
AllPassVisitor
: boost::unit_test::test_tree_visitor {
13
bool
passed
=
true
;
14
15
void
visit
( boost::unit_test::test_case
const
& test ) {
16
passed
&= boost::unit_test::results_collector.results(test.p_id).passed();
17
}
18
};
19
20
~SeedPrinter
() {
21
namespace
ut = boost::unit_test;
22
23
// Check whether we have passed all tests.
24
AllPassVisitor
v;
25
ut::traverse_test_tree(ut::framework::master_test_suite(), v);
26
27
// If not, print the global seed to reproduce errors.
28
if
(!v.
passed
)
29
BOOST_CHECK_MESSAGE(
false
,
"ROOT SEED: "
<<
AIToolbox::Seeder::getRootSeed
());
30
}
31
};
32
33
BOOST_TEST_GLOBAL_FIXTURE
(
SeedPrinter
);
34
35
#endif
SeedPrinter::~SeedPrinter
~SeedPrinter()
Definition:
GlobalFixtures.hpp:20
SeedPrinter::AllPassVisitor::passed
bool passed
Definition:
GlobalFixtures.hpp:13
SeedPrinter::AllPassVisitor
Definition:
GlobalFixtures.hpp:12
AIToolbox::Seeder::getRootSeed
static unsigned getRootSeed()
This function returns the root seed of Seeder.
Seeder.hpp
SeedPrinter
Definition:
GlobalFixtures.hpp:11
BOOST_TEST_GLOBAL_FIXTURE
BOOST_TEST_GLOBAL_FIXTURE(SeedPrinter)
SeedPrinter::AllPassVisitor::visit
void visit(boost::unit_test::test_case const &test)
Definition:
GlobalFixtures.hpp:15