-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7713 from obsidiansystems/more-rapid-check
Add more property tests
- Loading branch information
Showing
23 changed files
with
381 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "libexprtests.hh" | ||
#include "tests/libexpr.hh" | ||
#include "value-to-json.hh" | ||
|
||
namespace nix { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "libexprtests.hh" | ||
#include "tests/libexpr.hh" | ||
|
||
namespace nix { | ||
// Testing of trivial expressions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include <rapidcheck/gen/Arbitrary.h> | ||
|
||
#include <value/context.hh> | ||
|
||
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(); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#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; | ||
|
||
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>(*gen::arbitrary<DerivedPath::Opaque>()); | ||
default: | ||
return gen::just<DerivedPath>(*gen::arbitrary<DerivedPath::Built>()); | ||
} | ||
} | ||
|
||
} | ||
|
||
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) | ||
{ | ||
} | ||
|
||
RC_GTEST_FIXTURE_PROP( | ||
DerivedPathTest, | ||
prop_round_rip, | ||
(const DerivedPath & o)) | ||
{ | ||
RC_ASSERT(o == DerivedPath::parse(*store, o.to_string(*store))); | ||
} | ||
|
||
} |
Oops, something went wrong.