Commit 6d117f4f authored by Quentin Khan's avatar Quentin Khan

Fix tests standard empty assert macro when building release

The macro NDEBUG is undefined in the tests
parent 7d5c44b5
#ifdef NDEBUG // This test file must be run using NDEBUG for asserts
#undef NDEBUG
#endif
#include <cassert>
#include <iterator>
......@@ -25,7 +29,7 @@ namespace scalfmm {
tree_t* tree = nullptr;
node_t* root = nullptr;
box_t box {{0,0,0}, 100};
box_t box {100, {0,0,0}};
public:
......
#ifdef NDEBUG // This test relies on standard asserts
#undef NDEBUG
#endif
#include <cassert>
#include <random>
......@@ -47,7 +51,7 @@ namespace scalfmm {
{}
void set_up() {
tree = new tree_t({{0,0,0}, box_side_length});
tree = new tree_t({box_side_length, {0,0,0}});
tree->leaf_max_particle_count(20);
}
......@@ -76,7 +80,7 @@ namespace scalfmm {
void test_constructor_from_tree() {
assert(tree->root()->getDepth() == 0);
assert(tree->root()->getLevel() == 0);
assert(tree->root()->getParent() == nullptr);
assert(tree->root()->getBox() == tree->box());
assert(tree->root()->getIndex() == 0);
......@@ -101,7 +105,7 @@ namespace scalfmm {
box_t b = box_t( tree->box().center(), tree->box().corner(5) );
assert(node->getDepth() == 1);
assert(node->getLevel() == 1);
assert(node->getParent() == tree->root());
assert(node->getBox() == b);
assert(node->getIndex() == 5);
......@@ -123,7 +127,7 @@ namespace scalfmm {
assert(leaf->getChildren() == typename node_t::child_node_array_t{{}});
assert(leaf->getChild(0) == nullptr);
assert(leaf->getParent() == node);
assert(leaf->getDepth() == 1);
assert(leaf->getLevel() == 1);
assert(leaf->getIndex() == 0);
assert((&leaf->getTree()) == tree);
assert(leaf->getBox() == box_t(node->getBox().center(), node->getBox().corner(0)));
......@@ -137,7 +141,7 @@ namespace scalfmm {
assert(node->getChild(0) == leaf);
assert(node->getChild(0) == leaf);
assert(node->getParent() == nullptr);
assert(node->getDepth() == 0);
assert(node->getLevel() == 0);
assert(node->getIndex() == 0);
assert(&(node->getTree()) == tree);
assert(node->getBox() == tree->box() );
......@@ -198,7 +202,7 @@ namespace scalfmm {
void test_in_order_traversal() {
std::vector<std::pair<std::size_t,std::size_t>> indexes;
std::function<void(node_t*)> lambda = [&](node_t* node) {
indexes.emplace_back(node->getDepth(), node->getIndex());
indexes.emplace_back(node->getLevel(), node->getIndex());
};
tree->root()->create_children();
......@@ -228,7 +232,7 @@ namespace scalfmm {
void test_post_order_traversal() {
std::vector<std::pair<std::size_t,std::size_t>> indexes;
std::function<void(node_t*)> lambda = [&](node_t* node) {
indexes.emplace_back(node->getDepth(), node->getIndex());
indexes.emplace_back(node->getLevel(), node->getIndex());
};
tree->root()->create_children();
......@@ -259,7 +263,7 @@ namespace scalfmm {
void test_pre_order_traversal() {
std::vector<std::pair<std::size_t,std::size_t>> indexes;
std::function<void(node_t*)> lambda = [&](node_t* node) {
indexes.emplace_back(node->getDepth(), node->getIndex());
indexes.emplace_back(node->getLevel(), node->getIndex());
};
tree->root()->create_children();
......@@ -308,12 +312,12 @@ namespace scalfmm {
}
if(n->getParent() && node->is_adjacent(n->getParent())
&& ! node->is_adjacent(n)
&& node->getDepth() < n->getDepth() ) {
&& node->getLevel() < n->getLevel() ) {
this->W.insert(n);
}
}
if(n->getDepth() == node->getDepth()) {
if(n->getLevel() == node->getLevel()) {
if(node->getParent()
&& n->getParent()
&& ! node->is_adjacent(n)
......@@ -327,7 +331,7 @@ namespace scalfmm {
if(node->getParent()
&& n->is_adjacent(node->getParent())
&& ! n->is_adjacent(node)
&& n->getDepth() < node->getDepth()) {
&& n->getLevel() < node->getLevel()) {
this->X.insert(n);
}
}
......@@ -386,7 +390,7 @@ namespace scalfmm {
void test_split_max_height() {
node_t* node = tree->root();
std::size_t i;
typename node_t::level_t i;
// Check that the split limit works
for(i = 0; i < tree->max_height() && node != nullptr; ++i) {
node->split();
......@@ -394,7 +398,7 @@ namespace scalfmm {
}
assert(node != nullptr);
assert(node->getDepth() == tree->max_height());
assert(node->getLevel() == tree->max_height());
node->split();
for(auto c : node->getChildren()) {
......@@ -559,7 +563,7 @@ namespace scalfmm {
}
});
assert(loader.getNumberOfParticles() == particle_counter);
assert((size_t)loader.getNumberOfParticles() == particle_counter);
tree->root()->for_each_in_order([&](node_t* node) {
interaction_list_struct lists(tree, node);
......
#ifdef NDEBUG // This test relies on standard assert
#undef NDEBUG
#endif
#include <cassert>
#include "test_Abstract.hpp"
......
#ifdef NDEBUG // This test relies on standard assert
#undef NDEBUG
#endif
#include <cassert>
#include <iterator>
......@@ -25,7 +29,7 @@ namespace scalfmm {
tree_t* tree = nullptr;
node_t* root = nullptr;
box_t box {{0,0,0}, 100};
box_t box {100, {0,0,0}};
public:
......
#ifdef NDEBUG // This test relies on standard assert
#undef NDEBUG
#endif
#include <cassert>
#include <iterator>
......@@ -25,7 +29,7 @@ namespace scalfmm {
tree_t* tree = nullptr;
node_t* root = nullptr;
box_t box {{0,0,0}, 100};
box_t box {100, {0,0,0}};
public:
......
#ifdef NDEBUG // This test relies on standard assert
#undef NDEBUG
#endif
#include <cassert>
#include "test_Abstract.hpp"
......@@ -23,7 +27,7 @@ namespace scalfmm {
using box_t = typename tree_t::box_t;
using position_t = typename box_t::position_t;
box_t box {position_t(), 100};
box_t box {100, position_t()};
tree_t* tree = nullptr;
public:
......@@ -49,7 +53,7 @@ namespace scalfmm {
}
void test_swap() {
box_t t_box = {position_t(), 50};
box_t t_box = {50, position_t()};
tree_t t(t_box);
auto root = tree->root();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment