Skip to content

Commit

Permalink
Add tests for MinIncidentValenceInvariant.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-zint committed Oct 12, 2023
1 parent 91a6855 commit 7d0389e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(TEST_SOURCES
test_tuple_3d.cpp
test_io.cpp
test_execution.cpp
test_invariants.cpp
test_simplex_collection.cpp
test_simplicial_complex.cpp
test_2d_operations.cpp
Expand Down
56 changes: 56 additions & 0 deletions tests/test_invariants.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <catch2/catch_test_macros.hpp>

#include "tools/DEBUG_TriMesh.hpp"
#include "tools/TriMesh_examples.hpp"

#include <wmtk/invariants/MinIncidentValenceInvariant.hpp>

using namespace wmtk;
using namespace wmtk::invariants;
using namespace wmtk::tests;

TEST_CASE("MinIncidentValenceInvariant", "[invariants][2D]")
{
SECTION("single_triangle")
{
const DEBUG_TriMesh m = single_triangle();
const MinIncidentValenceInvariant inv(m, 3);

for (const Tuple& t : m.get_all(PrimitiveType::Edge)) {
CHECK_FALSE(inv.before(t));
CHECK_FALSE(inv.after(PrimitiveType::Edge, {t}));
}
}
SECTION("one_ear")
{
const DEBUG_TriMesh m = one_ear();
const MinIncidentValenceInvariant inv(m, 3);

const Simplex e_mid = Simplex::edge(m.edge_tuple_between_v1_v2(0, 1, 0));

for (const Tuple& t : m.get_all(PrimitiveType::Edge)) {
const Simplex e = Simplex::edge(t);
if (m.simplices_are_equal(e, e_mid)) {
CHECK(inv.before(t));
CHECK(inv.after(PrimitiveType::Edge, {t}));
} else {
CHECK_FALSE(inv.before(t));
CHECK_FALSE(inv.after(PrimitiveType::Edge, {t}));
}
}

CHECK_FALSE(inv.after(PrimitiveType::Edge, m.get_all(PrimitiveType::Edge)));
}
SECTION("edge_region")
{
const DEBUG_TriMesh m = edge_region();
const MinIncidentValenceInvariant inv(m, 3);

for (const Tuple& t : m.get_all(PrimitiveType::Edge)) {
CHECK(inv.before(t));
CHECK(inv.after(PrimitiveType::Edge, {t}));
}

CHECK(inv.after(PrimitiveType::Edge, m.get_all(PrimitiveType::Edge)));
}
}

0 comments on commit 7d0389e

Please sign in to comment.