bakaid commented on a change in pull request #596: MINIFICPP-925 - Fix TailFile
hang on long lines
URL: https://github.com/apache/nifi-minifi-cpp/pull/596#discussion_r297579560
##########
File path: libminifi/test/unit/StringUtilsTests.cpp
##########
@@ -93,3 +93,49 @@ TEST_CASE("TestStringUtils::testEnv5", "[test split
classname]") {
REQUIRE(expected == StringUtils::replaceEnvironmentVariables(test_string));
}
+
+TEST_CASE("TestStringUtils::testHexEncode", "[test hex encode]") {
+ REQUIRE("" == StringUtils::to_hex(""));
+ REQUIRE("6f" == StringUtils::to_hex("o"));
+ REQUIRE("666f6f626172" == StringUtils::to_hex("foobar"));
+ REQUIRE("000102030405060708090a0b0c0d0e0f" == StringUtils::to_hex({0x00,
0x01, 0x02, 0x03,
+ 0x04,
0x05, 0x06, 0x07,
+ 0x08,
0x09, 0x0a, 0x0b,
+ 0x0c,
0x0d, 0x0e, 0x0f}));
+ REQUIRE("6F" == StringUtils::to_hex("o", true /*uppercase*/));
+ REQUIRE("666F6F626172" == StringUtils::to_hex("foobar", true /*uppercase*/));
+ REQUIRE("000102030405060708090A0B0C0D0E0F" == StringUtils::to_hex({0x00,
0x01, 0x02, 0x03,
+ 0x04,
0x05, 0x06, 0x07,
+ 0x08,
0x09, 0x0a, 0x0b,
+ 0x0c,
0x0d, 0x0e, 0x0f}, true /*uppercase*/));
+}
+
+TEST_CASE("TestStringUtils::testHexDecode", "[test hex decode]") {
+ REQUIRE("" == StringUtils::from_hex(""));
+ REQUIRE("o" == StringUtils::from_hex("6f"));
+ REQUIRE("o" == StringUtils::from_hex("6F"));
+ REQUIRE("foobar" == StringUtils::from_hex("666f6f626172"));
+ REQUIRE("foobar" == StringUtils::from_hex("666F6F626172"));
+ REQUIRE("foobar" == StringUtils::from_hex("66:6F:6F:62:61:72"));
+ REQUIRE("foobar" == StringUtils::from_hex("66 6F 6F 62 61 72"));
+ REQUIRE(std::string({0x00, 0x01, 0x02, 0x03,
+ 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b,
+ 0x0c, 0x0d, 0x0e, 0x0f}) ==
StringUtils::from_hex("000102030405060708090a0b0c0d0e0f"));
+ REQUIRE(std::string({0x00, 0x01, 0x02, 0x03,
+ 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b,
+ 0x0c, 0x0d, 0x0e, 0x0f}) ==
StringUtils::from_hex("000102030405060708090A0B0C0D0E0F"));
+ try {
+ StringUtils::from_hex("666f6f62617");
Review comment:
Thank you!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services