Subonsic API: added estimateContentLength parameter support for stream endpoint. fixes #244
This commit is contained in:
@@ -63,6 +63,18 @@ readAs(std::string_view str)
|
||||
return std::string {str};
|
||||
}
|
||||
|
||||
template<>
|
||||
std::optional<bool>
|
||||
readAs(std::string_view str)
|
||||
{
|
||||
if (str == "1" || str == "true")
|
||||
return true;
|
||||
else if (str == "0" || str == "false")
|
||||
return false;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
splitStringCopy(std::string_view string, std::string_view separators)
|
||||
{
|
||||
|
||||
@@ -85,6 +85,11 @@ template<>
|
||||
std::optional<std::string>
|
||||
readAs(std::string_view str);
|
||||
|
||||
template<>
|
||||
[[nodiscard]]
|
||||
std::optional<bool>
|
||||
readAs(std::string_view str);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
replaceInString(std::string_view str, const std::string& from, const std::string& to);
|
||||
|
||||
@@ -109,3 +109,12 @@ TEST(StringUtils, escapeString)
|
||||
EXPECT_EQ(StringUtils::escapeString("**||", "*|", '_'), "_*_*_|_|");
|
||||
}
|
||||
|
||||
TEST(StringUtils, readAs)
|
||||
{
|
||||
EXPECT_EQ(StringUtils::readAs<bool>("true"), true);
|
||||
EXPECT_EQ(StringUtils::readAs<bool>("1"), true);
|
||||
EXPECT_EQ(StringUtils::readAs<bool>("false"), false);
|
||||
EXPECT_EQ(StringUtils::readAs<bool>("0"), false);
|
||||
EXPECT_EQ(StringUtils::readAs<bool>("foo"), std::nullopt);
|
||||
EXPECT_EQ(StringUtils::readAs<bool>(""), std::nullopt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user