Skip to content

Commit

Permalink
add more test
Browse files Browse the repository at this point in the history
Signed-off-by: YangKeao <yangkeao@chunibyo.icu>
  • Loading branch information
YangKeao committed Jul 5, 2022
1 parent 0ca9582 commit a3f71cc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
42 changes: 36 additions & 6 deletions dbms/src/Functions/tests/gtest_strings_hexint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,52 @@ try
const String & func_name = "hexInt";

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({std::nullopt, "3039", "FFFFFFFFFFFFFFFF"}),
createColumn<Nullable<String>>({"1348B21", std::nullopt, "0", "FFFFFFFFFECB74DF", "8000000000000000", "7FFFFFFFFFFFFFFF"}),
executeFunction(
func_name,
createColumn<Nullable<UInt64>>({std::nullopt, 12345, 0xFFFFFFFFFFFFFFFF})));
createColumn<Nullable<Int64>>({20220705, std::nullopt, 0, -20220705, std::numeric_limits<Int64>::min(), std::numeric_limits<Int64>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"3039", "FFFFFFFFFFFFCFC7"}),
createColumn<Nullable<String>>({"1348B21", std::nullopt, "0", "0", "FFFFFFFFFFFFFFFF"}),
executeFunction(
func_name,
createColumn<Nullable<Int64>>({12345, -12345})));
createColumn<Nullable<UInt64>>({20220705, std::nullopt, 0, std::numeric_limits<UInt64>::min(), std::numeric_limits<UInt64>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"FF", "1"}),
createColumn<Nullable<String>>({"13414DA", std::nullopt, "0", "FFFFFFFFFECBEB26", "FFFFFFFF80000000", "7FFFFFFF"}),
executeFunction(
func_name,
createColumn<Nullable<UInt8>>({255, 1})));
createColumn<Nullable<Int32>>({20190426, std::nullopt, 0, -20190426, std::numeric_limits<Int32>::min(), std::numeric_limits<Int32>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"13414DA", std::nullopt, "0", "0", "FFFFFFFF"}),
executeFunction(
func_name,
createColumn<Nullable<UInt32>>({20190426, std::nullopt, 0, std::numeric_limits<UInt32>::min(), std::numeric_limits<UInt32>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"3039", std::nullopt, "0", "FFFFFFFFFFFFCFC7", "FFFFFFFFFFFF8000", "7FFF"}),
executeFunction(
func_name,
createColumn<Nullable<Int16>>({12345, std::nullopt, 0, -12345, std::numeric_limits<Int16>::min(), std::numeric_limits<Int16>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"3039", std::nullopt, "0", "0", "FFFF"}),
executeFunction(
func_name,
createColumn<Nullable<UInt16>>({12345, std::nullopt, 0, std::numeric_limits<UInt16>::min(), std::numeric_limits<UInt16>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"78", std::nullopt, "0", "FFFFFFFFFFFFFF88", "FFFFFFFFFFFFFF80", "7F"}),
executeFunction(
func_name,
createColumn<Nullable<Int8>>({120, std::nullopt, 0, -120, std::numeric_limits<Int8>::min(), std::numeric_limits<Int8>::max()})));

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"8F", std::nullopt, "0", "0", "FF"}),
executeFunction(
func_name,
createColumn<Nullable<UInt8>>({143, std::nullopt, 0, std::numeric_limits<UInt8>::min(), std::numeric_limits<UInt8>::max()})));
}
CATCH
} // namespace tests
Expand Down
18 changes: 16 additions & 2 deletions dbms/src/Functions/tests/gtest_strings_hexstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,24 @@ try
const String & func_name = "hexStr";

ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"7777772E70696E676361702E636F6D", "61626364", "E6B58BE8AF95E6B58BE8AF95E6B58BE8AF95E6B58BE8AF9561626364E6B58BE8AF95", std::nullopt}),
createColumn<Nullable<String>>({"7777772E70696E676361702E636F6D", "61626364", std::nullopt, ""}),
executeFunction(
func_name,
createColumn<Nullable<String>>({"www.pingcap.com", "abcd", "测试测试测试测试abcd测试", std::nullopt})));
createColumn<Nullable<String>>({"www.pingcap.com", "abcd", std::nullopt, ""})));

// CJK and emoji
ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"E38195E38289E381ABE585A5", "E6B58BE8AF95E6B58BE8AF95E6B58BE8AF95E6B58BE8AF9561626364E6B58BE8AF95", "F09F8DBB", "F09F8FB4E2808DE298A0EFB88F"}),
executeFunction(
func_name,
createColumn<Nullable<String>>({"さらに入", "测试测试测试测试abcd测试", "🍻", "🏴‍☠️"})));

// Special Empty Character
ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"09", "0A", "20"}),
executeFunction(
func_name,
createColumn<Nullable<String>>({"\t", "\n", " "})));
}
CATCH
} // namespace tests
Expand Down
20 changes: 0 additions & 20 deletions tests/fullstack-test/expr/hex_str.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
+----------------------------------------------------------------------+

0 comments on commit a3f71cc

Please sign in to comment.