Files
lix/tests/unit/libutil-support/tests/hash.cc
T
FireFly a8c3fbf0cc tests: ignore deprecated uses in rapidcheck
There is a pull request [1] addressing these upstream--it doesn't appear
likely to be merged anytime soon though... this is a no-op til we enable
-Wdeprecated-declarations, but helps in the direction of #744

[1]: https://github.com/emil-e/rapidcheck/pull/325

Change-Id: I27e2c7d81df152de8674696f2a56d5f21c414ce3
2025-04-09 17:04:42 +02:00

32 lines
847 B
C++

// required due to rapidcheck generating an incomplete-return-type error due to
// missing include on libc++ on macOS
#include <exception> // IWYU pragma: keep
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <rapidcheck.h>
#pragma GCC diagnostic pop
#include "hash.hh"
#include "tests/hash.hh"
namespace rc {
using namespace nix;
Gen<Hash> Arbitrary<Hash>::arbitrary()
{
Hash prototype(HashType::SHA1);
return
gen::apply(
[](const std::vector<uint8_t> & v) {
Hash hash(HashType::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>())
);
}
}