From b5d3f907b61d838325e4ee8a2c80d36fea438537 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 11 Dec 2014 02:02:39 +0100 Subject: added assertion to Buffer class which makes sure that all cursors are marked as free (just to be sure), adapted Buffer unit tests accordingly --- src/core/utils/CharReader.cpp | 11 +++++++++++ src/core/utils/CharReader.hpp | 8 ++++++++ 2 files changed, 19 insertions(+) (limited to 'src/core/utils') diff --git a/src/core/utils/CharReader.cpp b/src/core/utils/CharReader.cpp index c661b6f..61616d7 100644 --- a/src/core/utils/CharReader.cpp +++ b/src/core/utils/CharReader.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include @@ -80,6 +81,16 @@ Buffer::Buffer(const std::string &str) startBucket = buckets.begin(); } +#ifndef NDEBUG +Buffer::~Buffer() +{ + // Make sure all cursors have been deleted + for (bool cursor_alive: alive) { + assert(!cursor_alive); + } +} +#endif + void Buffer::advance(BucketIterator &it) { it++; diff --git a/src/core/utils/CharReader.hpp b/src/core/utils/CharReader.hpp index 86f09db..1306026 100644 --- a/src/core/utils/CharReader.hpp +++ b/src/core/utils/CharReader.hpp @@ -242,6 +242,14 @@ public: */ Buffer(const std::string &str); +#ifndef NDEBUG + /** + * Destructor of the Buffer class. Makes sure that all cursors have been + * freed. + */ + ~Buffer(); +#endif + // No copy Buffer(const Buffer &) = delete; -- cgit v1.2.3