This is an automated email from the ASF dual-hosted git repository.
aboda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 598abe0 MINIFICPP-1101 - Fix std::pointer_to_unary_function
deprecated warnings
598abe0 is described below
commit 598abe08ce4693270bad20f552e2e1c6c3c7d7dc
Author: Daniel Bakai <[email protected]>
AuthorDate: Thu Dec 12 15:32:12 2019 +0100
MINIFICPP-1101 - Fix std::pointer_to_unary_function deprecated warnings
Signed-off-by: Arpad Boda <[email protected]>
This closes #693
---
libminifi/include/utils/StringUtils.h | 4 ++--
libminifi/test/unit/StringUtilsTests.cpp | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/libminifi/include/utils/StringUtils.h
b/libminifi/include/utils/StringUtils.h
index fc44d93..ef0a849 100644
--- a/libminifi/include/utils/StringUtils.h
+++ b/libminifi/include/utils/StringUtils.h
@@ -100,7 +100,7 @@ class StringUtils {
* @returns modified string
*/
static inline std::string trimLeft(std::string s) {
- s.erase(s.begin(), std::find_if(s.begin(), s.end(),
std::not1(std::pointer_to_unary_function<int, int>(isspace))));
+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](char c) -> bool {
return !isspace(c); }));
return s;
}
@@ -111,7 +111,7 @@ class StringUtils {
*/
static inline std::string trimRight(std::string s) {
- s.erase(std::find_if(s.rbegin(), s.rend(),
std::not1(std::pointer_to_unary_function<int, int>(isspace))).base(), s.end());
+ s.erase(std::find_if(s.rbegin(), s.rend(), [](char c) -> bool { return
!isspace(c); }).base(), s.end());
return s;
}
diff --git a/libminifi/test/unit/StringUtilsTests.cpp
b/libminifi/test/unit/StringUtilsTests.cpp
index 30fac99..771d0d0 100644
--- a/libminifi/test/unit/StringUtilsTests.cpp
+++ b/libminifi/test/unit/StringUtilsTests.cpp
@@ -123,6 +123,38 @@ TEST_CASE("TestStringUtils::testJoin", "[test string
join]") {
REQUIRE(StringUtils::join("this separator wont appear",
std::vector<std::string>()) == "");
}
+TEST_CASE("TestStringUtils::trim", "[test trim]") {
+ REQUIRE("" == StringUtils::trim(" \n\t"));
+ REQUIRE("foobar" == StringUtils::trim("foobar"));
+ REQUIRE("foo bar" == StringUtils::trim("foo bar"));
+ REQUIRE("foobar" == StringUtils::trim("foobar "));
+ REQUIRE("foobar" == StringUtils::trim(" foobar"));
+ REQUIRE("foobar" == StringUtils::trim("foobar "));
+ REQUIRE("foobar" == StringUtils::trim(" foobar"));
+ REQUIRE("foobar" == StringUtils::trim(" foobar "));
+ REQUIRE("foobar" == StringUtils::trim(" \n\tfoobar\n\t "));
+
+ REQUIRE("" == StringUtils::trimRight(" \n\t"));
+ REQUIRE("foobar" == StringUtils::trimRight("foobar"));
+ REQUIRE("foo bar" == StringUtils::trimRight("foo bar"));
+ REQUIRE("foobar" == StringUtils::trimRight("foobar "));
+ REQUIRE(" foobar" == StringUtils::trimRight(" foobar"));
+ REQUIRE("foobar" == StringUtils::trimRight("foobar "));
+ REQUIRE(" foobar" == StringUtils::trimRight(" foobar"));
+ REQUIRE(" foobar" == StringUtils::trimRight(" foobar "));
+ REQUIRE(" \n\tfoobar" == StringUtils::trimRight(" \n\tfoobar\n\t "));
+
+ REQUIRE("" == StringUtils::trimLeft(" \n\t"));
+ REQUIRE("foobar" == StringUtils::trimLeft("foobar"));
+ REQUIRE("foo bar" == StringUtils::trimLeft("foo bar"));
+ REQUIRE("foobar " == StringUtils::trimLeft("foobar "));
+ REQUIRE("foobar" == StringUtils::trimLeft(" foobar"));
+ REQUIRE("foobar " == StringUtils::trimLeft("foobar "));
+ REQUIRE("foobar" == StringUtils::trimLeft(" foobar"));
+ REQUIRE("foobar " == StringUtils::trimLeft(" foobar "));
+ REQUIRE("foobar\n\t " == StringUtils::trimLeft(" \n\tfoobar\n\t "));
+}
+
TEST_CASE("TestStringUtils::testHexEncode", "[test hex encode]") {
REQUIRE("" == StringUtils::to_hex(""));
REQUIRE("6f" == StringUtils::to_hex("o"));