Skip to content

Commit a6c9719

Browse files
committed
Add test for umfPoolMallocUsableSize
1 parent d69a241 commit a6c9719

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/poolFixtures.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,18 @@ TEST_P(umfPoolTest, realloc_compliance) {
451451

452452
TEST_P(umfPoolTest, free_compliance) { free_compliance_test(pool.get()); }
453453

454+
TEST_P(umfPoolTest, mallocUsableSize) {
455+
for (size_t allocSize : {32, 48, 1024, 8192}) {
456+
char *ptr = static_cast<char *>(umfPoolMalloc(pool.get(), allocSize));
457+
size_t result = umfPoolMallocUsableSize(pool.get(), ptr);
458+
EXPECT_TRUE(result == 0 or result >= allocSize);
459+
460+
for (size_t i = 0; i < result; i++) {
461+
ptr[i] = 123;
462+
}
463+
464+
umfPoolFree(pool.get(), ptr);
465+
}
466+
}
467+
454468
#endif /* UMF_TEST_POOL_FIXTURES_HPP */

0 commit comments

Comments
 (0)