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

- Deletion of 20 legacy DRAW test files (.tcl format) from tests/bugs/ directories
- Addition of 15 new GTest C++ test files across multiple modules
- Removal of corresponding QA command implementations from TKQADraw
This commit is contained in:
Pasukhin Dmitry
2025-11-13 09:28:07 +00:00
committed by GitHub
parent 44df7106f3
commit 396b677095
50 changed files with 1242 additions and 1299 deletions

View File

@@ -0,0 +1,54 @@
// 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 <Expr_GeneralExpression.hxx>
#include <Expr_NamedUnknown.hxx>
#include <ExprIntrp_GenExp.hxx>
#include <TCollection_AsciiString.hxx>
#include <gtest/gtest.h>
TEST(Expr_GeneralExpression_Test, OCC902_ExpressionDerivative)
{
// Bug OCC902: Bad derivative computation
// This test verifies that the derivative of Exp(5*x) is correctly computed
// The expected result is either "Exp(5*x)*5" or "5*Exp(5*x)"
TCollection_AsciiString anExpStr("5");
anExpStr.AssignCat("*x");
anExpStr.Prepend("Exp(");
anExpStr.AssignCat(")");
Handle(ExprIntrp_GenExp) anExprIntrp = ExprIntrp_GenExp::Create();
// Create the expression
anExprIntrp->Process(anExpStr);
ASSERT_TRUE(anExprIntrp->IsDone()) << "Expression interpretation should succeed";
Handle(Expr_GeneralExpression) anExpr = anExprIntrp->Expression();
ASSERT_FALSE(anExpr.IsNull()) << "Expression should not be null";
Handle(Expr_NamedUnknown) aVar = new Expr_NamedUnknown("x");
Handle(Expr_GeneralExpression) aNewExpr = anExpr->Derivative(aVar);
ASSERT_FALSE(aNewExpr.IsNull()) << "Derivative should not be null";
TCollection_AsciiString aDerivativeStr = aNewExpr->String();
// The derivative of Exp(5*x) should be either "Exp(5*x)*5" or "5*Exp(5*x)"
bool isCorrect = (aDerivativeStr == "Exp(5*x)*5") || (aDerivativeStr == "5*Exp(5*x)");
EXPECT_TRUE(isCorrect) << "Derivative result was: " << aDerivativeStr.ToCString()
<< ", expected either 'Exp(5*x)*5' or '5*Exp(5*x)'";
}

View File

@@ -2,4 +2,5 @@
set(OCCT_TKExpress_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKExpress_GTests_FILES
Expr_GeneralExpression_Test.cxx
)

View File

@@ -3,6 +3,7 @@ set(OCCT_TKGeomAlgo_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKGeomAlgo_GTests_FILES
Geom2dAPI_InterCurveCurve_Test.cxx
Geom2dGcc_Circ2d3Tan_Test.cxx
GeomFill_CorrectedFrenet_Test.cxx
GeomPlate_BuildPlateSurface_Test.cxx
)

View File

@@ -0,0 +1,77 @@
// 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 <Geom2dAdaptor_Curve.hxx>
#include <Geom2dGcc_Circ2d3Tan.hxx>
#include <Geom2dGcc_QualifiedCurve.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_Circle.hxx>
#include <GeomAPI.hxx>
#include <gp_Ax2.hxx>
#include <gp_Pln.hxx>
#include <gtest/gtest.h>
TEST(Geom2dGcc_Circ2d3Tan_Test, OCC353_TangentCircleDoesNotHang)
{
// Bug OCC353: Attached DRAW command hangs in Geom2dGcc_Circ2d3Tan
// This test verifies that computing a circle tangent to two circles and
// passing through a point doesn't hang
// Create two 3D circles
gp_Ax2 anAx21(gp_Pnt(100, 0, 0), gp_Dir(gp::DZ()));
Handle(Geom_Circle) aCirc1 = new Geom_Circle(anAx21, 25);
gp_Ax2 anAx22(gp_Pnt(-100, 0, 0), gp_Dir(gp::DZ()));
Handle(Geom_Circle) aCirc2 = new Geom_Circle(anAx22, 25);
// Reference plane for 2D projection
gp_Pln aRefPln(gp_Pnt(0, 0, 0), gp_Dir(gp::DZ()));
// Convert 3D circles to 2D
Handle(Geom2d_Curve) aCirc2d1 = GeomAPI::To2d(aCirc1, aRefPln);
Handle(Geom2d_Curve) aCirc2d2 = GeomAPI::To2d(aCirc2, aRefPln);
// Create adaptors
Geom2dAdaptor_Curve anAdap1(aCirc2d1);
Geom2dAdaptor_Curve anAdap2(aCirc2d2);
// Create qualified curves (enclosing)
Geom2dGcc_QualifiedCurve aQCur1(anAdap1, GccEnt_enclosing);
Geom2dGcc_QualifiedCurve aQCur2(anAdap2, GccEnt_enclosing);
// Create a 2D point
gp_Pnt2d aPt2d(0, 175);
Handle(Geom2d_CartesianPoint) aPt = new Geom2d_CartesianPoint(aPt2d);
// Compute tangent circle - this should not hang
Geom2dGcc_Circ2d3Tan aSol(aQCur1, aQCur2, aPt, 0.001, 0.0, 0.0);
// Verify that the computation completed successfully
EXPECT_TRUE(aSol.IsDone()) << "Geom2dGcc_Circ2d3Tan computation should complete";
// Verify that we have solutions
if (aSol.IsDone())
{
Standard_Integer aNbSol = aSol.NbSolutions();
EXPECT_GT(aNbSol, 0) << "Should find at least one solution";
// Verify that we can access the solutions
for (Standard_Integer i = 1; i <= aNbSol; i++)
{
EXPECT_NO_THROW(aSol.ThisSolution(i)) << "Should be able to access solution " << i;
}
}
}

View File

@@ -0,0 +1,86 @@
// 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 <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepMesh_GeomTool.hxx>
#include <Geom_Circle.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Precision.hxx>
#include <gp_Ax2.hxx>
#include <gp_Pln.hxx>
#include <gtest/gtest.h>
TEST(BRepMesh_GeomTool_Test, OCC25547_StaticMethodsExportAndFunctionality)
{
// Bug OCC25547: static class methods not exported in BRepMesh_GeomTool
// This test verifies that BRepMesh_GeomTool static methods are properly exported
// and functional
// Test 1: Discretize an arc
const Standard_Real aFirstP = 0., aLastP = M_PI;
Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(aHalf);
BRepAdaptor_Curve anAdaptor(anEdge);
BRepMesh_GeomTool aGeomTool(anAdaptor, aFirstP, aLastP, 0.1, 0.5);
EXPECT_GT(aGeomTool.NbPoints(), 0) << "BRepMesh_GeomTool failed to discretize an arc";
// Test 2: Test Normal() static method
TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
BRepAdaptor_Surface aSurf(aFace);
Handle(BRepAdaptor_Surface) aHSurf = new BRepAdaptor_Surface(aSurf);
gp_Pnt aPnt;
gp_Dir aNormal;
Standard_Boolean isNormalComputed = BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal);
EXPECT_TRUE(isNormalComputed) << "BRepMesh_GeomTool failed to compute a normal of surface";
// Test 3: Test IntLinLin() static method - line-line intersection
gp_XY aRefPnts[4] = {gp_XY(-10., -10.), gp_XY(10., 10.), gp_XY(-10., 10.), gp_XY(10., -10.)};
gp_Pnt2d anIntPnt;
Standard_Real aParams[2];
BRepMesh_GeomTool::IntFlag anIntFlag = BRepMesh_GeomTool::IntLinLin(aRefPnts[0],
aRefPnts[1],
aRefPnts[2],
aRefPnts[3],
anIntPnt.ChangeCoord(),
aParams);
Standard_Real aDiff = anIntPnt.Distance(gp::Origin2d());
EXPECT_EQ(anIntFlag, BRepMesh_GeomTool::Cross)
<< "BRepMesh_GeomTool::IntLinLin should return Cross flag";
EXPECT_LE(aDiff, Precision::PConfusion())
<< "BRepMesh_GeomTool failed to intersect two lines at origin";
// Test 4: Test IntSegSeg() static method - segment-segment intersection
anIntFlag = BRepMesh_GeomTool::IntSegSeg(aRefPnts[0],
aRefPnts[1],
aRefPnts[2],
aRefPnts[3],
Standard_False,
Standard_False,
anIntPnt);
aDiff = anIntPnt.Distance(gp::Origin2d());
EXPECT_EQ(anIntFlag, BRepMesh_GeomTool::Cross)
<< "BRepMesh_GeomTool::IntSegSeg should return Cross flag";
EXPECT_LE(aDiff, Precision::PConfusion())
<< "BRepMesh_GeomTool failed to intersect two segments at origin";
}

View File

@@ -2,4 +2,5 @@
set(OCCT_TKMesh_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKMesh_GTests_FILES
BRepMesh_GeomTool_Test.cxx
)

View File

@@ -0,0 +1,42 @@
// 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 <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gtest/gtest.h>
TEST(BRepPrimAPI_MakePrism_Test, OCC31294_GeneratedListForNonBaseShape)
{
// Bug OCC31294: Modeling Algorithms - Regression relatively 7.3.0.
// Crash in method BRepPrimAPI_MakePrism::Generated(...) if input sub-shape
// does not belong to the base shape
//
// This test verifies that calling Generated() with a shape that doesn't belong
// to the base shape doesn't crash and returns an empty list
BRepBuilderAPI_MakeVertex aMkVert(gp_Pnt(0., 0., 0.));
BRepBuilderAPI_MakeVertex aMkDummy(gp_Pnt(0., 0., 0.));
BRepPrimAPI_MakePrism aMkPrism(aMkVert.Shape(), gp_Vec(0., 0., 1.));
// Check that Generated() returns 1 shape for the vertex used to create the prism
Standard_Integer aNbGen = aMkPrism.Generated(aMkVert.Shape()).Extent();
EXPECT_EQ(aNbGen, 1);
// Check that Generated() returns 0 shapes for a vertex not used to create the prism
// (this should not crash)
Standard_Integer aNbDummy = aMkPrism.Generated(aMkDummy.Shape()).Extent();
EXPECT_EQ(aNbDummy, 0);
}

View File

@@ -2,4 +2,5 @@
set(OCCT_TKPrim_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKPrim_GTests_FILES
BRepPrimAPI_MakePrism_Test.cxx
)

View File

@@ -0,0 +1,71 @@
// 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 <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_ListOfShape.hxx>
#include <gp_Pnt.hxx>
#include <gtest/gtest.h>
TEST(BRepBuilderAPI_MakeWire_Test, OCC27552_AddEdgesAndListOfEdges)
{
// Bug OCC27552: Wire creation fails depending on the order of edges
// This test verifies that BRepBuilderAPI_MakeWire can successfully add
// edges individually and as a list
BRep_Builder aBB;
TopoDS_Vertex aV1, aV2, aV3;
TopoDS_Edge anE1, anE2;
// Create vertices
aBB.MakeVertex(aV1, gp_Pnt(0, 0, 0), 0.1);
aBB.MakeVertex(aV2, gp_Pnt(5, 0, 0), 0.1);
aBB.MakeVertex(aV3, gp_Pnt(10, 0, 0), 0.1);
// Create edges
anE1 = BRepBuilderAPI_MakeEdge(aV1, aV2).Edge();
anE2 = BRepBuilderAPI_MakeEdge(aV2, aV3).Edge();
// Build wire with individually added edges
BRepBuilderAPI_MakeWire aMW;
EXPECT_NO_THROW(aMW.Add(anE1));
EXPECT_NO_THROW(aMW.Add(anE2));
// Create additional vertices and edges for list test
TopoDS_Vertex aV4, aV5, aV6, aV7;
TopoDS_Edge anE3, anE4;
aBB.MakeVertex(aV4, gp_Pnt(10, 0.05, 0), 0.07);
aBB.MakeVertex(aV5, gp_Pnt(10, -0.05, 0), 0.07);
aBB.MakeVertex(aV6, gp_Pnt(10, 2, 0), 0.07);
aBB.MakeVertex(aV7, gp_Pnt(10, -2, 0), 0.07);
anE3 = BRepBuilderAPI_MakeEdge(aV4, aV6).Edge();
anE4 = BRepBuilderAPI_MakeEdge(aV5, aV7).Edge();
// Add edges as a list
TopTools_ListOfShape aListOfEdges;
aListOfEdges.Append(anE3);
aListOfEdges.Append(anE4);
EXPECT_NO_THROW(aMW.Add(aListOfEdges));
// Verify wire was created successfully
EXPECT_TRUE(aMW.IsDone()) << "Wire builder should complete successfully";
TopoDS_Wire aWire = aMW.Wire();
EXPECT_FALSE(aWire.IsNull()) << "Resulting wire should not be null";
}

View File

@@ -2,6 +2,7 @@
set(OCCT_TKTopAlgo_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKTopAlgo_GTests_FILES
BRepBuilderAPI_MakeWire_Test.cxx
BRepLib_MakeWire_Test.cxx
BRepOffsetAPI_ThruSections_Test.cxx
)