/* haertel.hpp file * * Copyright Jens Maurer 2000, 2002 * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * $Id$ * * Revision history */ #include #include #include #include "haertel.hpp" #define BOOST_TEST_MAIN #include template inline void check_validation(Gen & gen, T value, const std::string & name) { for(int i = 0; i < 100000-1; ++i) gen(); typename Gen::result_type actual = gen(); BOOST_CHECK_MESSAGE(value == actual, boost::str(boost::format("%s: check value == gen() failed [%d != %d]") % name % value % actual)); } // we have validation after 100000 steps with Haertel's generators template void validate(T value, const std::string & name) { Gen gen(1234567); check_validation(gen, value, name); } BOOST_AUTO_TEST_CASE(test_haertel) { using namespace Haertel; validate(183269031u, "LCG_Af2"); validate(522319944u, "LCG_Die1"); validate(-2065162233u, "LCG_Fis"); validate(581815473u, "LCG_FM"); validate(28931709, "LCG_Hae"); validate(1508154087u, "LCG_VAX"); validate(6666884, "NLG_Inv2"); validate(1521640076, "NLG_Inv4"); validate(641840839, "NLG_Inv5"); static const int acorn7_init[] = { 1234567, 7654321, 246810, 108642, 13579, 97531, 555555 }; MRG_Acorn7 acorn7(acorn7_init); check_validation(acorn7, 874294697, "MRG_Acorn7"); // This currently fails. I don't want to touch it until // I trace the source of this generator. --SJW validate(1234567u, "MRG_Fib2"); }