mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-06 04:37:42 +08:00
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:
@@ -0,0 +1,59 @@
|
||||
// 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 <BRepAdaptor_CompCurve.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
// Test OCC5696: BRepAdaptor_CompCurve::Edge() method
|
||||
// Migrated from QABugs_5.cxx
|
||||
TEST(BRepAdaptor_CompCurve_Test, OCC5696_EdgeMethod)
|
||||
{
|
||||
// Create a simple edge from two points
|
||||
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, 0), gp_Pnt(2, 0, 0));
|
||||
|
||||
// Create a wire from the edge
|
||||
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge);
|
||||
|
||||
// Create a composite curve adaptor
|
||||
BRepAdaptor_CompCurve aCurve(aWire);
|
||||
|
||||
// Get curve parameters
|
||||
Standard_Real aFirst = aCurve.FirstParameter();
|
||||
Standard_Real aLast = aCurve.LastParameter();
|
||||
Standard_Real aPar = (aFirst + aLast) / 2.0;
|
||||
|
||||
// Test the Edge() method
|
||||
Standard_Real aParEdge = 0.0;
|
||||
TopoDS_Edge anEdgeFound;
|
||||
|
||||
// The original test was checking that this method doesn't throw an exception
|
||||
// and returns valid parameter
|
||||
EXPECT_NO_THROW({ aCurve.Edge(aPar, anEdgeFound, aParEdge); })
|
||||
<< "Edge() method should not throw an exception";
|
||||
|
||||
// Verify that the returned edge is valid
|
||||
EXPECT_FALSE(anEdgeFound.IsNull()) << "Returned edge should not be null";
|
||||
|
||||
// Verify that the parameter is within valid range [0, edge length]
|
||||
EXPECT_GE(aParEdge, 0.0) << "Edge parameter should be non-negative";
|
||||
EXPECT_LE(aParEdge, 2.0) << "Edge parameter should not exceed edge length";
|
||||
|
||||
// The parameter should be approximately half of the edge length
|
||||
EXPECT_NEAR(1.0, aParEdge, 0.01) << "Edge parameter should be approximately 1.0";
|
||||
}
|
||||
@@ -2,4 +2,7 @@
|
||||
set(OCCT_TKBRep_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_TKBRep_GTests_FILES
|
||||
BRepAdaptor_CompCurve_Test.cxx
|
||||
TopoDS_Edge_Test.cxx
|
||||
TopoDS_Iterator_Test.cxx
|
||||
)
|
||||
|
||||
37
src/ModelingData/TKBRep/GTests/TopoDS_Edge_Test.cxx
Normal file
37
src/ModelingData/TKBRep/GTests/TopoDS_Edge_Test.cxx
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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 <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
||||
// Test BUC60828: TopoDS_Edge Infinite flag getter/setter
|
||||
// Migrated from QABugs_16.cxx
|
||||
TEST(TopoDS_Edge_Test, BUC60828_InfiniteFlag)
|
||||
{
|
||||
// Create a simple edge
|
||||
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0., 0., 0.), gp_Pnt(0., 0., 1.));
|
||||
|
||||
// Check initial flag value (should be false by default)
|
||||
Standard_Boolean anInitialValue = anEdge.Infinite();
|
||||
EXPECT_FALSE(anInitialValue) << "Initial Infinite flag should be false";
|
||||
|
||||
// Set the flag to true
|
||||
anEdge.Infinite(Standard_True);
|
||||
|
||||
// Verify the flag was set correctly
|
||||
Standard_Boolean aCurrentValue = anEdge.Infinite();
|
||||
EXPECT_TRUE(aCurrentValue) << "Infinite flag should be true after setting";
|
||||
}
|
||||
29
src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx
Normal file
29
src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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 <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(TopoDS_Iterator_Test, OCC30708_1_InitializeWithNullShape)
|
||||
{
|
||||
TopoDS_Iterator it;
|
||||
TopoDS_Shape empty;
|
||||
|
||||
// Should not throw exception when initializing with null shape
|
||||
EXPECT_NO_THROW(it.Initialize(empty));
|
||||
|
||||
// More() should return false on null shape
|
||||
EXPECT_FALSE(it.More());
|
||||
}
|
||||
Reference in New Issue
Block a user