Testing - Migrate QA DRAW tests to GTest (#818)

- Removed 37 DRAW test scripts from `tests/bugs/` directories
- Added 31 new GTest C++ test files in appropriate `GTests/` directories
- Removed corresponding QAcommands implementations from QABugs source files
- Updated CMake FILES.cmake files to include new test files
This commit is contained in:
Pasukhin Dmitry
2025-11-10 21:17:50 +00:00
committed by GitHub
parent 49cf4baea6
commit d166ff70e7
86 changed files with 1989 additions and 2901 deletions
@@ -2028,3 +2028,24 @@ TEST_F(BFuseSimpleTest, BlendBoxWithCylinderBottomNegY_K9)
const TopoDS_Shape aResult = PerformFuse(aBlendedBox, aCylinder);
ValidateResult(aResult, 322832);
}
//==================================================================================================
// Additional Tests
//==================================================================================================
TEST_F(BFuseSimpleTest, OCC277_FuseAndCommonOfOverlappingBoxes)
{
BRepPrimAPI_MakeBox aBox1Maker(100, 100, 100);
BRepPrimAPI_MakeBox aBox2Maker(gp_Pnt(50, 50, 50), 200, 200, 200);
TopoDS_Shape aShape1 = aBox1Maker.Shape();
TopoDS_Shape aShape2 = aBox2Maker.Shape();
BRepAlgoAPI_Fuse aFuseOp(aShape1, aShape2);
TopoDS_Shape aFuseResult = aFuseOp.Shape();
EXPECT_FALSE(aFuseResult.IsNull());
BRepAlgoAPI_Common aCommonOp(aShape1, aShape2);
TopoDS_Shape aCommonResult = aCommonOp.Shape();
EXPECT_FALSE(aCommonResult.IsNull());
}
@@ -1,6 +1,8 @@
# Test source files for TKGeomAlgo
set(OCCT_TKGeomAlgo_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKGeomAlgo_GTests_FILES
Geom2dAPI_InterCurveCurve_Test.cxx
GeomFill_CorrectedFrenet_Test.cxx
GeomPlate_BuildPlateSurface_Test.cxx
)
@@ -0,0 +1,66 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <Geom2d_Ellipse.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Ax2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Dir2d.hxx>
#include <math_NewtonFunctionRoot.hxx>
#include <math_TrigonometricEquationFunction.hxx>
#include <gtest/gtest.h>
TEST(Geom2dAPI_InterCurveCurve_Test, OCC29289_EllipseIntersectionNewtonRoot)
{
// Create two ellipses
gp_Elips2d e1(gp_Ax2d(gp_Pnt2d(0., 0.), gp_Dir2d(gp_Dir2d::D::X)), 2., 1.);
Handle(Geom2d_Ellipse) Ge1 = new Geom2d_Ellipse(e1);
gp_Elips2d e2(gp_Ax2d(gp_Pnt2d(0.5, 0.5), gp_Dir2d(1., 1.)), 2., 1.);
Handle(Geom2d_Ellipse) Ge2 = new Geom2d_Ellipse(e2);
// Find intersection points
Geom2dAPI_InterCurveCurve Intersector;
Intersector.Init(Ge1, Ge2, 1.e-7);
EXPECT_GT(Intersector.NbPoints(), 0) << "Error: intersector found no points";
// Setup trigonometric equation: A*Cos(x) + B*Sin(x) + C*Cos(2*x) + D*Sin(2*x) + E
Standard_Real A, B, C, D, E;
A = 1.875;
B = -.75;
C = -.5;
D = -.25;
E = -.25;
math_TrigonometricEquationFunction MyF(A, B, C, D, E);
Standard_Real Tol1 = 1.e-15;
Standard_Real Eps = 1.5e-12;
Standard_Integer Nit[] = {5, 6, 7, 6};
// For each intersection point, verify Newton root finding
Standard_Real TetaPrev = 0.;
Standard_Integer i;
for (i = 1; i <= Intersector.NbPoints(); i++)
{
Standard_Real Teta = Intersector.Intersector().Point(i).ParamOnFirst();
Standard_Real X = Teta - 0.1 * (Teta - TetaPrev);
TetaPrev = Teta;
math_NewtonFunctionRoot Resol(MyF, X, Tol1, Eps, Nit[i - 1]);
ASSERT_TRUE(Resol.IsDone()) << "Error: Newton is not done for " << Teta;
Standard_Real TetaNewton = Resol.Root();
EXPECT_LE(Abs(Teta - TetaNewton), 1.e-7) << "Error: Newton root is wrong for " << Teta;
}
}
@@ -0,0 +1,30 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <GeomPlate_BuildPlateSurface.hxx>
#include <gtest/gtest.h>
TEST(GeomPlate_BuildPlateSurface, OCC525_PerformWithoutConstraints)
{
GeomPlate_BuildPlateSurface aBuilder;
aBuilder.Perform();
// Note: Due to implementation behavior, IsDone() returns true after Init()
// even though Perform() returns early when there are no constraints.
// The resulting surface is null, which is the expected behavior.
// Original bug OCC525: Bug in GeomPlate_BuildPlateSurface::ComputeSurfInit()
EXPECT_TRUE(aBuilder.IsDone());
EXPECT_TRUE(aBuilder.Surface().IsNull())
<< "Surface should be null when Perform() is called without constraints";
}
@@ -0,0 +1,25 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepLib_MakeWire.hxx>
#include <TopoDS_Wire.hxx>
#include <gtest/gtest.h>
TEST(BRepLib_MakeWire_Test, OCC30708_2_InitializeWithNullWire)
{
TopoDS_Wire empty;
// Should not throw exception when initializing with null wire
EXPECT_NO_THROW(BRepLib_MakeWire aWBuilder(empty));
}
@@ -0,0 +1,80 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gtest/gtest.h>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepOffsetAPI_ThruSections.hxx>
#include <TopoDS_Shape.hxx>
#include <gp_Pnt.hxx>
// Test OCC10006: BRepOffsetAPI_ThruSections loft operation with Boolean fusion
TEST(BRepOffsetAPI_ThruSections_Test, OCC10006_LoftAndFusion)
{
// Define bottom and top polygon coordinates for first loft
double aBottomPoints1[12] = {10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
double aTopPoints1[12] = {0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
// Define bottom and top polygon coordinates for second loft
double aBottomPoints2[12] = {0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
double aTopPoints2[12] = {0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
// Create polygons
BRepBuilderAPI_MakePolygon aBottomPolygon1, aTopPolygon1, aBottomPolygon2, aTopPolygon2;
gp_Pnt aTmpPnt;
for (int i = 0; i < 4; i++)
{
aTmpPnt.SetCoord(aBottomPoints1[3 * i], aBottomPoints1[3 * i + 1], aBottomPoints1[3 * i + 2]);
aBottomPolygon1.Add(aTmpPnt);
aTmpPnt.SetCoord(aTopPoints1[3 * i], aTopPoints1[3 * i + 1], aTopPoints1[3 * i + 2]);
aTopPolygon1.Add(aTmpPnt);
aTmpPnt.SetCoord(aBottomPoints2[3 * i], aBottomPoints2[3 * i + 1], aBottomPoints2[3 * i + 2]);
aBottomPolygon2.Add(aTmpPnt);
aTmpPnt.SetCoord(aTopPoints2[3 * i], aTopPoints2[3 * i + 1], aTopPoints2[3 * i + 2]);
aTopPolygon2.Add(aTmpPnt);
}
// Close polygons
aBottomPolygon1.Close();
aTopPolygon1.Close();
aBottomPolygon2.Close();
aTopPolygon2.Close();
// Create first loft (ThruSections)
BRepOffsetAPI_ThruSections aLoft1(Standard_True, Standard_True);
aLoft1.AddWire(aBottomPolygon1.Wire());
aLoft1.AddWire(aTopPolygon1.Wire());
aLoft1.Build();
// Create second loft (ThruSections)
BRepOffsetAPI_ThruSections aLoft2(Standard_True, Standard_True);
aLoft2.AddWire(aBottomPolygon2.Wire());
aLoft2.AddWire(aTopPolygon2.Wire());
aLoft2.Build();
// Verify that loft operations succeeded
EXPECT_FALSE(aLoft1.Shape().IsNull()) << "First loft operation should produce a valid shape";
EXPECT_FALSE(aLoft2.Shape().IsNull()) << "Second loft operation should produce a valid shape";
// Perform Boolean fusion of the two lofted shapes
BRepAlgoAPI_Fuse aFusion(aLoft1.Shape(), aLoft2.Shape());
// Verify that fusion operation succeeded
EXPECT_FALSE(aFusion.Shape().IsNull())
<< "Boolean fusion of lofted shapes should produce a valid shape";
}
@@ -2,4 +2,6 @@
set(OCCT_TKTopAlgo_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKTopAlgo_GTests_FILES
BRepLib_MakeWire_Test.cxx
BRepOffsetAPI_ThruSections_Test.cxx
)