[poincare] Fix TreeNode logging

This commit is contained in:
Romain Goyet
2018-08-10 14:29:50 +02:00
parent 0d69d87167
commit 4e08f196f8
46 changed files with 282 additions and 110 deletions

View File

@@ -20,8 +20,10 @@ public:
static AbsoluteValueLayoutNode * FailedAllocationStaticNode();
AbsoluteValueLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(AbsoluteValueLayoutNode); }
#if TREE_LOG
const char * description() const override { return "AbsoluteValueLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "AbsoluteValueLayout";
}
#endif
private:

View File

@@ -23,8 +23,10 @@ public:
static AdditionNode * FailedAllocationStaticNode();
AdditionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(AdditionNode); }
#if TREE_LOG
const char * description() const override { return "Addition"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Addition";
}
#endif
// ExpressionNode

View File

@@ -13,11 +13,15 @@ public:
// TreeNode
size_t size() const override { return sizeof(AllocationFailureNode<T>); }
#if TREE_LOG
const char * description() const override { return "AllocationFailure"; }
#endif
int numberOfChildren() const override { return 0; }
bool isAllocationFailure() const override { return true; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "AllocationFailure[";
T::logNodeName(stream);
stream << "]";
}
#endif
};
}

View File

@@ -26,8 +26,10 @@ public:
BinomialCoefficientLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(BinomialCoefficientLayoutNode); }
int numberOfChildren() const override { return 2; }
#if TREE_LOG
const char * description() const override { return "BinomialCoefficientLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "BinomialCoefficientLayout";
}
#endif
protected:

View File

@@ -17,8 +17,10 @@ public:
static CeilingLayoutNode * FailedAllocationStaticNode();
CeilingLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(CeilingLayoutNode); }
#if TREE_LOG
const char * description() const override { return "CeilingLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "CeilingLayout";
}
#endif
protected:

View File

@@ -33,11 +33,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(CharLayoutNode); }
int numberOfChildren() const override { return 0; }
#if TREE_LOG
const char * description() const override {
static char Description[] = "Char a";
Description[5] = m_char;
return Description;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "CharLayout";
}
virtual void logAttributes(std::ostream & stream) const {
stream << " char=\"" << m_char << "\"";
}
#endif

View File

@@ -18,10 +18,16 @@ public:
// TreeNode
size_t size() const override { return sizeof(ComplexNode<T>); }
#if TREE_LOG
const char * description() const override { return "Evaluation complex"; }
#endif
int numberOfChildren() const override { return 0; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Complex";
}
virtual void logAttributes(std::ostream & stream) const {
stream << " real=\"" << this->real() << "\"";
stream << " imag=\"" << this->imag() << "\"";
}
#endif
void setComplex(std::complex<T> c);
typename Poincare::EvaluationNode<T>::Type type() const override { return Poincare::EvaluationNode<T>::Type::Complex; }

View File

@@ -31,9 +31,9 @@ public:
CondensedSumLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(CondensedSumLayoutNode); }
int numberOfChildren() const override { return 3; }
#if TREE_LOG
const char * description() const override {
return "CondensedSumLayout";
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "CondensedSumLayout";
}
#endif

View File

@@ -22,9 +22,9 @@ public:
ConjugateLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(ConjugateLayoutNode); }
int numberOfChildren() const override { return 1; }
#if TREE_LOG
const char * description() const override {
return "ConjugateLayout";
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "ConjugateLayout";
}
#endif

View File

@@ -30,8 +30,15 @@ public:
// TreeNode
size_t size() const override { return sizeof(DecimalNode); }
#if TREE_LOG
const char * description() const override { return "Decimal"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Decimal";
}
virtual void logAttributes(std::ostream & stream) const {
char buffer[256];
serialize(buffer, sizeof(buffer));
stream << " value=\"" << buffer << "\"";
}
#endif
// Properties

View File

@@ -17,10 +17,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(DivisionNode); }
#if TREE_LOG
const char * description() const override { return "Division"; }
#endif
int numberOfChildren() const override { return 2; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Division";
}
#endif
// Properties
Type type() const override { return Type::Division; }

View File

@@ -42,8 +42,10 @@ public:
EmptyLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(EmptyLayoutNode); }
int numberOfChildren() const override { return 0; }
#if TREE_LOG
const char * description() const override { return "Empty"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "EmptyLayout";
}
#endif
protected:

View File

@@ -30,8 +30,13 @@ public:
// TreeNode
size_t size() const override { return sizeof(FloatNode<T>); }
#if TREE_LOG
const char * description() const override { return "Float"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Float";
}
virtual void logAttributes(std::ostream & stream) const {
stream << " value=\"" << m_value << "\"";
}
#endif
// Properties

View File

@@ -18,8 +18,10 @@ public:
static FloorLayoutNode * FailedAllocationStaticNode();
FloorLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(FloorLayoutNode); }
#if TREE_LOG
const char * description() const override { return "FloorLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "FloorLayout";
}
#endif
protected:

View File

@@ -38,8 +38,10 @@ public:
// TreeNode
size_t size() const override { return sizeof(FractionLayoutNode); }
int numberOfChildren() const override { return 2; }
#if TREE_LOG
const char * description() const override { return "FractionLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "FractionLayout";
}
#endif
protected:

View File

@@ -12,9 +12,12 @@ public:
// TreeNode
int numberOfChildren() const override { return 0; }
size_t size() const override { return sizeof(GhostNode); }
#if TREE_LOG
const char * description() const override { return "Ghost"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Ghost";
}
#endif
// Ghost
bool isGhost() const override { return true; }
// Allocation Failure

View File

@@ -43,8 +43,10 @@ public:
m_numberOfChildren-= decrement;
}
void eraseNumberOfChildren() override { m_numberOfChildren = 0; }
#if TREE_LOG
const char * description() const override { return "Horizontal Layout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "HorizontalLayout";
}
#endif
protected:

View File

@@ -17,7 +17,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(InfinityNode); }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream stream) {
virtual void logNodeName(std::ostream & stream) const {
stream << "Infinity";
}
#endif

View File

@@ -133,8 +133,15 @@ public:
// TreeNode
size_t size() const override;
#if TREE_LOG
const char * description() const override { return "Integer"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Integer";
}
virtual void logAttributes(std::ostream & stream) const {
char buffer[256];
serialize(buffer, sizeof(buffer));
stream << " value=\"" << buffer << "\"";
}
#endif
// ExpressionNode

View File

@@ -33,8 +33,10 @@ public:
IntegralLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(IntegralLayoutNode); }
int numberOfChildren() const override { return 3; }
#if TREE_LOG
const char * description() const override { return "IntegralLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "IntegralLayout";
}
#endif
protected:

View File

@@ -25,8 +25,10 @@ public:
// TreeNode
static LeftParenthesisLayoutNode * FailedAllocationStaticNode();
LeftParenthesisLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
#if TREE_LOG
const char * description() const override { return "Left parenthesis"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "LeftParenthesisLayout";
}
#endif
protected:

View File

@@ -19,9 +19,12 @@ public:
static LeftSquareBracketLayoutNode * FailedAllocationStaticNode();
LeftSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(LeftSquareBracketLayoutNode); }
#if TREE_LOG
const char * description() const override { return "LeftSquareBracketLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "LeftSquareBracketLayout";
}
#endif
protected:
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
};

View File

@@ -26,10 +26,16 @@ public:
// TreeNode
size_t size() const override { return sizeof(MatrixComplexNode<T>); }
#if TREE_LOG
const char * description() const override { return "Evaluation matrix complex"; }
#endif
int numberOfChildren() const override { return m_numberOfRows*m_numberOfColumns; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "MatrixComplex";
}
virtual void logAttributes(std::ostream & stream) const {
stream << " rows=\"" << m_numberOfRows << "\"";
stream << " columns=\"" << m_numberOfColumns << "\"";
}
#endif
// EvaluationNode
typename EvaluationNode<T>::Type type() const override { return EvaluationNode<T>::Type::MatrixComplex; }

View File

@@ -33,8 +33,10 @@ public:
static MatrixLayoutNode * FailedAllocationStaticNode();
MatrixLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(MatrixLayoutNode); }
#if TREE_LOG
const char * description() const override { return "MatrixLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "MatrixLayout";
}
#endif
protected:

View File

@@ -23,8 +23,10 @@ public:
static MultiplicationNode * FailedAllocationStaticNode();
MultiplicationNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(MultiplicationNode); }
#if TREE_LOG
const char * description() const override { return "Multiplication"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Multiplication";
}
#endif
Type type() const override { return Type::Multiplication; }

View File

@@ -35,8 +35,10 @@ public:
NthRootLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(NthRootLayoutNode); }
int numberOfChildren() const override { return m_hasIndex ? 2 : 1; }
#if TREE_LOG
const char * description() const override { return "NthRootLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "NthRootLayout";
}
#endif
protected:

View File

@@ -18,10 +18,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(OppositeNode); }
#if TREE_LOG
const char * description() const override { return "Opposite"; }
#endif
int numberOfChildren() const override { return 0; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Opposite";
}
#endif
// Properties
Type type() const override { return Type::Opposite; }

View File

@@ -13,10 +13,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(ParenthesisNode); }
#if TREE_LOG
const char * description() const override { return "Parenthesis"; }
#endif
int numberOfChildren() const override { return 1; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Parenthesis";
}
#endif
// Properties
Type type() const override { return Type::Parenthesis; }

View File

@@ -18,10 +18,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(PowerNode); }
#if TREE_LOG
const char * description() const override { return "Power"; }
#endif
int numberOfChildren() const override { return 2; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Power";
}
#endif
// Properties
Type type() const override { return Type::Power; }

View File

@@ -13,8 +13,10 @@ public:
static ProductLayoutNode * FailedAllocationStaticNode();
ProductLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(ProductLayoutNode); }
#if TREE_LOG
const char * description() const override { return "ProductLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "ProductLayout";
}
#endif
protected:

View File

@@ -23,8 +23,10 @@ public:
// TreeNode
size_t size() const override;
#if TREE_LOG
const char * description() const override { return "Rational"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Rational";
}
#endif
// SerializationHelperInterface

View File

@@ -26,8 +26,10 @@ public:
static RightParenthesisLayoutNode * FailedAllocationStaticNode();
RightParenthesisLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(RightParenthesisLayoutNode); }
#if TREE_LOG
const char * description() const override { return "RightParenthesisLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "RightParenthesisLayout";
}
#endif
protected:

View File

@@ -19,8 +19,10 @@ public:
static RightSquareBracketLayoutNode * FailedAllocationStaticNode();
RightSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(RightSquareBracketLayoutNode); }
#if TREE_LOG
const char * description() const override { return "RightSquareBracketLayout"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "RightSquareBracketLayout";
}
#endif
protected:

View File

@@ -27,11 +27,7 @@ public:
char XNTChar() const override { return 'n'; }
// TreeNode
size_t size() const override { return sizeof(SequenceLayoutNode); }
int numberOfChildren() const override { return 3; }
#if TREE_LOG
const char * description() const override { return "Sequence Layout"; }
#endif
protected:
constexpr static KDCoordinate k_boundHeightMargin = 2;

View File

@@ -14,8 +14,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(SubtractionNode); }
const char * description() const override { return "Subtraction"; }
int numberOfChildren() const override { return 2; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Subtraction";
}
#endif
// ExpressionNode

View File

@@ -12,6 +12,13 @@ public:
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
static SumLayoutNode * FailedAllocationStaticNode();
SumLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
size_t size() const override { return sizeof(SumLayoutNode); }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "SumLayout";
}
#endif
private:
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
};

View File

@@ -18,10 +18,12 @@ public:
// TreeNode
size_t size() const override { return sizeof(SymbolNode); }
#if TREE_LOG
const char * description() const override { return "Symbol"; }
#endif
int numberOfChildren() const override { return 0; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Symbol";
}
#endif
// Expression Properties
Type type() const override { return Type::Symbol; }

View File

@@ -59,6 +59,11 @@ protected:
void addChildAtIndexInPlace(TreeByValue t, int index, int currentNumberOfChildren) {
TreeByReference::addChildAtIndexInPlace(t, index, currentNumberOfChildren);
}
/*
private:
// Fix
using TreeByReference::addChildAtIndexInPlace;
*/
};
}

View File

@@ -1,18 +1,20 @@
#ifndef POINCARE_TREE_NODE_H
#define POINCARE_TREE_NODE_H
#define POINCARE_TREE_LOG 1
#include <assert.h>
#include <stddef.h>
#include <strings.h>
#include <stdio.h>
#if POINCARE_TREE_LOG
#include <ostream>
#endif
/* What's in a TreeNode, really?
* - a vtable pointer
* - an identifier
* - a reference counter
*/
#define TREE_LOG 0
namespace Poincare {
@@ -41,8 +43,6 @@ public:
}
}
virtual const char * description() const { return "UNKNOWN";}
// Ghost
virtual bool isGhost() const { return false; }
@@ -153,11 +153,11 @@ public:
}
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream stream) = 0;
virtual void logAttributes(std::ostream stream) {
virtual void logNodeName(std::ostream & stream) const = 0;
virtual void logAttributes(std::ostream & stream) const {
}
void log(std::ostream stream, bool recursive = true) {
void log(std::ostream & stream, bool recursive = true) {
stream << "<";
logNodeName(stream);
stream << " id=\"" << m_identifier << "\"";
@@ -166,13 +166,13 @@ public:
logAttributes(stream);
stream << ">";
if (recursive) {
for (TreeNode * child : node->depthFirstChildren()) {
t->log(stream, recursive);
for (TreeNode * child : depthFirstChildren()) {
child->log(stream, recursive);
}
}
stream << "</";
logNodeName(stream);
stream << ">"
stream << ">";
}
#endif

View File

@@ -98,8 +98,8 @@ void TreeByReference::buildGhostChildren() {
}
#if POINCARE_TREE_LOG
void flatLog(std::ostream stream);
void treeLog(std::ostream stream);
void flatLog(std::ostream & stream);
void treeLog(std::ostream & stream);
#endif
int numberOfNodes() const {

View File

@@ -13,8 +13,10 @@ public:
// TreeNode
size_t size() const override { return sizeof(UndefinedNode); }
#if TREE_LOG
const char * description() const override { return "Undefined"; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Undefined";
}
#endif
// Properties

View File

@@ -40,9 +40,9 @@ public:
// TreeNode
size_t size() const override { return sizeof(VerticalOffsetLayoutNode); }
int numberOfChildren() const override { return 1; }
#if TREE_LOG
const char * description() const override {
return m_type == Type::Subscript ? "Subscript" : "Superscript";
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << (m_type == Type::Subscript ? "Subscript" : "Superscript");
}
#endif

View File

@@ -2,10 +2,6 @@
#include <string.h>
#include <stdint.h>
#if POINCARE_TREE_LOG
#include <iostream>
#endif
namespace Poincare {
TreePool * TreePool::sharedPool() {
@@ -99,8 +95,8 @@ void TreePool::moveNodes(TreeNode * destination, TreeNode * source, size_t moveS
}
#if POINCARE_TREE_LOG
void TreePool::flatLog(std::ostream stream) {
size_t size static_cast<char *>(m_cursor) - static_cast<char *>(m_buffer);
void TreePool::flatLog(std::ostream & stream) {
size_t size = static_cast<char *>(m_cursor) - static_cast<char *>(m_buffer);
stream << "<TreePool format=\"flat\" size=\"" << size << "\">";
for (TreeNode * node : allNodes()) {
node->log(stream, false);
@@ -108,7 +104,7 @@ void TreePool::flatLog(std::ostream stream) {
stream << "</TreePool>";
}
void TreePool::treeLog() {
void TreePool::treeLog(std::ostream & stream) {
stream << "<TreePool format=\"tree\" size=\"" << (int)(m_cursor-m_buffer) << "\">";
for (TreeNode * node : roots()) {
node->log(stream, true);

View File

@@ -22,6 +22,11 @@ public:
int data() { return m_data; }
void setData(int data) { m_data = data; }
virtual int numberOfChildren() const override { return 0; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Blob";
}
#endif
private:
int m_data;
};

View File

@@ -0,0 +1,51 @@
#ifndef POINCARE_TEST_PAIR_NODE_H
#define POINCARE_TEST_PAIR_NODE_H
#include <poincare/tree_node.h>
#include <poincare/allocation_failure_node.h>
#include <poincare/tree_by_reference.h>
#include <poincare/tree_by_value.h>
namespace Poincare {
class PairNode : public TreeNode {
public:
static PairNode * FailedAllocationStaticNode() {
static AllocationFailureNode<PairNode> failureNode;
return &failureNode;
}
virtual PairNode * failedAllocationStaticNode() override {
return PairNode::FailedAllocationStaticNode();
}
virtual size_t size() const override { return sizeof(PairNode); }
virtual int numberOfChildren() const override { return 2; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const {
stream << "Pair";
}
#endif
};
class PairByReference : public TreeByReference {
public:
PairByReference(TreeByReference t1, TreeByReference t2) : TreeByReference(TreePool::sharedPool()->createTreeNode<PairNode>()) {
replaceChildAtIndexInPlace(0, t1); // TODO: Is that the correct way to do this?
replaceChildAtIndexInPlace(1, t2); // TODO: Is that the correct way to do this?
}
};
class PairByValue : public TreeByValue {
public:
PairByValue(TreeByValue t1, TreeByValue t2) : TreeByValue(TreePool::sharedPool()->createTreeNode<PairNode>()) {
replaceChildAtIndexInPlace(0, t1);
replaceChildAtIndexInPlace(1, t2);
}
};
}
#endif

View File

@@ -3,6 +3,7 @@
#include <assert.h>
#include "blob_node.h"
#include "pair_node.h"
using namespace Poincare;
@@ -23,6 +24,15 @@ QUIZ_CASE(tree_by_values_are_stored_in_pool) {
assert_pool_size(0);
}
TreeByValue blob_with_data_3() {
return BlobByValue(3);
}
QUIZ_CASE(tree_by_values_can_be_returned) {
assert_pool_size(0);
TreeByValue b = blob_with_data_3();
assert_pool_size(1);
}
QUIZ_CASE(tree_by_values_allocation_failures) {
assert_pool_size(0);
BlobByValue b(1);
@@ -34,3 +44,13 @@ QUIZ_CASE(tree_by_values_allocation_failures) {
}
assert_pool_size(1);
}
QUIZ_CASE(tree_by_value_deep_copies) {
assert_pool_size(0);
BlobByValue b1(1);
BlobByValue b2(2);
PairByValue p(b1, b2);
assert_pool_size(3);
PairByValue p2 = p;
assert_pool_size(6);
}