mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-27 11:06:53 +01:00
Fix #399 MemoryPoolAllocator::Realloc expands fail
This commit is contained in:
@@ -81,3 +81,22 @@ TEST(Allocator, Alignment) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Allocator, Issue399) {
|
||||
MemoryPoolAllocator<> a;
|
||||
void* p = a.Malloc(100);
|
||||
void* q = a.Realloc(p, 100, 200);
|
||||
EXPECT_EQ(p, q);
|
||||
|
||||
// exhuasive testing
|
||||
for (size_t j = 1; j < 32; j++) {
|
||||
a.Clear();
|
||||
a.Malloc(j); // some unaligned size
|
||||
p = a.Malloc(1);
|
||||
for (size_t i = 1; i < 1024; i++) {
|
||||
q = a.Realloc(p, i, i + 1);
|
||||
EXPECT_EQ(p, q);
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user