Permalink
Browse files

Add std::list test to ut-allocator (#25)

  • Loading branch information...
1 parent 34d8005 commit 6b088432522d934081963e4fc1cde02c214fd921 @Mortal Mortal committed Aug 2, 2012
Showing with 8 additions and 5 deletions.
  1. +1 −1 test/unit/CMakeLists.txt
  2. +7 −4 test/unit/test_allocator.cpp
View
@@ -17,7 +17,7 @@ macro(add_fulltest NAME)
endforeach(TEST)
endmacro(add_fulltest)
-add_unittest(allocator deque)
+add_unittest(allocator deque list)
add_unittest(ami_stream basic truncate)
add_unittest(array basic iterators auto_ptr memory segmented memory_segmented bit_basic bit_iterators bit_memory copyempty arrayarray frontback)
add_unittest(disjoint_set basic memory)
@@ -18,18 +18,20 @@
// along with TPIE. If not, see <http://www.gnu.org/licenses/>
#include "../app_config.h"
#include "common.h"
+#include <list>
#include <queue>
#include <tpie/memory.h>
using namespace tpie;
-bool allocator_deque_test() {
+template <template <typename T, typename Allocator> class Container>
+bool allocator_test() {
memory_size_type m1, m2, m3;
m1 = get_memory_manager().used();
typedef int test_t;
const test_t N = 100;
{
- std::deque<test_t, allocator<test_t> > d;
+ Container<test_t, allocator<test_t> > d;
for (test_t i = 0; i < N; ++i) {
d.push_back(i);
}
@@ -39,12 +41,13 @@ bool allocator_deque_test() {
if (m1 != m3) {
log_error() << "Memory leak" << std::endl;
}
- log_info() << "Pushing " << N << " numbers of size " << sizeof(test_t) << " uses " << m2-m1 << std::endl;
+ log_info() << "Pushing " << N << " numbers of size " << sizeof(test_t) << " to a " << typeid(Container<test_t, allocator<test_t> >).name() << " uses " << m2-m1 << std::endl;
return m1 != m2;
}
int main(int argc, char ** argv) {
return tests(argc, argv)
- .test(allocator_deque_test, "deque")
+ .test(allocator_test<std::deque>, "deque")
+ .test(allocator_test<std::list>, "list")
;
}

0 comments on commit 6b08843

Please sign in to comment.