mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
8406da2877
Gen::just is the constant generator. Don't just return that!
27 lines
601 B
C++
27 lines
601 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(HashAlgorithm::SHA1);
|
|
return
|
|
gen::apply(
|
|
[](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>())
|
|
);
|
|
}
|
|
|
|
}
|