Skip to content

Commit

Permalink
Modifying test to show allocation in pool and deallocation after dest…
Browse files Browse the repository at this point in the history
…ruction of pool.

PROBLEM: Preallocate currently fails due to using maximum integer value as default allocation size.
  • Loading branch information
Gabriel Hare authored and codemercenary committed Aug 1, 2014
1 parent d4c0c72 commit c661951
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/autowiring/test/ObjectPoolTest.cpp
Expand Up @@ -73,36 +73,50 @@ class LifeCycle {
};

TEST_F(ObjectPoolTest, LifeCycleTestLimitOne) {
std::shared_ptr<ObjectPool<LifeCycle>> pool(LifeCycle::NewObjectPool(~1, ~1));
std::shared_ptr<LifeCycle> obj;
std::shared_ptr<ObjectPool<LifeCycle>> pool(LifeCycle::NewObjectPool(2, 2));
std::shared_ptr<LifeCycle> objHold, objDrop;

// Create & Issue
// Create in Pool
try {
(*pool)(obj);
pool->Preallocate(1);
} catch (std::runtime_error e) {
FAIL() << e.what();
}

// Return to Pool
// Issue from Pool
try {
obj.reset();
(*pool)(objHold);
} catch (std::runtime_error e) {
FAIL() << e.what();
}

// Issue from Pool
// Issue from Pool with implicit Creation of objDrop
try {
(*pool)(objDrop);
} catch (std::runtime_error e) {
FAIL() << e.what();
}

// Return to Pool
try {
(*pool)(obj);
objDrop.reset();
} catch (std::runtime_error e) {
FAIL() << e.what();
}

// Return & Destroy
// Destroy Pool with implicit Destruction of objDrop
try {
pool.reset();
} catch (std::runtime_error e) {
FAIL() << e.what();
}

// Return to Pool redirected to Destruction of objHold
try {
objHold.reset();
} catch (std::runtime_error e) {
FAIL() << e.what();
}
}

TEST_F(ObjectPoolTest, VerifyAsynchronousUsage) {
Expand Down

0 comments on commit c661951

Please sign in to comment.