test: improve test coverage for make_point() and coord_point()
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
name: OCCT CI
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches: [master, dev-occt]
|
||||
paths:
|
||||
- "src/occt/**"
|
||||
- "src/ffi/**"
|
||||
@@ -11,7 +11,7 @@ on:
|
||||
- ".github/**"
|
||||
- "./CMakeLists.txt"
|
||||
pull_request:
|
||||
branches: [master]
|
||||
branches: [master, dev-occt]
|
||||
paths:
|
||||
- "src/occt/**"
|
||||
- "src/ffi/**"
|
||||
@@ -24,7 +24,7 @@ on:
|
||||
jobs:
|
||||
build-wrappers:
|
||||
name: Build OCCT wrappers
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -35,11 +35,3 @@ jobs:
|
||||
|
||||
- name: Build OCCT and run tests
|
||||
run: ./ci/scripts/occt.sh --unit-testing
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
run: |
|
||||
echo "=== CI Summary ==="
|
||||
echo "Build: ${{ steps.build.outcome }}"
|
||||
echo "Tests: ${{ steps.test.outcome }}"
|
||||
echo "=================="
|
||||
|
||||
+49
-80
@@ -8,102 +8,71 @@
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include "point.hpp"
|
||||
|
||||
TEST_CASE("Create points and get coordinates") {
|
||||
SECTION("Positive integer coordinates") {
|
||||
double coords[3] = {3, 7, 2};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
TEST_CASE("make_point and coord_point behavior", "[make_point]") {
|
||||
auto check_coords = [](const TopoDS_Shape& p, const double expected[3]) {
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
REQUIRE(x == Catch::Approx(expected[0]));
|
||||
REQUIRE(y == Catch::Approx(expected[1]));
|
||||
REQUIRE(z == Catch::Approx(expected[2]));
|
||||
};
|
||||
|
||||
INFO("Point coordinates: " << x << ", " << y << ", " << z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
}
|
||||
|
||||
SECTION("Negative integer coordinates") {
|
||||
double coords[3] = {-2, -5, -14};
|
||||
SECTION("Accept integer coordinates") {
|
||||
double coords[3] = {3, -7, 2};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
check_coords(p, coords);
|
||||
}
|
||||
|
||||
SECTION("Mixed integer coordinates") {
|
||||
double coords[3] = {8, -5, 4};
|
||||
SECTION("Accept float coordinates") {
|
||||
double coords[3] = {3.2352, 7.124662, -2.5};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
check_coords(p, coords);
|
||||
}
|
||||
|
||||
SECTION("Positive float coordinates") {
|
||||
double coords[3] = {3.2352, 7.124662, 2.5};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
}
|
||||
|
||||
SECTION("Negative float coordinates") {
|
||||
double coords[3] = {-2.1345, -5.463, -14.00001};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
}
|
||||
|
||||
SECTION("Mixed float coordinates") {
|
||||
double coords[3] = {8.124, -5.523, 4.0};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
}
|
||||
|
||||
SECTION("Origin") {
|
||||
SECTION("XYZ Origin") {
|
||||
double coords[3] = {0, 0, 0};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
check_coords(p, coords);
|
||||
}
|
||||
|
||||
SECTION("Large values") {
|
||||
double coords[3] = {65186415.16516, 948156654.0, -6516515.165};
|
||||
SECTION("Large magnitude values") {
|
||||
double coords[3] = {6.5186415e7, 9.48156654e8, -6.516515e6};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
check_coords(p, coords);
|
||||
}
|
||||
|
||||
SECTION("Multiple points") {
|
||||
const double points[5][3] = {
|
||||
{3, 7, 2},
|
||||
{3, 7, 2},
|
||||
{-5, 3.7, 8},
|
||||
{-3, -7, -2},
|
||||
{0, 0, 1}
|
||||
};
|
||||
|
||||
for (const auto& c : points) {
|
||||
TopoDS_Shape p = make_point(c[0], c[1], c[2]);
|
||||
check_coords(p, c);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Extreme double limits") {
|
||||
double coords[3] = {std::numeric_limits<double>::max(),
|
||||
std::numeric_limits<double>::lowest(),
|
||||
std::numeric_limits<double>::min()};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
check_coords(p, coords);
|
||||
}
|
||||
|
||||
SECTION("NaN and Infinity") {
|
||||
double coords[3] = {std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::infinity(),
|
||||
-std::numeric_limits<double>::infinity()};
|
||||
TopoDS_Shape p = make_point(coords[0], coords[1], coords[2]);
|
||||
double x, y, z;
|
||||
coord_point(p, &x, &y, &z);
|
||||
|
||||
REQUIRE(x == Catch::Approx(coords[0]));
|
||||
REQUIRE(y == Catch::Approx(coords[1]));
|
||||
REQUIRE(z == Catch::Approx(coords[2]));
|
||||
REQUIRE((std::isnan(x) || std::isinf(x)));
|
||||
REQUIRE((std::isnan(y) || std::isinf(y)));
|
||||
REQUIRE((std::isnan(z) || std::isinf(z)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user