From 4fd1dbec508c66dd07081f067c245f9ce0050333 Mon Sep 17 00:00:00 2001
From: Brandon Lai-Cheong <brandon.lai-cheong@uwaterloo.ca>
Date: Wed, 13 Nov 2024 15:12:29 -0500
Subject: [PATCH] new tests

---
 .gitignore            |  1 +
 tests/union_tests.cpp | 99 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 92 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index 6d7270f..316af62 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 build
 .vscode/c_cpp_properties.json
 .vscode/launch.json
+.vscode/settings.json
\ No newline at end of file
diff --git a/tests/union_tests.cpp b/tests/union_tests.cpp
index e468886..363956c 100644
--- a/tests/union_tests.cpp
+++ b/tests/union_tests.cpp
@@ -1,23 +1,106 @@
 #include "gtest/gtest.h"
 #include <union.h>
-#include<triangle.h>
+#include <triangle.h>
 
-TEST (UnionTrivialTests, NotTouching) {
-    Triangle t1 = Triangle{{0,0}, {5,0}, {2,3}, 0};
-    Triangle t2 = Triangle{{6,0}, {10,0}, {7,5}, 0};
+TEST(UnionTrivialTests, NotTouching)
+{
+    Triangle t1 = Triangle{{0, 0}, {5, 0}, {2, 3}, 0};
+    Triangle t2 = Triangle{{6, 0}, {10, 0}, {7, 5}, 0};
 
     auto ts = unionize(t1, t2);
 
     EXPECT_TRUE(ts.size() == 2);
 }
 
+TEST(UnionTests, TwoIntersections)
+{
 
-TEST (UnionTests, TwoIntersections) {
-
-    auto t1 = Triangle(Point{0,0}, Point{5,0},  Point{2,3}, 0);
-    auto t2 = Triangle(Point{3,1}, Point{6,1}, Point{4,3}, 0);
+    auto t1 = Triangle(Point{0, 0}, Point{5, 0}, Point{2, 3}, 0);
+    auto t2 = Triangle(Point{3, 1}, Point{6, 1}, Point{4, 3}, 0);
 
     auto ts = unionize(t1, t2);
 
     EXPECT_TRUE(ts.size() > 0);
+}
+
+TEST(UnionTests, TriangleTreeShapeTest)
+{
+    // Case 1 t1 covers t2
+    Triangle bottom = Triangle({0, 5}, {3, 2}, {5, 3}, 1, 1);
+    Triangle top = Triangle({0.1, 7}, {5, 3}, {3.2, 9}, 2, 2);
+
+    auto results = unionize(bottom, top);
+    std::vector<Triangle> expected_results_1;
+
+    EXPECT_EQ(results, expected_results_1);
+
+    // Case 2 t2 covers t1
+    bottom.depth = 3;
+
+    results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_2;
+
+    EXPECT_EQ(results, expected_results_2);
+}
+
+TEST(UnionTests, FoldTriangleTest)
+{
+
+    Triangle bottom = Triangle({0, 5}, {3, 2}, {5, 3}, 1, 1);
+    Triangle top = Triangle({0.1, 9}, {5, 5}, {2, 4}, 2, 2);
+
+    auto results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_1;
+
+    EXPECT_EQ(results, expected_results_1);
+
+    bottom.depth = 3;
+
+    results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_2;
+
+    EXPECT_EQ(results, expected_results_2);
+}
+
+TEST(UnionTests, IceCreamTest)
+{
+    Triangle bottom = Triangle({0, 5}, {3, 2}, {5, 3}, 1, 1);
+    Triangle top = Triangle({-1, 5}, {2, 4}, {5, 7}, 2, 2);
+
+    auto results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_1;
+
+    EXPECT_EQ(results, expected_results_1);
+
+    bottom.depth = 3;
+
+    results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_2;
+
+    EXPECT_EQ(results, expected_results_2);
+}
+
+TEST(UnionTests, StarTest)
+{
+    Triangle bottom = Triangle({0, 3}, {2.5, 6}, {5, 3}, 1, 1);
+    Triangle top = Triangle({0, 5}, {2, 0}, {5, 5}, 2, 2);
+
+    auto results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_1;
+
+    EXPECT_EQ(results, expected_results_1);
+
+    bottom.depth = 3;
+
+    results = unionize(bottom, top);
+
+    std::vector<Triangle> expected_results_2;
+
+    EXPECT_EQ(results, expected_results_2);
 }
\ No newline at end of file
-- 
GitLab