aboutsummaryrefslogtreecommitdiff
path: root/src/test/allocator_tests.cpp
diff options
context:
space:
mode:
authorKaz Wesley <keziahw@gmail.com>2016-11-02 14:03:50 -0700
committerKaz Wesley <keziahw@gmail.com>2016-11-02 14:05:07 -0700
commit21b8f3db31f05f7756c4291e460544ce0457fd87 (patch)
treecad5ae454a73cd7248d4bf9bdffabc0ed3df18dc /src/test/allocator_tests.cpp
parenta4fd8dff68369de497354574624b740f42175b1b (diff)
LockedPool: test handling of invalid allocations
(Currently fails due to bug)
Diffstat (limited to 'src/test/allocator_tests.cpp')
-rw-r--r--src/test/allocator_tests.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp
index f0e848655f..a853aececb 100644
--- a/src/test/allocator_tests.cpp
+++ b/src/test/allocator_tests.cpp
@@ -166,6 +166,16 @@ BOOST_AUTO_TEST_CASE(lockedpool_tests_mock)
BOOST_CHECK(pool.stats().total == 0);
BOOST_CHECK(pool.stats().locked == 0);
+ // Ensure unreasonable requests are refused without allocating anything
+ void *invalid_toosmall = pool.alloc(0);
+ BOOST_CHECK(invalid_toosmall == nullptr);
+ BOOST_CHECK(pool.stats().used == 0);
+ BOOST_CHECK(pool.stats().free == 0);
+ void *invalid_toobig = pool.alloc(LockedPool::ARENA_SIZE+1);
+ BOOST_CHECK(invalid_toobig == nullptr);
+ BOOST_CHECK(pool.stats().used == 0);
+ BOOST_CHECK(pool.stats().free == 0);
+
void *a0 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a0);
BOOST_CHECK(pool.stats().locked == LockedPool::ARENA_SIZE);