From 60d51d91f5b04b459646be7e57988896c9561c81 Mon Sep 17 00:00:00 2001 From: Erick Ahmed Date: Tue, 11 Nov 2025 10:47:22 +0100 Subject: [PATCH] test: add unit tests for point deletion --- test/occt/point-test.cpp | 51 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/test/occt/point-test.cpp b/test/occt/point-test.cpp index 0d14308..7279f52 100644 --- a/test/occt/point-test.cpp +++ b/test/occt/point-test.cpp @@ -8,7 +8,7 @@ #include #include "point.hpp" -TEST_CASE("make_point and coord_point behavior", "[make_point]") { +TEST_CASE("make_point and coord_point behavior", "[point]") { auto check_coords = [](const TopoDS_Shape& p, const double expected[3]) { double x, y, z; coord_point(p, &x, &y, &z); @@ -76,3 +76,52 @@ TEST_CASE("make_point and coord_point behavior", "[make_point]") { REQUIRE((std::isnan(z) || std::isinf(z))); } } + +TEST_CASE("clear_point behavior", "[point]") { + SECTION("Clear single point") { + TopoDS_Shape point = make_point(1.0, 2.0, 3.0); + + REQUIRE_FALSE(point.IsNull()); + double x, y, z; + coord_point(point, &x, &y, &z); + REQUIRE(x == Catch::Approx(1.0)); + REQUIRE(y == Catch::Approx(2.0)); + REQUIRE(z == Catch::Approx(3.0)); + + clear_point(point); + + REQUIRE(point.IsNull()); + } + + SECTION("Clear multiple points") { + const int num_points = 5; + TopoDS_Shape points[num_points]; + + for (int i = 0; i < num_points; ++i) { + points[i] = make_point(i * 1.0, i * 2.0, i * 3.0); + REQUIRE_FALSE(points[i].IsNull()); + } + + for (int i = 0; i < num_points; ++i) { + clear_point(points[i]); + REQUIRE(points[i].IsNull()); + } + } + + SECTION("Clear already null shape") { + TopoDS_Shape null_shape; + REQUIRE(null_shape.IsNull()); + + clear_point(null_shape); + REQUIRE(null_shape.IsNull()); + } + + SECTION("Memory efficiency - multiple clear calls") { + TopoDS_Shape point = make_point(1.0, 1.0, 1.0); + + for (int i = 0; i < 100; ++i) { + clear_point(point); + REQUIRE(point.IsNull()); + } + } +}