Skip to content

Commit c1ba4b0

Browse files
committed
Add test for umfPoolMallocUsableSize
1 parent 64456b7 commit c1ba4b0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/poolFixtures.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,22 @@ TEST_P(umfPoolTest, allocMaxSize) {
456456
ASSERT_EQ(ptr, nullptr);
457457
}
458458

459+
// Sanitizer replaces malloc_usable_size implementation with it's own,
460+
// what results in a failure.
461+
#ifndef __SANITIZE_ADDRESS__
462+
TEST_P(umfPoolTest, mallocUsableSize) {
463+
for (size_t allocSize : {32, 48, 1024, 8192}) {
464+
char *ptr = static_cast<char *>(umfPoolMalloc(pool.get(), allocSize));
465+
size_t result = umfPoolMallocUsableSize(pool.get(), ptr);
466+
EXPECT_TRUE(result == 0 or result >= allocSize);
467+
468+
for (size_t i = 0; i < result; i++) {
469+
ptr[i] = 123;
470+
}
471+
472+
umfPoolFree(pool.get(), ptr);
473+
}
474+
}
475+
#endif
476+
459477
#endif /* UMF_TEST_POOL_FIXTURES_HPP */

0 commit comments

Comments
 (0)