From 5867ee86d4b3c47efa3fb40c04d262396d895bec Mon Sep 17 00:00:00 2001
From: Pietro Incardona <i-bird@localhost.localdomain>
Date: Wed, 23 Mar 2016 00:27:54 +0100
Subject: [PATCH] reinforced test

---
 src/memory/BHeapMemory.hpp           | 10 ++++++++++
 src/memory/HeapMemory.cpp            |  3 +--
 src/memory/HeapMemory_unit_tests.hpp | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/memory/BHeapMemory.hpp b/src/memory/BHeapMemory.hpp
index ec087d8..6a02117 100644
--- a/src/memory/BHeapMemory.hpp
+++ b/src/memory/BHeapMemory.hpp
@@ -133,6 +133,16 @@ public:
 	{
 		return HeapMemory::size();
 	}
+
+	/*! \brief Destroy the internal memory
+	 *
+	 *
+	 */
+	void destroy()
+	{
+		HeapMemory::destroy();
+		buf_sz = 0;
+	}
 };
 
 
diff --git a/src/memory/HeapMemory.cpp b/src/memory/HeapMemory.cpp
index 348656a..7d423c8 100644
--- a/src/memory/HeapMemory.cpp
+++ b/src/memory/HeapMemory.cpp
@@ -54,9 +54,8 @@ void HeapMemory::setAlignment(size_t align)
 	this->alignement = align;
 }
 
-/*! \brief destroy a chunk of memory
+/*! \brief Destroy the internal memory
  *
- * Destroy a chunk of memory
  *
  */
 void HeapMemory::destroy()
diff --git a/src/memory/HeapMemory_unit_tests.hpp b/src/memory/HeapMemory_unit_tests.hpp
index 54df299..f1fc1bc 100644
--- a/src/memory/HeapMemory_unit_tests.hpp
+++ b/src/memory/HeapMemory_unit_tests.hpp
@@ -28,6 +28,8 @@ template<typename T> void test()
 	//! [Allocate some memory and fill with data]
 	T mem;
 
+	BOOST_REQUIRE_EQUAL(mem.size(),0ul);
+
 	mem.allocate(FIRST_ALLOCATION);
 
 	BOOST_REQUIRE_EQUAL(mem.size(),FIRST_ALLOCATION);
@@ -107,6 +109,14 @@ template<typename T> void test()
 		BOOST_REQUIRE_EQUAL(ptr2[i],c);
 	}
 
+	mem.destroy();
+
+	BOOST_REQUIRE_EQUAL(mem.size(),0ul);
+
+	mem.allocate(FIRST_ALLOCATION);
+
+	BOOST_REQUIRE_EQUAL(mem.size(),FIRST_ALLOCATION);
+
 	}
 }
 
@@ -150,6 +160,14 @@ template<typename T> void Btest()
 	BOOST_REQUIRE_EQUAL(mem.size(),1ul);
 
 	//! [BShrink memory]
+
+	mem.destroy();
+
+	BOOST_REQUIRE_EQUAL(mem.size(),0ul);
+
+	mem.allocate(FIRST_ALLOCATION);
+
+	BOOST_REQUIRE_EQUAL(mem.size(),FIRST_ALLOCATION);
 }
 
 BOOST_AUTO_TEST_CASE( use_heap_memory )
-- 
GitLab