mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
test: Generate distinct hashes
Gen::just is the constant generator. Don't just return that!
This commit is contained in:
parent
69bbd5852a
commit
8406da2877
1 changed files with 11 additions and 4 deletions
|
@ -11,10 +11,17 @@ using namespace nix;
|
||||||
|
|
||||||
Gen<Hash> Arbitrary<Hash>::arbitrary()
|
Gen<Hash> Arbitrary<Hash>::arbitrary()
|
||||||
{
|
{
|
||||||
Hash hash(HashAlgorithm::SHA1);
|
Hash prototype(HashAlgorithm::SHA1);
|
||||||
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(HashAlgorithm::SHA1);
|
||||||
|
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