Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61492 - in trunk/libs/random: src test
From: steven_at_[hidden]
Date: 2010-04-22 17:30:05


Author: steven_watanabe
Date: 2010-04-22 17:30:04 EDT (Thu, 22 Apr 2010)
New Revision: 61492
URL: http://svn.boost.org/trac/boost/changeset/61492

Log:
Add tests for random_device
Added:
   trunk/libs/random/test/test_random_device.cpp (contents, props changed)
Text files modified:
   trunk/libs/random/src/random_device.cpp | 2 +-
   trunk/libs/random/test/Jamfile.v2 | 2 ++
   2 files changed, 3 insertions(+), 1 deletions(-)

Modified: trunk/libs/random/src/random_device.cpp
==============================================================================
--- trunk/libs/random/src/random_device.cpp (original)
+++ trunk/libs/random/src/random_device.cpp 2010-04-22 17:30:04 EDT (Thu, 22 Apr 2010)
@@ -17,7 +17,7 @@
 #include <cassert>
 
 
-#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
+#if defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
 // A definition is required even for integral static constants
 const bool boost::random_device::has_fixed_range;
 const boost::random_device::result_type boost::random_device::min_value;

Modified: trunk/libs/random/test/Jamfile.v2
==============================================================================
--- trunk/libs/random/test/Jamfile.v2 (original)
+++ trunk/libs/random/test/Jamfile.v2 2010-04-22 17:30:04 EDT (Thu, 22 Apr 2010)
@@ -13,6 +13,8 @@
 run random_test.cpp ;
 run ../example/random_demo.cpp ;
 run validate.cpp ;
+run test_random_device.cpp /boost//random : : : <link>static : test_random_device ;
+run test_random_device.cpp /boost//random : : : <link>shared : test_random_device_dll ;
 
 local all-urngs =
     rand48

Added: trunk/libs/random/test/test_random_device.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_random_device.cpp 2010-04-22 17:30:04 EDT (Thu, 22 Apr 2010)
@@ -0,0 +1,26 @@
+/* boost random_test.cpp various tests
+ *
+ * Copyright (c) 2010 Steven Watanabe
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENCE_1_0.txt)
+ *
+ * $Id$
+ */
+
+#include <boost/nondet_random.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int argc, char** argv) {
+ boost::random_device rng;
+ double entropy = rng.entropy();
+ BOOST_CHECK_GE(entropy, 0);
+ for(int i = 0; i < 100; ++i) {
+ boost::random_device::result_type val = rng();
+ BOOST_CHECK_GE(val, (rng.min)());
+ BOOST_CHECK_LE(val, (rng.max)());
+ }
+ return 0;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk