[CP] fix the memleak of nested Array
This commit is contained in:
26
deps/oblib/unittest/lib/utility/test_utility.cpp
vendored
26
deps/oblib/unittest/lib/utility/test_utility.cpp
vendored
@ -18,6 +18,32 @@
|
||||
using namespace oceanbase::common;
|
||||
using namespace std;
|
||||
|
||||
struct TestItem
|
||||
{
|
||||
TestItem() : status_(0), disable_assign_(false)
|
||||
{}
|
||||
~TestItem()
|
||||
{
|
||||
status_ = 1;
|
||||
}
|
||||
int assign(const TestItem &other)
|
||||
{
|
||||
return other.disable_assign_ ? OB_ERROR : OB_SUCCESS;
|
||||
}
|
||||
int status_;
|
||||
bool disable_assign_;
|
||||
};
|
||||
|
||||
TEST(utility, construct_assign)
|
||||
{
|
||||
TestItem item_1, item_2;
|
||||
item_1.disable_assign_ = true;
|
||||
TestItem *item = (TestItem *)ob_malloc(sizeof(TestItem), "TEST");
|
||||
construct_assign(*item, item_1);
|
||||
ASSERT_EQ(1, item->status_);
|
||||
construct_assign(*item, item_2);
|
||||
ASSERT_EQ(0, item->status_);
|
||||
}
|
||||
|
||||
TEST(utility, load_file_to_string)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user