2023-01-29 18:52:38 +00:00
|
|
|
#include <regex>
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <rapidcheck/gtest.h>
|
|
|
|
|
|
|
|
#include "tests/derived-path.hh"
|
|
|
|
#include "tests/libstore.hh"
|
|
|
|
|
|
|
|
namespace rc {
|
|
|
|
using namespace nix;
|
|
|
|
|
2023-01-30 15:55:08 +00:00
|
|
|
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>(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-01-29 18:52:38 +00:00
|
|
|
Gen<DerivedPath> Arbitrary<DerivedPath>::arbitrary()
|
|
|
|
{
|
2023-05-12 03:22:35 +00:00
|
|
|
switch (*gen::inRange<uint8_t>(0, std::variant_size_v<DerivedPath::Raw>)) {
|
2023-01-29 18:52:38 +00:00
|
|
|
case 0:
|
2023-01-30 15:55:08 +00:00
|
|
|
return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Opaque>());
|
2023-05-12 03:22:35 +00:00
|
|
|
case 1:
|
2023-01-30 15:55:08 +00:00
|
|
|
return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Built>());
|
2023-05-12 03:22:35 +00:00
|
|
|
default:
|
|
|
|
assert(false);
|
2023-01-29 18:52:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class DerivedPathTest : public LibStoreTest
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
// FIXME: `RC_GTEST_FIXTURE_PROP` isn't calling `SetUpTestSuite` because it is
|
|
|
|
// no a real fixture.
|
|
|
|
//
|
|
|
|
// See https://github.com/emil-e/rapidcheck/blob/master/doc/gtest.md#rc_gtest_fixture_propfixture-name-args
|
|
|
|
TEST_F(DerivedPathTest, force_init)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-04-15 00:45:11 +00:00
|
|
|
RC_GTEST_FIXTURE_PROP(
|
|
|
|
DerivedPathTest,
|
|
|
|
prop_legacy_round_rip,
|
|
|
|
(const DerivedPath & o))
|
|
|
|
{
|
|
|
|
RC_ASSERT(o == DerivedPath::parseLegacy(*store, o.to_string_legacy(*store)));
|
|
|
|
}
|
|
|
|
|
2023-01-29 18:52:38 +00:00
|
|
|
RC_GTEST_FIXTURE_PROP(
|
|
|
|
DerivedPathTest,
|
|
|
|
prop_round_rip,
|
|
|
|
(const DerivedPath & o))
|
|
|
|
{
|
|
|
|
RC_ASSERT(o == DerivedPath::parse(*store, o.to_string(*store)));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|