Gen::just is the constant generator. Don't just return that!
(cherry picked from commit 8406da28773f050e00a006e4812e3ecbf919a2a9)
Change-Id: Ibfd0bd40f90942077a4720086ce0cd3bfabef79d
28 lines
575 B
C++
28 lines
575 B
C++
#include <regex>
|
|
|
|
#include <rapidcheck.h>
|
|
|
|
#include "hash.hh"
|
|
|
|
#include "tests/hash.hh"
|
|
|
|
namespace rc {
|
|
using namespace nix;
|
|
|
|
Gen<Hash> Arbitrary<Hash>::arbitrary()
|
|
{
|
|
Hash prototype(htSHA1);
|
|
return
|
|
gen::apply(
|
|
[](const std::vector<uint8_t> & v) {
|
|
Hash hash(htSHA1);
|
|
assert(v.size() == hash.hashSize);
|
|
std::copy(v.begin(), v.end(), hash.hash);
|
|
return hash;
|
|
},
|
|
gen::container<std::vector<uint8_t>>(prototype.hashSize, gen::arbitrary<uint8_t>())
|
|
);
|
|
}
|
|
|
|
}
|