20 #if HAVE_BOOST_SERIALIZATION
24 #pragma warning (disable: 4244 4996)
26 #include <boost/archive/xml_iarchive.hpp>
27 #include <boost/archive/xml_oarchive.hpp>
35 std::cout <<
"Using " << r.Name() <<
"\n"
36 <<
"with seed " << r.SeedString() <<
"\n";
39 std::cout <<
"Test save and restore with copy constructor... ";
41 r.StepCount(step); s.StepCount(step);
42 std::cout << (r == s && r() == s()
43 ?
"succeeded\n" : (retval = 1,
"failed\n"));
46 std::cout <<
"Test save state via count... ";
47 long long savecount = r.Count();
50 r.SetCount(savecount);
51 std::cout << (d == r.
Fixed()
52 ?
"succeeded\n" : (retval = 1,
"failed\n"));
55 std::cout <<
"Test save state via seed and count... ";
57 s.SetCount(r.Count());
58 r.StepCount(step); s.StepCount(step);
59 std::cout << (r == s && r() == s()
60 ?
"succeeded\n" : (retval = 1,
"failed\n"));
63 std::cout <<
"Test save state to file in portable binary format... ";
65 std::ofstream f(
"rand.bin", std::ios::binary);
70 std::ifstream f(
"rand.bin", std::ios::binary);
73 r.StepCount(step); s.StepCount(step);
74 std::cout << (r == s && r() == s()
75 ?
"succeeded\n" : (retval = 1,
"failed\n"));
78 std::cout <<
"Test save state to file in text format... ";
80 std::ofstream f(
"rand.txt");
81 f <<
"Random number state:\n" << r <<
"\n";
85 std::ifstream f(
"rand.txt");
90 r.StepCount(step); s.StepCount(step);
91 std::cout << (r == s && r() == s()
92 ?
"succeeded\n" : (retval = 1,
"failed\n"));
95 #if HAVE_BOOST_SERIALIZATION
96 std::cout <<
"Test save state to file in boost xml format... ";
98 std::ofstream f(
"rand.xml");
99 boost::archive::xml_oarchive oa(f);
100 oa << BOOST_SERIALIZATION_NVP(r);
104 std::ifstream f(
"rand.xml");
105 boost::archive::xml_iarchive ia(f);
106 ia >> BOOST_SERIALIZATION_NVP(s);
108 r.StepCount(step); s.StepCount(step);
109 std::cout << (r == s && r() == s()
110 ?
"succeeded\n" : (retval = 1,
"failed\n"));
112 std::cout <<
"Skipping boost tests\n";
Generate random integers, reals, and booleans.
Header for Random, RandomGenerator.