diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-02 17:49:32 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-04 19:37:38 +0200 |
| commit | 784020963f518aaba48b18b3fcff55d5c28a1f28 (patch) | |
| tree | 7055f3f6c421431ee21c83caf080848daedbfdec /test/make_digest_test.cc | |
| parent | 5316c4b7ba275dc6a8f4d2179dd22ad3c8dc42b5 (diff) | |
Make some tests repeatable across platforms.
Diffstat (limited to 'test/make_digest_test.cc')
| -rw-r--r-- | test/make_digest_test.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/make_digest_test.cc b/test/make_digest_test.cc index 9d37f837..98792e62 100644 --- a/test/make_digest_test.cc +++ b/test/make_digest_test.cc @@ -35,6 +35,7 @@ #include "array_data.h" #include "util.h" #include <boost/bind.hpp> +#include <boost/random.hpp> #include <boost/test/unit_test.hpp> #include <sys/time.h> @@ -49,15 +50,18 @@ void progress (float) BOOST_AUTO_TEST_CASE (make_digest_test) { /* Make a big file with some random data */ - srand (1); + + boost::random::mt19937 rng(1); + boost::random::uniform_int_distribution<> dist(0, 255); + int const N = 256 * 1024 * 1024; dcp::ArrayData data (N); auto p = data.data(); for (int i = 0; i < N; ++i) { - *p++ = rand() & 0xff; + *p++ = dist(rng); } data.write ("build/test/random"); /* Hash it */ - BOOST_CHECK_EQUAL (dcp::make_digest("build/test/random", boost::bind(&progress, _1)), "GKbk/V3fcRtP5MaPdSmAGNbKkaU="); + BOOST_CHECK_EQUAL (dcp::make_digest("build/test/random", boost::bind(&progress, _1)), "HayqPBWBRKqLNgfuo4XSajc+D5s="); } |
