patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -16,157 +16,172 @@
using namespace oceanbase::common;
using namespace oceanbase::sql;
class ObExprIsTest : public ::testing::Test {
public:
ObExprIsTest();
virtual ~ObExprIsTest();
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
ObExprIsTest(const ObExprIsTest& other);
ObExprIsTest& operator=(const ObExprIsTest& other);
protected:
// data members
class ObExprIsTest: public ::testing::Test
{
public:
ObExprIsTest();
virtual ~ObExprIsTest();
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
ObExprIsTest(const ObExprIsTest &other);
ObExprIsTest& operator=(const ObExprIsTest &other);
protected:
// data members
};
ObExprIsTest::ObExprIsTest()
{}
{
}
ObExprIsTest::~ObExprIsTest()
{}
{
}
void ObExprIsTest::SetUp()
{}
{
}
void ObExprIsTest::TearDown()
{}
{
}
#define COMPARE_EXPECT_(cmp_op, ctx, func, type1, v1, type2, v2, res) \
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc; \
cmp_op op(alloc); \
t1.set_##type1(v1); \
t2.set_##type2(v2); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) { \
ASSERT_NE(OB_SUCCESS, err); \
} else { \
ASSERT_EQ(OB_SUCCESS, err); \
switch (res) { \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
} \
} \
while (0)
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc;\
cmp_op op(alloc); \
t1.set_##type1(v1); \
t2.set_##type2(v2); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) \
{ \
ASSERT_NE(OB_SUCCESS, err); \
} \
else \
{ \
ASSERT_EQ(OB_SUCCESS, err); \
switch(res) \
{ \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
}\
} while(0)
#define COMPARE_EXPECT_NULL1(cmp_op, ctx, func, type1, type2, v2, res) \
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc; \
cmp_op op(alloc); \
t1.set_##type1(); \
t2.set_##type2(v2); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) { \
ASSERT_NE(OB_SUCCESS, err); \
} else { \
ASSERT_EQ(OB_SUCCESS, err); \
switch (res) { \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
} \
} \
while (0)
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc;\
cmp_op op(alloc); \
t1.set_##type1(); \
t2.set_##type2(v2); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) \
{ \
ASSERT_NE(OB_SUCCESS, err); \
} \
else \
{ \
ASSERT_EQ(OB_SUCCESS, err); \
switch(res) \
{ \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
}\
} while(0)
#define COMPARE_EXPECT_NULL2(cmp_op, ctx, func, type1, v1, type2, res) \
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc; \
cmp_op op(alloc); \
t1.set_##type1(v1); \
t2.set_##type2(); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) { \
ASSERT_NE(OB_SUCCESS, err); \
} else { \
ASSERT_EQ(OB_SUCCESS, err); \
switch (res) { \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
} \
} \
while (0)
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc;\
cmp_op op(alloc); \
t1.set_##type1(v1); \
t2.set_##type2(); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) \
{ \
ASSERT_NE(OB_SUCCESS, err); \
} \
else \
{ \
ASSERT_EQ(OB_SUCCESS, err); \
switch(res) \
{ \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
}\
} while(0)
#define COMPARE_EXPECT_NULL1_NULL2(cmp_op, ctx, func, type1, type2, res) \
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc; \
cmp_op op(alloc); \
t1.set_##type1(); \
t2.set_##type2(); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) { \
ASSERT_NE(OB_SUCCESS, err); \
} else { \
ASSERT_EQ(OB_SUCCESS, err); \
switch (res) { \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
} \
} \
while (0)
{ \
ObObj t1; \
ObObj t2; \
ObObj t3; \
t3.set_bool(false); \
ObObj vres; \
ObArenaAllocator alloc;\
cmp_op op(alloc); \
t1.set_##type1(); \
t2.set_##type2(); \
int err = op.func(vres, t1, t2, t3, ctx); \
if (res == MY_ERROR) \
{ \
ASSERT_NE(OB_SUCCESS, err); \
} \
else \
{ \
ASSERT_EQ(OB_SUCCESS, err); \
switch(res) \
{ \
case MY_TRUE: \
ASSERT_TRUE(vres.is_true()); \
break; \
case MY_FALSE: \
ASSERT_TRUE(vres.is_false()); \
break; \
default: \
ASSERT_TRUE(vres.is_null()); \
break; \
} \
}\
} while(0)
#define T(t1, v1, t2, v2, res) COMPARE_EXPECT_(ObExprIs, ctx, calc_result3, t1, v1, t2, v2, res)
#define T_NULL1(t1, t2, v2, res) COMPARE_EXPECT_NULL1(ObExprIs, ctx, calc_result3, t1, t2, v2, res)
@ -191,9 +206,9 @@ TEST_F(ObExprIsTest, basic_test)
T_NULL2(int, 0, null, MY_FALSE);
T_NULL2(float, 0.0, null, MY_FALSE);
T_NULL2(double, 0.0, null, MY_FALSE);
// T(precise_datetime, 0, null, 0, MY_TRUE);
// T(ctime, 0, null, 0, MY_TRUE);
// T(mtime, 0, null, 0, MY_TRUE);
//T(precise_datetime, 0, null, 0, MY_TRUE);
//T(ctime, 0, null, 0, MY_TRUE);
//T(mtime, 0, null, 0, MY_TRUE);
T(varchar, "20080115", bool, true, MY_TRUE);
T(varchar, "a", bool, true, MY_FALSE);
@ -201,8 +216,9 @@ TEST_F(ObExprIsTest, basic_test)
T(int, 1, bool, true, MY_TRUE);
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
::testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}