From c514b3dd3af083df0fe802409f644b390b24bdd9 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 10 Aug 2018 14:38:47 +0200 Subject: [PATCH] [poincare] Log pool on failure --- poincare/src/tree_pool.cpp | 2 ++ poincare/test/tree/tree_by_value.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/poincare/src/tree_pool.cpp b/poincare/src/tree_pool.cpp index 038e8a178..33979f31c 100644 --- a/poincare/src/tree_pool.cpp +++ b/poincare/src/tree_pool.cpp @@ -102,6 +102,7 @@ void TreePool::flatLog(std::ostream & stream) { node->log(stream, false); } stream << ""; + stream << std::endl; } void TreePool::treeLog(std::ostream & stream) { @@ -110,6 +111,7 @@ void TreePool::treeLog(std::ostream & stream) { node->log(stream, true); } stream << ""; + stream << std::endl; } #endif diff --git a/poincare/test/tree/tree_by_value.cpp b/poincare/test/tree/tree_by_value.cpp index 6d206065c..bc17fe7fd 100644 --- a/poincare/test/tree/tree_by_value.cpp +++ b/poincare/test/tree/tree_by_value.cpp @@ -5,14 +5,32 @@ #include "blob_node.h" #include "pair_node.h" +#if POINCARE_TREE_LOG +#include +#endif + using namespace Poincare; static inline int pool_size() { return TreePool::sharedPool()->numberOfNodes(); } +#if POINCARE_TREE_LOG +static inline void log_pool() { + TreePool::sharedPool()->flatLog(std::cout); +} +#endif static void assert_pool_size(int i) { +#if POINCARE_TREE_LOG + int poolSize = pool_size(); + if (poolSize != i) { + std::cout << "Expected pool of size " << i << " but got " << poolSize << std::endl; + log_pool(); + assert(false); + } +#else assert(pool_size() == i); +#endif } QUIZ_CASE(tree_by_values_are_stored_in_pool) {