diff --git a/tests/edge_union_cases.cpp b/tests/edge_union_cases.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb9cf7c67a650f0ce4bda357c4d887bf13454cce --- /dev/null +++ b/tests/edge_union_cases.cpp @@ -0,0 +1,16 @@ +#include <gtest/gtest.h> +#include <union.h> +#include <triangle.h> + +TEST(UnionEdgeTests, TriangleVertexOnEdge) { + Triangle t1 = Triangle({}, {}, {}, 1, 1); + Triangle t2 = Triangle({}, {}, {}, 2, 2); + + auto result = unionize(t1, t2); + +} + +TEST(UnionEdgeTests, TriangleEdgeLength0) { + Triangle t1 = Triangle({1,1}, {2,2}, {3,3}, 1, 1); + Triangle t2 = Triangle({}, {}, {}, 2, 2); +} diff --git a/tests/unit_tests/convex_triangulation_tests.cpp b/tests/unit_tests/convex_triangulation_tests.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21c77eb55fb784707ce63a65565e58855ed19223 --- /dev/null +++ b/tests/unit_tests/convex_triangulation_tests.cpp @@ -0,0 +1,41 @@ +#include <gtest/gtest.h> +#include <convex_triangulation.h> +#include <vector> + +TEST(ConvexTriangulationTests, Simple) { + + Point p1{1,3}; + Point p2{2,2}; + Point p3{3,2.1}; + Point p4{4,3.2}; + Point p5{2.1,4}; + + std::vector<Point> points = { + p1, p2, p3, p4, p5 + }; + + auto results = convexTriangulation(points, 2, 2); + + std::vector<Triangle> expected_result { + Triangle(p1, p2, p3, 2, 2), + Triangle(p1, p3, p5, 2, 2), + Triangle(p5, p3, p4, 2, 2) + }; + + EXPECT_EQ(results, expected_result); + +} + +TEST(ConvexTriangulationTests, TrivialTriangle) { + std::vector<Point> points = { + {0,0}, + {2,0}, + {1.5, 2} + }; + + auto results = convexTriangulation(points, 1, 1); + Triangle expected_triangle = Triangle({0,0}, {2,0}, {1.5, 2}, 1, 1); + + EXPECT_EQ(results.size(), 1); + EXPECT_EQ(results[0], expected_triangle); +}