int main(int argc, char **args)
{
	ObjectPool<int> pool;
	
	int &a = pool.acquireObject();
	pool.releaseObject(a);
	
	return 0;
}
void ObjectPoolTest::testRelease()
{
	ObjectPool<Serial> myPool;
	const size_t numberOfObjectsToRetrieve = 10;

	std::vector<ObjectPool<Serial>::Object> retrievedSerials;
	for (size_t i = 0; i < numberOfObjectsToRetrieve; i++) {
		// Add the retrieved Serial to the vector to keep it 'alive'.
		retrievedSerials.push_back(myPool.acquireObject());
	}
	size_t lastSerialNumber = retrievedSerials.back()->getSerialNumber();
	// Release all objects back to the pool.
	retrievedSerials.clear();

	// The above loop has created ten Serial objects, with serial
	// numbers 0-9, and released all ten Serial objects back to the pool.

	// The next loop first again retrieves ten Serial objects. The serial
	// numbers of these should all be <= lastSerialNumber.
	// The Serial object acquired after that should have a new serial number.

	bool wronglyNewObjectCreated = false;
	for (size_t i = 0; i < numberOfObjectsToRetrieve; i++) {
		auto nextSerial = myPool.acquireObject();
		if (nextSerial->getSerialNumber() > lastSerialNumber) {
			wronglyNewObjectCreated = true;
			break;
		}
		retrievedSerials.push_back(nextSerial);
	}

	// Acquire one more Serial object, which should have a serial
	// number > lastSerialNumber.
	auto anotherSerial = myPool.acquireObject();
	bool newObjectCreated = (anotherSerial->getSerialNumber() > lastSerialNumber);

	Assert::IsFalse(wronglyNewObjectCreated);
	Assert::IsTrue(newObjectCreated);
}
void ObjectPoolTest::testExclusivity()
{
	ObjectPool<Serial> myPool;
	const size_t numberOfObjectsToRetrieve = 10;
	std::vector<ObjectPool<Serial>::Object> retrievedSerials;
	std::set<size_t> seenSerialNumbers;

	for (size_t i = 0; i < numberOfObjectsToRetrieve; i++) {
		auto nextSerial = myPool.acquireObject();

		// Add the retrieved Serial to the vector to keep it 'alive',
		// and add the serial number to the set.
		retrievedSerials.push_back(nextSerial);
		seenSerialNumbers.insert(nextSerial->getSerialNumber());
	}

	// Assert that all retrieved serial numbers are different.
	Assert::AreEqual(numberOfObjectsToRetrieve, seenSerialNumbers.size());
}
void ObjectPoolTest::testAcquire()
{
	ObjectPool<Serial> myPool;
	shared_ptr<Serial> serial = myPool.acquireObject();
	CPPUNIT_ASSERT(serial->getSerialNumber() >= 0);
}
void ObjectPoolTest::testAcquire()
{
	ObjectPool<Serial> myPool;
	auto serial = myPool.acquireObject();
	Assert::IsTrue(serial->getSerialNumber() >= 0);
}