mirror of
https://github.com/NixOS/nix.git
synced 2025-11-10 04:26:01 +01:00
libutil: Move references.{hh,cc} to libstore
The implicit dependency on refLength (which is the StorePath::HashLen) is not good. Also the companion tests and benchmarks are already in libstore-tests.
This commit is contained in:
parent
1b4aa5c1ef
commit
2e3ebfb829
15 changed files with 48 additions and 59 deletions
|
|
@ -66,7 +66,6 @@ sources = files(
|
|||
'pool.cc',
|
||||
'position.cc',
|
||||
'processes.cc',
|
||||
'references.cc',
|
||||
'sort.cc',
|
||||
'spawn.cc',
|
||||
'strings.cc',
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
#include "nix/util/references.hh"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace nix {
|
||||
|
||||
using std::string;
|
||||
|
||||
struct RewriteParams
|
||||
{
|
||||
string originalString, finalString;
|
||||
StringMap rewrites;
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & os, const RewriteParams & bar)
|
||||
{
|
||||
StringSet strRewrites;
|
||||
for (auto & [from, to] : bar.rewrites)
|
||||
strRewrites.insert(from + "->" + to);
|
||||
return os << "OriginalString: " << bar.originalString << std::endl
|
||||
<< "Rewrites: " << dropEmptyInitThenConcatStringsSep(",", strRewrites) << std::endl
|
||||
<< "Expected result: " << bar.finalString;
|
||||
}
|
||||
};
|
||||
|
||||
class RewriteTest : public ::testing::TestWithParam<RewriteParams>
|
||||
{};
|
||||
|
||||
TEST_P(RewriteTest, IdentityRewriteIsIdentity)
|
||||
{
|
||||
RewriteParams param = GetParam();
|
||||
StringSink rewritten;
|
||||
auto rewriter = RewritingSink(param.rewrites, rewritten);
|
||||
rewriter(param.originalString);
|
||||
rewriter.flush();
|
||||
ASSERT_EQ(rewritten.s, param.finalString);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
references,
|
||||
RewriteTest,
|
||||
::testing::Values(
|
||||
RewriteParams{"foooo", "baroo", {{"foo", "bar"}, {"bar", "baz"}}},
|
||||
RewriteParams{"foooo", "bazoo", {{"fou", "bar"}, {"foo", "baz"}}},
|
||||
RewriteParams{"foooo", "foooo", {}}));
|
||||
|
||||
} // namespace nix
|
||||
Loading…
Add table
Add a link
Reference in a new issue