Skip to content

Commit

Permalink
Add new octree equality test
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Jul 6, 2020
1 parent 4489afe commit 5554a75
Showing 1 changed file with 49 additions and 30 deletions.
79 changes: 49 additions & 30 deletions Octree/test/Octree/test_octree_equality.cpp
Expand Up @@ -14,7 +14,7 @@ typedef CGAL::Octree::Octree
<Point_set, typename Point_set::Point_map>
Octree;

int test_identical_trees() {
void test_identical_trees() {

int failures = 0;

Expand All @@ -39,20 +39,11 @@ int test_identical_trees() {
b.refine(10, 1);

// Check if those trees are considered equal
std::cout << "test equality: identical octrees" << std::endl;
if (a == b) {
std::cout << "[PASS]" << std::endl;
} else {
failures++;
std::cout << "[FAIL]" << std::endl;
std::cout << a << std::endl;
std::cout << b << std::endl;
}

return failures;
assert(a == b);

}

int test_different_trees() {
void test_identical_contents_different_criteria() {

int failures = 0;

Expand All @@ -77,27 +68,55 @@ int test_different_trees() {
b.refine(10, 9);

// Check if those trees are considered equal
std::cout << "test equality: different octrees" << std::endl;
if (!(a == b)) {
std::cout << "[PASS]" << std::endl;
} else {
failures++;
std::cout << "[FAIL]" << std::endl;
std::cout << a << std::endl;
std::cout << b << std::endl;
}

return failures;
assert(!(a == b));
}

void test_different_contents_identical_criteria() {

// Create a couple of simple point sets
Point_set points_a;
points_a.insert({-1, -1, -1});
points_a.insert({1, -1, -1});
points_a.insert({-1, 1, -1});
points_a.insert({1, 1, -1});
points_a.insert({-1, -1, 1});
points_a.insert({1, -1, 1});
points_a.insert({-1, 1, 1});
points_a.insert({1, 1, 1});

Point_set points_b;
points_b.insert({-1, -1, -1});
points_b.insert({1, -1, -1});
points_b.insert({-1, 1, -1});
points_b.insert({1, 1, -1});
points_b.insert({-1, -1, 1});
points_b.insert({1, -1, 1});
points_b.insert({-1, 1, 1});
points_b.insert({1, 1, 2});

// Create a pair of trees from the different point sets
auto point_map_a = points_a.point_map();
Octree a(points_a, point_map_a);
auto point_map_b = points_b.point_map();
Octree b(points_b, point_map_b);

// Refine both trees using the same criteria
a.refine(10, 1);
b.refine(10, 1);

// Check if those trees are considered equal
assert(!(a == b));
}


int main(void) {

int failures = 0;

failures += test_identical_trees();
failures += test_different_trees();
test_identical_trees();

test_identical_contents_different_criteria();

test_different_contents_identical_criteria();

if (0 == failures)
return EXIT_SUCCESS;
return failures;
return EXIT_SUCCESS;
}

0 comments on commit 5554a75

Please sign in to comment.