summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/alloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-11-14 08:58:34 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2017-01-03 11:01:56 +0100
commit47b97f5bd9211cd95016d476b6f2d65f2a12d8d9 (patch)
tree5bb6365ecfa587f96c6ce2e81c917474c14470d4 /vespalib/src/tests/alloc
parentad711a467185a694ef5059add8f560e1da9d6461 (diff)
Verify that heap allocated buffers are not extendable.
Diffstat (limited to 'vespalib/src/tests/alloc')
-rw-r--r--vespalib/src/tests/alloc/alloc_test.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp
index e217abfbd16..ad5729ea11b 100644
--- a/vespalib/src/tests/alloc/alloc_test.cpp
+++ b/vespalib/src/tests/alloc/alloc_test.cpp
@@ -102,4 +102,14 @@ TEST("rounding of large mmaped buffer") {
EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12, buf.size());
}
+TEST("heap alloc can not be extended") {
+ Alloc buf = Alloc::allocHeap(100);
+ void * oldPtr = buf.get();
+ size_t oldSz = buf.size();
+ EXPECT_FALSE(buf.extend_inplace(101));
+ EXPECT_EQUAL(oldPtr, buf.get());
+ EXPECT_EQUAL(oldSz, buf.size());
+}
+
+
TEST_MAIN() { TEST_RUN_ALL(); }