diff --git a/dbms/src/Functions/tests/gtest_strings_hexint.cpp b/dbms/src/Functions/tests/gtest_strings_hexint.cpp index 02bdb4f4e71..b0539d93616 100644 --- a/dbms/src/Functions/tests/gtest_strings_hexint.cpp +++ b/dbms/src/Functions/tests/gtest_strings_hexint.cpp @@ -34,22 +34,52 @@ try const String & func_name = "hexInt"; ASSERT_COLUMN_EQ( - createColumn>({std::nullopt, "3039", "FFFFFFFFFFFFFFFF"}), + createColumn>({"1348B21", std::nullopt, "0", "FFFFFFFFFECB74DF", "8000000000000000", "7FFFFFFFFFFFFFFF"}), executeFunction( func_name, - createColumn>({std::nullopt, 12345, 0xFFFFFFFFFFFFFFFF}))); + createColumn>({20220705, std::nullopt, 0, -20220705, std::numeric_limits::min(), std::numeric_limits::max()}))); ASSERT_COLUMN_EQ( - createColumn>({"3039", "FFFFFFFFFFFFCFC7"}), + createColumn>({"1348B21", std::nullopt, "0", "0", "FFFFFFFFFFFFFFFF"}), executeFunction( func_name, - createColumn>({12345, -12345}))); + createColumn>({20220705, std::nullopt, 0, std::numeric_limits::min(), std::numeric_limits::max()}))); ASSERT_COLUMN_EQ( - createColumn>({"FF", "1"}), + createColumn>({"13414DA", std::nullopt, "0", "FFFFFFFFFECBEB26", "FFFFFFFF80000000", "7FFFFFFF"}), executeFunction( func_name, - createColumn>({255, 1}))); + createColumn>({20190426, std::nullopt, 0, -20190426, std::numeric_limits::min(), std::numeric_limits::max()}))); + + ASSERT_COLUMN_EQ( + createColumn>({"13414DA", std::nullopt, "0", "0", "FFFFFFFF"}), + executeFunction( + func_name, + createColumn>({20190426, std::nullopt, 0, std::numeric_limits::min(), std::numeric_limits::max()}))); + + ASSERT_COLUMN_EQ( + createColumn>({"3039", std::nullopt, "0", "FFFFFFFFFFFFCFC7", "FFFFFFFFFFFF8000", "7FFF"}), + executeFunction( + func_name, + createColumn>({12345, std::nullopt, 0, -12345, std::numeric_limits::min(), std::numeric_limits::max()}))); + + ASSERT_COLUMN_EQ( + createColumn>({"3039", std::nullopt, "0", "0", "FFFF"}), + executeFunction( + func_name, + createColumn>({12345, std::nullopt, 0, std::numeric_limits::min(), std::numeric_limits::max()}))); + + ASSERT_COLUMN_EQ( + createColumn>({"78", std::nullopt, "0", "FFFFFFFFFFFFFF88", "FFFFFFFFFFFFFF80", "7F"}), + executeFunction( + func_name, + createColumn>({120, std::nullopt, 0, -120, std::numeric_limits::min(), std::numeric_limits::max()}))); + + ASSERT_COLUMN_EQ( + createColumn>({"8F", std::nullopt, "0", "0", "FF"}), + executeFunction( + func_name, + createColumn>({143, std::nullopt, 0, std::numeric_limits::min(), std::numeric_limits::max()}))); } CATCH } // namespace tests diff --git a/dbms/src/Functions/tests/gtest_strings_hexstr.cpp b/dbms/src/Functions/tests/gtest_strings_hexstr.cpp index 0f4733ae821..6d03ec05ef5 100644 --- a/dbms/src/Functions/tests/gtest_strings_hexstr.cpp +++ b/dbms/src/Functions/tests/gtest_strings_hexstr.cpp @@ -34,10 +34,24 @@ try const String & func_name = "hexStr"; ASSERT_COLUMN_EQ( - createColumn>({"7777772E70696E676361702E636F6D", "61626364", "E6B58BE8AF95E6B58BE8AF95E6B58BE8AF95E6B58BE8AF9561626364E6B58BE8AF95", std::nullopt}), + createColumn>({"7777772E70696E676361702E636F6D", "61626364", std::nullopt, ""}), executeFunction( func_name, - createColumn>({"www.pingcap.com", "abcd", "测试测试测试测试abcd测试", std::nullopt}))); + createColumn>({"www.pingcap.com", "abcd", std::nullopt, ""}))); + + // CJK and emoji + ASSERT_COLUMN_EQ( + createColumn>({"E38195E38289E381ABE585A5", "E6B58BE8AF95E6B58BE8AF95E6B58BE8AF95E6B58BE8AF9561626364E6B58BE8AF95", "F09F8DBB", "F09F8FB4E2808DE298A0EFB88F"}), + executeFunction( + func_name, + createColumn>({"さらに入", "测试测试测试测试abcd测试", "🍻", "🏴‍☠️"}))); + + // Special Empty Character + ASSERT_COLUMN_EQ( + createColumn>({"09", "0A", "20"}), + executeFunction( + func_name, + createColumn>({"\t", "\n", " "}))); } CATCH } // namespace tests diff --git a/tests/fullstack-test/expr/hex_str.test b/tests/fullstack-test/expr/hex_str.test index c7f94c68780..bf828169f40 100644 --- a/tests/fullstack-test/expr/hex_str.test +++ b/tests/fullstack-test/expr/hex_str.test @@ -31,23 +31,3 @@ mysql> set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash'; select | e6b58be8af95e6b58be8af95e6b58be8af95e6b58be8af9561626364e6b58be8af95 | | NULL | +----------------------------------------------------------------------+ - -mysql> drop table if exists test.t; -mysql> create table if not exists test.t(a varchar(100)); - -mysql> insert into test.t values('www.pingcap.com'); -mysql> insert into test.t values('abcd'); -mysql> insert into test.t values('测试测试测试测试abcd测试'); -mysql> insert into test.t values(NULL); -mysql> alter table test.t set tiflash replica 1; -func> wait_table test t - -mysql> set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash'; select hex(a) from test.t; -+----------------------------------------------------------------------+ -| hex(a) | -+----------------------------------------------------------------------+ -| 7777772e70696e676361702e636f6d | -| 61626364 | -| e6b58be8af95e6b58be8af95e6b58be8af95e6b58be8af9561626364e6b58be8af95 | -| NULL | -+----------------------------------------------------------------------+