forked from lix-project/lix
test: Generate distinct hashes
Gen::just is the constant generator. Don't just return that!
(cherry picked from commit 8406da28773f050e00a006e4812e3ecbf919a2a9)
Change-Id: Ibfd0bd40f90942077a4720086ce0cd3bfabef79d
This commit is contained in:
parent
2eec547d7d
commit
4b3dc66386
|
@ -11,10 +11,17 @@ using namespace nix;
|
||||||
|
|
||||||
Gen<Hash> Arbitrary<Hash>::arbitrary()
|
Gen<Hash> Arbitrary<Hash>::arbitrary()
|
||||||
{
|
{
|
||||||
Hash hash(htSHA1);
|
Hash prototype(htSHA1);
|
||||||
for (size_t i = 0; i < hash.hashSize; ++i)
|
return
|
||||||
hash.hash[i] = *gen::arbitrary<uint8_t>();
|
gen::apply(
|
||||||
return gen::just(hash);
|
[](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>())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue