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

@ -12,16 +12,19 @@
#include <gtest/gtest.h>
#include "lib/random/ob_mysql_random.h"
#include "lib/oblog/ob_log.h"
namespace oceanbase {
namespace common {
namespace oceanbase
{
namespace common
{
class TestMysqlRandom : public ::testing::Test {
class TestMysqlRandom : public ::testing::Test
{
public:
virtual void SetUp()
{}
virtual void TearDown()
{}
virtual void SetUp() {}
virtual void TearDown() {}
};
TEST_F(TestMysqlRandom, main_test)
@ -29,7 +32,7 @@ TEST_F(TestMysqlRandom, main_test)
double res_double = 0;
uint64_t res_uint = 0;
char res_buf[21];
// test static methods
//test static methods
ObMysqlRandom random;
ASSERT_TRUE(false == random.is_inited());
@ -67,10 +70,10 @@ TEST_F(TestMysqlRandom, main_test)
}
}
} // namespace common
} // namespace oceanbase
}
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
OB_LOGGER.set_log_level("INFO");
testing::InitGoogleTest(&argc, argv);

View File

@ -13,13 +13,15 @@
#include <gtest/gtest.h>
#include "lib/random/ob_random.h"
namespace oceanbase {
namespace common {
namespace oceanbase
{
namespace common
{
TEST(ObRandom, normal)
{
int64_t res = 0;
// test static methods
//test static methods
res = ObRandom::rand(10, 10);
ASSERT_EQ(10, res);
res = ObRandom::rand(0, 100);
@ -29,7 +31,7 @@ TEST(ObRandom, normal)
res = ObRandom::rand(10, 1);
ASSERT_TRUE(res >= 1 && res <= 10);
// test int64_t random number
//test int64_t random number
ObRandom rand1;
res = rand1.get();
res = rand1.get(10, 10);
@ -41,23 +43,18 @@ TEST(ObRandom, normal)
res = rand1.get(10, 1);
ASSERT_TRUE(res >= 1 && res <= 10);
// test int32_t random number
//test int32_t random number
res = rand1.get_int32();
res = rand1.get_int32(10, 10);
ASSERT_EQ(10, res);
res = rand1.get_int32(0, 100);
ASSERT_TRUE(res <= 100 && res >= 0);
res = rand1.get_int32(-1, -2);
ASSERT_TRUE(res >= -2 && res <= -1);
res = rand1.get_int32(10, 1);
ASSERT_TRUE(res >= 1 && res <= 10);
}
} // namespace common
} // namespace oceanbase
}
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}