[poincare] Clean TreeNode tests

This commit is contained in:
Romain Goyet
2018-08-10 15:38:50 +02:00
parent f8785f5e79
commit b91744e82b
3 changed files with 21 additions and 4 deletions

View File

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

View File

@@ -32,8 +32,8 @@ public:
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?
replaceChildAtIndexInPlace(0, t1);
replaceChildAtIndexInPlace(1, t2);
}
};

View File

@@ -33,7 +33,7 @@ static void assert_pool_size(int i) {
#endif
}
QUIZ_CASE(tree_by_values_are_stored_in_pool) {
QUIZ_CASE(tree_by_values_are_discared_after_block) {
assert_pool_size(0);
{
BlobByValue b(0);
@@ -42,6 +42,23 @@ QUIZ_CASE(tree_by_values_are_stored_in_pool) {
assert_pool_size(0);
}
void make_temp_blob() {
BlobByValue b(5);
}
QUIZ_CASE(tree_by_values_are_discared_after_function_call) {
assert_pool_size(0);
make_temp_blob();
assert_pool_size(0);
}
QUIZ_CASE(tree_by_values_can_be_copied) {
assert_pool_size(0);
BlobByValue b(123);
assert_pool_size(1);
TreeByValue t = b;
assert_pool_size(2);
}
TreeByValue blob_with_data_3() {
return BlobByValue(3);
}