diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2023-01-30 18:54:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-30 18:54:53 +0100 |
commit | c9b9260f348299aad70ea2010db6e291ee1e8114 (patch) | |
tree | 7c380cb7a6a04fc95d4397e35ba69dd53c235b0d /src/libstore/tests/outputs-spec.cc | |
parent | a31d7d4e5e5eeeb7ca12ca798dc383045e5be1a1 (diff) | |
parent | 560142fec0debefe7f983e60663dc3db4bdd79a9 (diff) |
Merge pull request #7713 from obsidiansystems/more-rapid-check
Add more property tests
Diffstat (limited to 'src/libstore/tests/outputs-spec.cc')
-rw-r--r-- | src/libstore/tests/outputs-spec.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libstore/tests/outputs-spec.cc b/src/libstore/tests/outputs-spec.cc index 06e4cabbd..984d1d963 100644 --- a/src/libstore/tests/outputs-spec.cc +++ b/src/libstore/tests/outputs-spec.cc @@ -2,6 +2,7 @@ #include <nlohmann/json.hpp> #include <gtest/gtest.h> +#include <rapidcheck/gtest.h> namespace nix { @@ -199,3 +200,34 @@ TEST_JSON(ExtendedOutputsSpec, names, R"(["a","b"])", (ExtendedOutputsSpec::Expl #undef TEST_JSON } + +namespace rc { +using namespace nix; + +Gen<OutputsSpec> Arbitrary<OutputsSpec>::arbitrary() +{ + switch (*gen::inRange<uint8_t>(0, 1)) { + case 0: + return gen::just((OutputsSpec) OutputsSpec::All { }); + default: + return gen::just((OutputsSpec) OutputsSpec::Names { + *gen::nonEmpty(gen::container<StringSet>(gen::map( + gen::arbitrary<StorePathName>(), + [](StorePathName n) { return n.name; }))), + }); + } +} + +} + +namespace nix { + +RC_GTEST_PROP( + OutputsSpec, + prop_round_rip, + (const OutputsSpec & o)) +{ + RC_ASSERT(o == OutputsSpec::parse(o.to_string())); +} + +} |