test_random_device.cpp 766 B

1234567891011121314151617181920212223242526272829
  1. /* boost random_test.cpp various tests
  2. *
  3. * Copyright (c) 2010 Steven Watanabe
  4. * Distributed under the Boost Software License, Version 1.0. (See
  5. * accompanying file LICENSE_1_0.txt or copy at
  6. * http://www.boost.org/LICENCE_1_0.txt)
  7. *
  8. * $Id$
  9. */
  10. #include <boost/random/random_device.hpp>
  11. #include <boost/test/test_tools.hpp>
  12. #include <boost/test/included/test_exec_monitor.hpp>
  13. int test_main(int, char**) {
  14. boost::random_device rng;
  15. double entropy = rng.entropy();
  16. BOOST_CHECK_GE(entropy, 0);
  17. for(int i = 0; i < 100; ++i) {
  18. boost::random_device::result_type val = rng();
  19. BOOST_CHECK_GE(val, (rng.min)());
  20. BOOST_CHECK_LE(val, (rng.max)());
  21. }
  22. boost::uint32_t a[10];
  23. rng.generate(a, a + 10);
  24. return 0;
  25. }