15 #define GETTEXT_DOMAIN "wesnoth-test"
17 #include <boost/test/unit_test.hpp>
32 for (
int i = 0;
i < 9999 ;
i++) {
35 unsigned long val = rng();
36 BOOST_CHECK_EQUAL( val , 4123659995U );
44 stream << std::setfill(
'0') << std::setw(
sizeof(
uint32_t)*2) << std::hex << seed;
62 std::stringstream stream2;
63 stream2 << std::setfill(
'0') << std::setw(
sizeof(
uint32_t)*2) << std::hex << seed3;
78 BOOST_CHECK (seed != seed3);
79 BOOST_CHECK (seed_str != seed_str3);
87 stream << std::setfill(
'0') << std::setw(
sizeof(
uint32_t)*2) << std::hex << seed;
91 cfg[
"random_seed"] = seed_str;
92 cfg[
"random_calls"] = 0;
107 std::stringstream stream2;
108 stream2 << std::setfill(
'0') << std::setw(
sizeof(
uint32_t)*2) << std::hex << seed3;
112 cfg2[
"random_seed"] = seed_str3;
113 cfg2[
"random_calls"] = 0;
128 BOOST_CHECK (seed != seed3);
129 BOOST_CHECK (seed_str != seed_str3);
135 cfg[
"random_seed"] =
"5eedf00d";
136 cfg[
"random_calls"] = 0;
141 BOOST_CHECK(rng1 == rng2);
142 for (
int i = 0;
i < 10 ;
i++) {
150 cfg[
"random_seed"] =
"18da5eed";
151 cfg[
"random_calls"] = 9999;
156 BOOST_CHECK(rng1 == rng2);
157 for (
int i = 0;
i < 10 ;
i++) {
171 BOOST_CHECK(rng1 == rng2);
172 for (
int i = 0;
i < 10 ;
i++) {
181 for (
int i = 0;
i < 5;
i++) {
191 BOOST_CHECK(rng1 == rng2);
198 cfg[
"random_seed"] =
"5eedc0de";
199 cfg[
"random_calls"] = 0;
203 for (
int i = 0;
i < 9999 ;
i++) {
216 BOOST_CHECK (rng == rng2);
219 BOOST_CHECK (result1 == result2);
230 BOOST_CHECK (rng == rng3);
233 BOOST_CHECK (result3 == result4);
241 cfg[
"random_seed"] = seed_str;
242 cfg[
"random_calls"] = 0;
246 for (
int i = 0;
i < 9999 ;
i++) {
247 rng1.get_next_random();
251 cfg2[
"random_seed"] = rng1.get_random_seed_str();
252 cfg2[
"random_calls"] = rng1.get_random_calls();
256 for (
int i = 0;
i < 9999 ;
i++) {
257 rng1.get_next_random();
258 rng2.get_next_random();
261 BOOST_CHECK(rng1 == rng2);
262 BOOST_CHECK(rng1.get_next_random() == rng2.get_next_random());
270 validate_seed_string(
"0000badd");
271 validate_seed_string(
"00001234");
272 validate_seed_string(
"deadbeef");
273 validate_seed_string(
"12345678");
274 validate_seed_string(
"00009999");
275 validate_seed_string(
"ffffaaaa");
276 validate_seed_string(
"11110000");
277 validate_seed_string(
"10101010");
278 validate_seed_string(
"aaaa0000");
283 std::string validate_get_random_int_seed_generator()
290 #define validation_get_random_int_num_draws 19999
292 #define validation_get_random_int_max 32000
294 #define validation_get_random_int_correct_answer 10885
307 cfg[
"random_seed"] = validate_get_random_int_seed_generator();
331 BOOST_AUTO_TEST_SUITE_END()
#define validation_get_random_int_num_draws
uint32_t get_next_random()
Get a new random number.
GLuint const GLfloat * val
void seed_random(const std::string &seed, const unsigned int call_count=0)
Same as uint32_t version, but uses a stringstream to convert given hex string.
BOOST_AUTO_TEST_SUITE(test_map_location)
Definitions for the interface to Wesnoth Markup Language (WML).
std::string get_random_seed_str() const
unsigned int get_random_calls() const
BOOST_AUTO_TEST_CASE(validate_mt19937)
#define validation_get_random_int_correct_answer
This rng is used when the normal synced rng is not available this is currently only he case at the ve...
uint32_t get_random_seed() const
#define validation_get_random_int_max
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string