// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include #include #include #include #include namespace DB { namespace tests { class HexIntTest : public DB::tests::FunctionTest { }; TEST_F(HexIntTest, hexint_all_unit_Test) try { const String & func_name = "hexInt"; ASSERT_COLUMN_EQ( createColumn>( {"1348B21", std::nullopt, "0", "FFFFFFFFFECB74DF", "8000000000000000", "7FFFFFFFFFFFFFFF"}), executeFunction( func_name, createColumn>( {20220705, std::nullopt, 0, -20220705, std::numeric_limits::min(), std::numeric_limits::max()}))); ASSERT_COLUMN_EQ( createColumn>({"1348B21", std::nullopt, "0", "0", "FFFFFFFFFFFFFFFF"}), executeFunction( func_name, createColumn>( {20220705, std::nullopt, 0, std::numeric_limits::min(), std::numeric_limits::max()}))); ASSERT_COLUMN_EQ( createColumn>( {"13414DA", std::nullopt, "0", "FFFFFFFFFECBEB26", "FFFFFFFF80000000", "7FFFFFFF"}), executeFunction( func_name, 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 } // namespace DB