[poincare] Log pool on failure

This commit is contained in:
Romain Goyet
2018-08-10 14:38:47 +02:00
parent fe0985dda8
commit c514b3dd3a
2 changed files with 20 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ void TreePool::flatLog(std::ostream & stream) {
node->log(stream, false);
}
stream << "</TreePool>";
stream << std::endl;
}
void TreePool::treeLog(std::ostream & stream) {
@@ -110,6 +111,7 @@ void TreePool::treeLog(std::ostream & stream) {
node->log(stream, true);
}
stream << "</TreePool>";
stream << std::endl;
}
#endif

View File

@@ -5,14 +5,32 @@
#include "blob_node.h"
#include "pair_node.h"
#if POINCARE_TREE_LOG
#include <iostream>
#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) {