Skip to content

Commit

Permalink
Localization: fix bug for memory allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
tthhee authored and jinghaomiao committed Aug 5, 2019
1 parent 102df41 commit 5fa358f
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ TEST_F(PyramidMapMatrixHandlerTestSuite, LossyMapFullAltMatrixHandler) {
expect_size += pm_matrix->GetRowsSafe() * pm_matrix->GetColsSafe() *
(sizeof(unsigned char) + sizeof(unsigned char) +
sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint16_t));
unsigned char* buf = new unsigned char[expect_size];
std::shared_ptr<unsigned char> buf(new unsigned char[expect_size]);
EXPECT_EQ(handler->GetBinarySize(pm_matrix), expect_size);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf, expect_size - 1), 0);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf, expect_size), expect_size);
EXPECT_EQ(handler->LoadBinary(buf, pm_matrix), expect_size);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf.get(), expect_size - 1), 0);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf.get(), expect_size),
expect_size);
EXPECT_EQ(handler->LoadBinary(buf.get(), pm_matrix), expect_size);

// check the matrix after save and load
EXPECT_FLOAT_EQ(*pm_matrix->GetIntensitySafe(0, 1), 255.f);
Expand All @@ -87,9 +88,10 @@ TEST_F(PyramidMapMatrixHandlerTestSuite, LossyMapFullAltMatrixHandler) {
pm_matrix->Init(*config);
expect_size = 56;
EXPECT_EQ(handler->GetBinarySize(pm_matrix), expect_size);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf, expect_size - 1), 0);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf, expect_size), expect_size);
EXPECT_EQ(handler->LoadBinary(buf, pm_matrix), expect_size);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf.get(), expect_size - 1), 0);
EXPECT_EQ(handler->CreateBinary(pm_matrix, buf.get(), expect_size),
expect_size);
EXPECT_EQ(handler->LoadBinary(buf.get(), pm_matrix), expect_size);

if (handler != nullptr) {
delete handler;
Expand Down

0 comments on commit 5fa358f

Please sign in to comment.