mirror of
https://github.com/NixOS/nix
synced 2025-06-24 18:01:16 +02:00
Add fresh concatStringsSep without bug
The buggy version was previously renamed to dropEmptyInitThenConcatStringsSep
This commit is contained in:
parent
79eb0adf9d
commit
a681d354e7
5 changed files with 150 additions and 0 deletions
83
tests/unit/libutil/strings.cc
Normal file
83
tests/unit/libutil/strings.cc
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "strings.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
using Strings = std::vector<std::string>;
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* concatStringsSep
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(concatStringsSep, empty)
|
||||
{
|
||||
Strings strings;
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), "");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, justOne)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("this");
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), "this");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, emptyString)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("");
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), "");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, emptyStrings)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("");
|
||||
strings.push_back("");
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), ",");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, threeEmptyStrings)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("");
|
||||
strings.push_back("");
|
||||
strings.push_back("");
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), ",,");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, buildCommaSeparatedString)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("this");
|
||||
strings.push_back("is");
|
||||
strings.push_back("great");
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), "this,is,great");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, buildStringWithEmptySeparator)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("this");
|
||||
strings.push_back("is");
|
||||
strings.push_back("great");
|
||||
|
||||
ASSERT_EQ(concatStringsSep("", strings), "thisisgreat");
|
||||
}
|
||||
|
||||
TEST(concatStringsSep, buildSingleString)
|
||||
{
|
||||
Strings strings;
|
||||
strings.push_back("this");
|
||||
|
||||
ASSERT_EQ(concatStringsSep(",", strings), "this");
|
||||
}
|
||||
|
||||
} // namespace nix
|
Loading…
Add table
Add a link
Reference in a new issue