Still converting to bootstrap 5. Converted release dropdown
This commit is contained in:
@@ -31,34 +31,43 @@
|
||||
|
||||
namespace StringUtils {
|
||||
|
||||
[[nodiscard]]
|
||||
std::vector<std::string>
|
||||
splitStringCopy(std::string_view string, std::string_view separators);
|
||||
|
||||
[[nodiscard]]
|
||||
std::vector<std::string_view>
|
||||
splitString(std::string_view string, std::string_view separators);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
joinStrings(const std::vector<std::string>& strings, const std::string& delimiter);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
stringTrim(std::string_view str, std::string_view whitespaces = " \t");
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
stringTrimEnd(std::string_view str, std::string_view whitespaces = " \t");
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
stringToLower(std::string_view str);
|
||||
|
||||
void
|
||||
stringToLower(std::string& str);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
stringToUpper(const std::string& str);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
bufferToString(const std::vector<unsigned char>& data);
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]]
|
||||
std::optional<T> readAs(std::string_view str)
|
||||
{
|
||||
T res;
|
||||
@@ -72,21 +81,27 @@ std::optional<T> readAs(std::string_view str)
|
||||
}
|
||||
|
||||
template<>
|
||||
[[nodiscard]]
|
||||
std::optional<std::string>
|
||||
readAs(std::string_view str);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
replaceInString(const std::string& str, const std::string& from, const std::string& to);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
jsEscape(const std::string& str);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
escapeString(std::string_view str, std::string_view charsToEscape, char escapeChar);
|
||||
|
||||
[[nodiscard]]
|
||||
bool
|
||||
stringEndsWith(const std::string& str, const std::string& ending);
|
||||
|
||||
[[nodiscard]]
|
||||
std::optional<std::string>
|
||||
stringFromHex(const std::string& str);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
TEST(StringUtils, splitString)
|
||||
{
|
||||
{
|
||||
const std::string test{"a"};
|
||||
const std::string test {"a"};
|
||||
|
||||
const std::vector<std::string_view> strings {StringUtils::splitString(test, "")};
|
||||
ASSERT_EQ(strings.size(), 1);
|
||||
@@ -32,7 +32,7 @@ TEST(StringUtils, splitString)
|
||||
}
|
||||
|
||||
{
|
||||
const std::string test{"a b"};
|
||||
const std::string test {"a b"};
|
||||
|
||||
const std::vector<std::string_view> strings {StringUtils::splitString(test, "|")};
|
||||
ASSERT_EQ(strings.size(), 1);
|
||||
@@ -40,7 +40,7 @@ TEST(StringUtils, splitString)
|
||||
}
|
||||
|
||||
{
|
||||
const std::string test{" a"};
|
||||
const std::string test {" a"};
|
||||
|
||||
const std::vector<std::string_view> strings {StringUtils::splitString(test, " ")};
|
||||
ASSERT_EQ(strings.size(), 1);
|
||||
@@ -48,7 +48,7 @@ TEST(StringUtils, splitString)
|
||||
}
|
||||
|
||||
{
|
||||
const std::string test{"a "};
|
||||
const std::string test {"a "};
|
||||
|
||||
const std::vector<std::string_view> strings {StringUtils::splitString(test, " ")};
|
||||
ASSERT_EQ(strings.size(), 1);
|
||||
@@ -56,7 +56,7 @@ TEST(StringUtils, splitString)
|
||||
}
|
||||
|
||||
{
|
||||
const std::string test{"a b"};
|
||||
const std::string test {"a b"};
|
||||
|
||||
const std::vector<std::string_view> strings {StringUtils::splitString(test, " ")};
|
||||
ASSERT_EQ(strings.size(), 2);
|
||||
@@ -65,7 +65,7 @@ TEST(StringUtils, splitString)
|
||||
}
|
||||
|
||||
{
|
||||
const std::string test{"a b,c|defgh "};
|
||||
const std::string test {"a b,c|defgh "};
|
||||
|
||||
const std::vector<std::string_view> strings {StringUtils::splitString(test, " ,|")};
|
||||
ASSERT_EQ(strings.size(), 4);
|
||||
@@ -76,6 +76,28 @@ TEST(StringUtils, splitString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(StringUtils, splitStringCopy)
|
||||
{
|
||||
{
|
||||
const std::string test {"test=foo"};
|
||||
|
||||
const std::vector<std::string> strings {StringUtils::splitStringCopy(test, "=")};
|
||||
ASSERT_EQ(strings.size(), 2);
|
||||
EXPECT_EQ(strings[0], "test");
|
||||
EXPECT_EQ(strings[1], "foo");
|
||||
}
|
||||
|
||||
{
|
||||
const std::string test {"test=foo bar"};
|
||||
|
||||
const std::vector<std::string> strings {StringUtils::splitStringCopy(test, "=")};
|
||||
ASSERT_EQ(strings.size(), 2);
|
||||
EXPECT_EQ(strings[0], "test");
|
||||
EXPECT_EQ(strings[1], "foo bar");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(StringUtils, escapeString)
|
||||
{
|
||||
EXPECT_EQ(StringUtils::escapeString("", "*", ' '), "");
|
||||
|
||||
Reference in New Issue
Block a user