mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
dropEmptyInitThenConcatStringSep: Check that we don't drop...
... initial empty strings. The tests pass, which is encouraging.
This commit is contained in:
parent
1a8defd06f
commit
79eb0adf9d
2 changed files with 12 additions and 0 deletions
|
@ -41,6 +41,11 @@ public:
|
|||
}
|
||||
|
||||
friend std::ostream & operator <<(std::ostream & os, const SymbolStr & symbol);
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return s->empty();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,6 +40,13 @@ template<class C>
|
|||
std::string dropEmptyInitThenConcatStringsSep(const std::string_view sep, const C & ss)
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
for (auto & i : ss) {
|
||||
// Make sure we don't rely on the empty item ignoring behavior
|
||||
assert(!i.empty());
|
||||
break;
|
||||
}
|
||||
|
||||
// need a cast to string_view since this is also called with Symbols
|
||||
for (const auto & s : ss) size += sep.size() + std::string_view(s).size();
|
||||
std::string s;
|
||||
|
|
Loading…
Reference in a new issue