aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/tests/derived-path.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-11 23:22:35 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-15 10:41:44 -0400
commitbbd7d5de090e200dbcf7e925e25b0b273c4290ff (patch)
treef17ae6a2544a57621284fcfa9ae49e45907462a7 /src/libstore/tests/derived-path.cc
parent0c49c1af28c7128d9dd140eb3ba392300778bd59 (diff)
Fix some bounds in rapid check instances
`inRange` is exclusive not inclusive: https://github.com/emil-e/rapidcheck/blob/master/doc/generators.md#usage Furthermore, use `std::variant_size_v` so we use the right number automatically. Finally, make the `switch` assert the discriminant is in bounds as expected.
Diffstat (limited to 'src/libstore/tests/derived-path.cc')
-rw-r--r--src/libstore/tests/derived-path.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstore/tests/derived-path.cc b/src/libstore/tests/derived-path.cc
index e6d32dbd0..160443ec1 100644
--- a/src/libstore/tests/derived-path.cc
+++ b/src/libstore/tests/derived-path.cc
@@ -27,11 +27,13 @@ Gen<DerivedPath::Built> Arbitrary<DerivedPath::Built>::arbitrary()
Gen<DerivedPath> Arbitrary<DerivedPath>::arbitrary()
{
- switch (*gen::inRange<uint8_t>(0, 1)) {
+ switch (*gen::inRange<uint8_t>(0, std::variant_size_v<DerivedPath::Raw>)) {
case 0:
return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Opaque>());
- default:
+ case 1:
return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Built>());
+ default:
+ assert(false);
}
}