/* boost random_test.cpp various tests * * Copyright Jens Maurer 2000 * 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$ */ #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 #pragma warning( disable : 4786 ) #endif #include #include #include #include #include #include #include #include #include #include #include template void test(const std::string & name, const PRNG &) { using namespace boost::random::parallel; std::cout << "Testing " << name << ": "; PRNG rng; // default ctor for(int i = 0; i < 10000; i++) rng(); typename PRNG::result_type val = rng(); PRNG rng2(stream_number=0, global_seed=0, total_streams=1); for(int i = 0; i < 10000; i++) rng2(); typename PRNG::result_type val2 = rng2(); PRNG rng3(stream_number=1, total_streams=2); for(int i = 0; i < 10000; i++) rng3(); typename PRNG::result_type val3 = rng3(); PRNG rng4; seed(rng4,1,2,0); for(int i = 0; i < 10000; i++) rng4(); typename PRNG::result_type val4 = rng4(); PRNG rng5; std::vector buffer(1,0); std::vector::iterator it=buffer.begin(); seed(rng5,1,2,it,buffer.end()); for(int i = 0; i < 10000; i++) rng5(); typename PRNG::result_type val5 = rng5(); bool result = (val==val2) && (val != val3) && (val3==val4) && (val4==val5); std::cout << val << " " << val2 << " " << val3 << " " << val4 << std::endl; BOOST_CHECK(result); } void test_all() { test("lcg64a", boost::lcg64a()); } int test_main(int, char*[]) { test_all(); return 0; }