From e9554ea798248ce07368fc69f8c6c0353a4b7ddd Mon Sep 17 00:00:00 2001 From: Ankita Victor Date: Mon, 18 Mar 2024 18:42:56 +0530 Subject: [PATCH] Update to const --- velox/functions/sparksql/tests/StringTest.cpp | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/velox/functions/sparksql/tests/StringTest.cpp b/velox/functions/sparksql/tests/StringTest.cpp index 93fc44c254ea..d77dd3b3dd28 100644 --- a/velox/functions/sparksql/tests/StringTest.cpp +++ b/velox/functions/sparksql/tests/StringTest.cpp @@ -29,7 +29,7 @@ class StringTest : public SparkFunctionBaseTest { }; TEST_F(StringTest, ascii) { - const auto ascii = [&](const std::string& arg) { + const auto ascii = [&](const std::optional& arg) { return evaluateOnce("ascii(c0)", arg); }; EXPECT_EQ(ascii(std::string("\0", 1)), 0); @@ -50,7 +50,7 @@ TEST_F(StringTest, ascii) { } TEST_F(StringTest, bitLength) { - const auto bitLength = [&](const std::string& arg) { + const auto bitLength = [&](const std::optional& arg) { return evaluateOnce("bit_length(c0)", arg); }; @@ -65,7 +65,7 @@ TEST_F(StringTest, bitLength) { } TEST_F(StringTest, bitLengthVarbinary) { - const auto bitLength = [&](std::optional arg) { + const auto bitLength = [&](const std::optional& arg) { return evaluateOnce( "bit_length(c0)", {arg}, {VARBINARY()}); }; @@ -112,7 +112,7 @@ TEST_F(StringTest, contains) { } TEST_F(StringTest, conv) { - const auto conv = [&](std::optional str, + const auto conv = [&](const std::optional& str, std::optional fromBase, std::optional toBase) { return evaluateOnce("conv(c0, c1, c2)", str, fromBase, toBase); @@ -192,8 +192,8 @@ TEST_F(StringTest, endsWith) { } TEST_F(StringTest, findInSet) { - const auto findInSet = [&](std::optional str, - std::optional strArray) { + const auto findInSet = [&](const std::optional& str, + const std::optional& strArray) { return evaluateOnce("find_in_set(c0, c1)", str, strArray); }; EXPECT_EQ(findInSet("ab", "abc,b,ab,c,def"), 3); @@ -227,8 +227,8 @@ TEST_F(StringTest, findInSet) { } TEST_F(StringTest, instr) { - const auto instr = [&](std::optional haystack, - std::optional needle) { + const auto instr = [&](const std::optional& haystack, + const std::optional& needle) { return evaluateOnce("instr(c0, c1)", haystack, needle); }; EXPECT_EQ(instr("SparkSQL", "SQL"), 6); @@ -251,7 +251,7 @@ TEST_F(StringTest, instr) { } TEST_F(StringTest, left) { - const auto left = [&](std::optional str, + const auto left = [&](const std::optional& str, std::optional length) { return evaluateOnce("left(c0, c1)", str, length); }; @@ -267,7 +267,7 @@ TEST_F(StringTest, left) { } TEST_F(StringTest, lengthString) { - const auto length = [&](std::optional arg) { + const auto length = [&](const std::optional& arg) { return evaluateOnce("length(c0)", arg); }; EXPECT_EQ(length(""), 0); @@ -281,7 +281,7 @@ TEST_F(StringTest, lengthString) { } TEST_F(StringTest, lengthVarbinary) { - const auto length = [&](std::optional arg) { + const auto length = [&](const std::optional& arg) { return evaluateOnce( "length(c0)", {arg}, {VARBINARY()}); }; @@ -297,14 +297,14 @@ TEST_F(StringTest, lpad) { std::string invalidString = "Ψ\xFF\xFFΣΓΔA"; std::string invalidPadString = "\xFFΨ\xFF"; - const auto lpad = [&](std::optional string, + const auto lpad = [&](const std::optional& string, std::optional size) { return evaluateOnce("lpad(c0, c1)", string, size); }; - const auto lpadWithPadString = [&](std::optional string, + const auto lpadWithPadString = [&](const std::optional& string, std::optional size, - std::optional padString) { + const std::optional& padString) { return evaluateOnce( "lpad(c0, c1, c2)", string, size, padString); }; @@ -342,12 +342,12 @@ TEST_F(StringTest, lpad) { } TEST_F(StringTest, ltrim) { - const auto ltrim = [&](std::optional srcStr) { + const auto ltrim = [&](const std::optional& srcStr) { return evaluateOnce("ltrim(c0)", srcStr); }; - const auto ltrimWithTrimStr = [&](std::optional trimStr, - std::optional srcStr) { + const auto ltrimWithTrimStr = [&](const std::optional& trimStr, + const std::optional& srcStr) { return evaluateOnce("ltrim(c0, c1)", trimStr, srcStr); }; @@ -384,7 +384,7 @@ TEST_F(StringTest, ltrim) { } TEST_F(StringTest, md5) { - const auto md5 = [&](std::optional arg) { + const auto md5 = [&](const std::optional& arg) { return evaluateOnce( "md5(c0)", {arg}, {VARBINARY()}); }; @@ -394,8 +394,8 @@ TEST_F(StringTest, md5) { } TEST_F(StringTest, overlayVarchar) { - const auto overlay = [&](std::optional input, - std::optional replace, + const auto overlay = [&](const std::optional& input, + const std::optional& replace, std::optional pos, std::optional len) { // overlay is a keyword of DuckDB, use double quote avoid parse error. @@ -421,8 +421,8 @@ TEST_F(StringTest, overlayVarchar) { } TEST_F(StringTest, overlayVarbinary) { - const auto overlay = [&](std::optional input, - std::optional replace, + const auto overlay = [&](const std::optional& input, + const std::optional& replace, std::optional pos, std::optional len) { // overlay is a keyword of DuckDB, use double quote avoid parse error. @@ -451,14 +451,14 @@ TEST_F(StringTest, overlayVarbinary) { } TEST_F(StringTest, replace) { - const auto replace = [&](std::optional str, - std::optional replaced) { + const auto replace = [&](const std::optional& str, + const std::optional& replaced) { return evaluateOnce("replace(c0, c1)", str, replaced); }; - const auto replaceWithReplacement = [&](std::optional str, - std::optional replaced, - std::optional replacement) { + const auto replaceWithReplacement = [&](const std::optional& str, + const std::optional& replaced, + const std::optional& replacement) { return evaluateOnce( "replace(c0, c1, c2)", str, replaced, replacement); }; @@ -480,14 +480,14 @@ TEST_F(StringTest, rpad) { const std::string invalidString = "Ψ\xFF\xFFΣΓΔA"; const std::string invalidPadString = "\xFFΨ\xFF"; - const auto rpad = [&](std::optional string, + const auto rpad = [&](const std::optional& string, std::optional size) { return evaluateOnce("rpad(c0, c1)", string, size); }; - const auto rpadWithPadString = [&](std::optional string, + const auto rpadWithPadString = [&](const std::optional& string, std::optional size, - std::optional padString) { + const std::optional& padString) { return evaluateOnce( "rpad(c0, c1, c2)", string, size, padString); }; @@ -525,12 +525,12 @@ TEST_F(StringTest, rpad) { } TEST_F(StringTest, rtrim) { - const auto rtrim = [&](std::optional srcStr) { + const auto rtrim = [&](const std::optional& srcStr) { return evaluateOnce("rtrim(c0)", srcStr); }; - const auto rtrimWithTrimStr = [&](std::optional trimStr, - std::optional srcStr) { + const auto rtrimWithTrimStr = [&](const std::optional& trimStr, + const std::optional& srcStr) { return evaluateOnce("rtrim(c0, c1)", trimStr, srcStr); }; EXPECT_EQ(rtrim(""), ""); @@ -566,7 +566,7 @@ TEST_F(StringTest, rtrim) { } TEST_F(StringTest, sha1) { - const auto sha1 = [&](std::optional arg) { + const auto sha1 = [&](const std::optional& arg) { return evaluateOnce( "sha1(c0)", {arg}, {VARBINARY()}); }; @@ -580,7 +580,7 @@ TEST_F(StringTest, sha1) { } TEST_F(StringTest, sha2) { - const auto sha2 = [&](std::optional str, + const auto sha2 = [&](const std::optional& str, std::optional bitLength) { return evaluateOnce( "sha2(cast(c0 as varbinary), c1)", str, bitLength); @@ -658,12 +658,12 @@ TEST_F(StringTest, startsWith) { } TEST_F(StringTest, substring) { - const auto substring = [&](std::optional str, + const auto substring = [&](const std::optional& str, std::optional start) { return evaluateOnce("substring(c0, c1)", str, start); }; - const auto substringWithLength = [&](std::optional str, + const auto substringWithLength = [&](const std::optional& str, std::optional start, std::optional length) { return evaluateOnce( @@ -819,12 +819,12 @@ TEST_F(StringTest, translateNonconstantMatch) { } TEST_F(StringTest, trim) { - const auto trim = [&](std::optional srcStr) { + const auto trim = [&](const std::optional& srcStr) { return evaluateOnce("trim(c0)", srcStr); }; - const auto trimWithTrimStr = [&](std::optional trimStr, - std::optional srcStr) { + const auto trimWithTrimStr = [&](const std::optional& trimStr, + const std::optional& srcStr) { return evaluateOnce("trim(c0, c1)", trimStr, srcStr); };