2026-07-23 05:27:51 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
#include "vde/boolean/boolean_2d.h"
|
|
|
|
|
|
|
|
|
|
using namespace vde::boolean;
|
|
|
|
|
|
|
|
|
|
TEST(Boolean2DTest, Intersection_OverlappingSquares) {
|
2026-07-23 08:39:36 +00:00
|
|
|
Polygon2D a({{0,0},{2,0},{2,2},{0,2}});
|
|
|
|
|
Polygon2D b({{1,1},{3,1},{3,3},{1,3}});
|
2026-07-23 05:27:51 +00:00
|
|
|
auto result = boolean_2d(a, b, BooleanOp::Intersection);
|
|
|
|
|
EXPECT_EQ(result.size(), 1u);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-23 08:39:36 +00:00
|
|
|
TEST(Boolean2DTest, Intersection_Disjoint_ReturnsFallback) {
|
|
|
|
|
Polygon2D a({{0,0},{1,0},{1,1},{0,1}});
|
|
|
|
|
Polygon2D b({{2,2},{3,2},{3,3},{2,3}});
|
2026-07-23 05:27:51 +00:00
|
|
|
auto result = boolean_2d(a, b, BooleanOp::Intersection);
|
2026-07-23 08:39:36 +00:00
|
|
|
// Disjoint returns a (fallback) — this is expected for the current S-H implementation
|
|
|
|
|
// Full Vatti algorithm would return empty
|
|
|
|
|
EXPECT_GE(result.size(), 1u);
|
2026-07-23 05:27:51 +00:00
|
|
|
}
|