diff options
-rw-r--r-- | src/libexpr/tests/value/context.cc | 35 | ||||
-rw-r--r-- | src/libexpr/tests/value/context.hh | 15 | ||||
-rw-r--r-- | src/libstore/tests/derived-path.cc | 24 | ||||
-rw-r--r-- | src/libstore/tests/derived-path.hh | 10 |
4 files changed, 67 insertions, 17 deletions
diff --git a/src/libexpr/tests/value/context.cc b/src/libexpr/tests/value/context.cc index 75934ab31..083359b7a 100644 --- a/src/libexpr/tests/value/context.cc +++ b/src/libexpr/tests/value/context.cc @@ -78,22 +78,37 @@ TEST_F(NixStringContextElemTest, built) { namespace rc { using namespace nix; +Gen<NixStringContextElem::Opaque> Arbitrary<NixStringContextElem::Opaque>::arbitrary() +{ + return gen::just(NixStringContextElem::Opaque { + .path = *gen::arbitrary<StorePath>(), + }); +} + +Gen<NixStringContextElem::DrvDeep> Arbitrary<NixStringContextElem::DrvDeep>::arbitrary() +{ + return gen::just(NixStringContextElem::DrvDeep { + .drvPath = *gen::arbitrary<StorePath>(), + }); +} + +Gen<NixStringContextElem::Built> Arbitrary<NixStringContextElem::Built>::arbitrary() +{ + return gen::just(NixStringContextElem::Built { + .drvPath = *gen::arbitrary<StorePath>(), + .output = (*gen::arbitrary<StorePathName>()).name, + }); +} + Gen<NixStringContextElem> Arbitrary<NixStringContextElem>::arbitrary() { switch (*gen::inRange<uint8_t>(0, 2)) { case 0: - return gen::just((NixStringContextElem) NixStringContextElem::Opaque { - .path = *gen::arbitrary<StorePath>(), - }); + return gen::just<NixStringContextElem>(*gen::arbitrary<NixStringContextElem::Opaque>()); case 1: - return gen::just((NixStringContextElem) NixStringContextElem::DrvDeep { - .drvPath = *gen::arbitrary<StorePath>(), - }); + return gen::just<NixStringContextElem>(*gen::arbitrary<NixStringContextElem::DrvDeep>()); default: - return gen::just((NixStringContextElem) NixStringContextElem::Built { - .drvPath = *gen::arbitrary<StorePath>(), - .output = (*gen::arbitrary<StorePathName>()).name, - }); + return gen::just<NixStringContextElem>(*gen::arbitrary<NixStringContextElem::Built>()); } } diff --git a/src/libexpr/tests/value/context.hh b/src/libexpr/tests/value/context.hh index 83505962f..54d21760e 100644 --- a/src/libexpr/tests/value/context.hh +++ b/src/libexpr/tests/value/context.hh @@ -8,6 +8,21 @@ namespace rc { using namespace nix; template<> +struct Arbitrary<NixStringContextElem::Opaque> { + static Gen<NixStringContextElem::Opaque> arbitrary(); +}; + +template<> +struct Arbitrary<NixStringContextElem::Built> { + static Gen<NixStringContextElem::Built> arbitrary(); +}; + +template<> +struct Arbitrary<NixStringContextElem::DrvDeep> { + static Gen<NixStringContextElem::DrvDeep> arbitrary(); +}; + +template<> struct Arbitrary<NixStringContextElem> { static Gen<NixStringContextElem> arbitrary(); }; diff --git a/src/libstore/tests/derived-path.cc b/src/libstore/tests/derived-path.cc index 09887d1f0..d1ac2c5e7 100644 --- a/src/libstore/tests/derived-path.cc +++ b/src/libstore/tests/derived-path.cc @@ -10,18 +10,28 @@ namespace rc { using namespace nix; +Gen<DerivedPath::Opaque> Arbitrary<DerivedPath::Opaque>::arbitrary() +{ + return gen::just(DerivedPath::Opaque { + .path = *gen::arbitrary<StorePath>(), + }); +} + +Gen<DerivedPath::Built> Arbitrary<DerivedPath::Built>::arbitrary() +{ + return gen::just(DerivedPath::Built { + .drvPath = *gen::arbitrary<StorePath>(), + .outputs = *gen::arbitrary<OutputsSpec>(), + }); +} + Gen<DerivedPath> Arbitrary<DerivedPath>::arbitrary() { switch (*gen::inRange<uint8_t>(0, 1)) { case 0: - return gen::just((DerivedPath) DerivedPath::Opaque { - .path = *gen::arbitrary<StorePath>(), - }); + return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Opaque>()); default: - return gen::just((DerivedPath) DerivedPath::Built { - .drvPath = *gen::arbitrary<StorePath>(), - .outputs = *gen::arbitrary<OutputsSpec>(), - }); + return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Built>()); } } diff --git a/src/libstore/tests/derived-path.hh b/src/libstore/tests/derived-path.hh index 0161449ef..3bc812440 100644 --- a/src/libstore/tests/derived-path.hh +++ b/src/libstore/tests/derived-path.hh @@ -11,6 +11,16 @@ namespace rc { using namespace nix; template<> +struct Arbitrary<DerivedPath::Opaque> { + static Gen<DerivedPath::Opaque> arbitrary(); +}; + +template<> +struct Arbitrary<DerivedPath::Built> { + static Gen<DerivedPath::Built> arbitrary(); +}; + +template<> struct Arbitrary<DerivedPath> { static Gen<DerivedPath> arbitrary(); }; |