/** * Copyright (c) 2021 OceanBase * OceanBase CE is licensed under Mulan PubL v2. * You can use this software according to the terms and conditions of the Mulan PubL v2. * You may obtain a copy of Mulan PubL v2 at: * http://license.coscl.org.cn/MulanPubL-2.0 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PubL v2 for more details. */ #include #include #include "share/ob_define.h" #include "common/object/ob_obj_type.h" #include "common/expression/ob_expr_obj.h" #include #include "sql/engine/expr/ob_expr_nvl.h" using namespace oceanbase::common; using namespace oceanbase::sql; class ObExprNvlTest: public ::testing::Test { public: ObExprNvlTest(); virtual ~ObExprNvlTest(); virtual void SetUp(); virtual void TearDown(); private: // disallow copy ObExprNvlTest(const ObExprNvlTest &other); ObExprNvlTest& operator=(const ObExprNvlTest &other); protected: // data members }; ObExprNvlTest::ObExprNvlTest() { } ObExprNvlTest::~ObExprNvlTest() { } void ObExprNvlTest::SetUp() { } void ObExprNvlTest::TearDown() { } #define EV 0.00001 #define NVL_EXPECT(funop, str_buf, func, type1, v1, type2, v2, restype, res) \ { \ ObObj t1; \ ObObj t2; \ ObObj vres; \ funop op; \ op.set_result_type(restype); \ t1.set_##type1(v1); \ t2.set_##type2(v2); \ int err = op.func(vres, t1, t2, str_buf); \ if (OB_SUCCESS != err) \ { \ ASSERT_EQ(res, err); \ } \ else \ { \ switch(vres.get_type()) \ { \ case ObIntType: \ ASSERT_EQ(res, vres.get_int()); \ break; \ case ObFloatType: \ ASSERT_TRUE(fabsf(res-vres.get_float()