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
@@ -2,4 +2,8 @@
set(OCCT_TKLCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKLCAF_GTests_FILES
TDataStd_Attribute_Test.cxx
TDataStd_TreeNode_Test.cxx
TNaming_Builder_Test.cxx
TNaming_Name_Test.cxx
)
@@ -0,0 +1,109 @@
// 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 <TDataStd_AsciiString.hxx>
#include <TDataStd_BooleanArray.hxx>
#include <TDataStd_BooleanList.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_ExtStringArray.hxx>
#include <TDataStd_ExtStringList.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_IntegerList.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_RealList.hxx>
#include <TDataStd_ReferenceArray.hxx>
#include <TDataStd_ReferenceList.hxx>
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <Standard_GUID.hxx>
#include <gtest/gtest.h>
TEST(TDataStd_Attribute_Test, OCC29371_AttributeGUIDsNotNull)
{
// Create document and label
Handle(TDocStd_Application) anApp = new TDocStd_Application();
Handle(TDocStd_Document) aDoc;
anApp->NewDocument("BinOcaf", aDoc);
TDF_Label aLab = aDoc->Main();
// Null GUID for comparison
Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000");
// Test each TDataStd attribute type has non-null GUID
Handle(TDataStd_AsciiString) aStrAtt = new TDataStd_AsciiString();
aLab.AddAttribute(aStrAtt);
EXPECT_NE(aNullGuid, aStrAtt->ID());
Handle(TDataStd_BooleanArray) aBArAtt = new TDataStd_BooleanArray();
aLab.AddAttribute(aBArAtt);
EXPECT_NE(aNullGuid, aBArAtt->ID());
Handle(TDataStd_BooleanList) aBListAtt = new TDataStd_BooleanList();
aLab.AddAttribute(aBListAtt);
EXPECT_NE(aNullGuid, aBListAtt->ID());
Handle(TDataStd_ByteArray) aByteArAtt = new TDataStd_ByteArray();
aLab.AddAttribute(aByteArAtt);
EXPECT_NE(aNullGuid, aByteArAtt->ID());
Handle(TDataStd_ExtStringArray) anExtStrArAtt = new TDataStd_ExtStringArray();
aLab.AddAttribute(anExtStrArAtt);
EXPECT_NE(aNullGuid, anExtStrArAtt->ID());
Handle(TDataStd_ExtStringList) anExtStrListAtt = new TDataStd_ExtStringList();
aLab.AddAttribute(anExtStrListAtt);
EXPECT_NE(aNullGuid, anExtStrListAtt->ID());
Handle(TDataStd_Integer) anIntAtt = new TDataStd_Integer();
aLab.AddAttribute(anIntAtt);
EXPECT_NE(aNullGuid, anIntAtt->ID());
Handle(TDataStd_IntegerArray) anIntArrAtt = new TDataStd_IntegerArray();
aLab.AddAttribute(anIntArrAtt);
EXPECT_NE(aNullGuid, anIntArrAtt->ID());
Handle(TDataStd_IntegerList) anIntListAtt = new TDataStd_IntegerList();
aLab.AddAttribute(anIntListAtt);
EXPECT_NE(aNullGuid, anIntListAtt->ID());
Handle(TDataStd_Name) aNameAtt = new TDataStd_Name();
aLab.AddAttribute(aNameAtt);
EXPECT_NE(aNullGuid, aNameAtt->ID());
Handle(TDataStd_Real) aRealAtt = new TDataStd_Real();
aLab.AddAttribute(aRealAtt);
EXPECT_NE(aNullGuid, aRealAtt->ID());
Handle(TDataStd_RealArray) aRealArrAtt = new TDataStd_RealArray();
aLab.AddAttribute(aRealArrAtt);
EXPECT_NE(aNullGuid, aRealArrAtt->ID());
Handle(TDataStd_RealList) aRealListAtt = new TDataStd_RealList();
aLab.AddAttribute(aRealListAtt);
EXPECT_NE(aNullGuid, aRealListAtt->ID());
Handle(TDataStd_ReferenceArray) aRefArrAtt = new TDataStd_ReferenceArray();
aLab.AddAttribute(aRefArrAtt);
EXPECT_NE(aNullGuid, aRefArrAtt->ID());
Handle(TDataStd_ReferenceList) aRefListAtt = new TDataStd_ReferenceList();
aLab.AddAttribute(aRefListAtt);
EXPECT_NE(aNullGuid, aRefListAtt->ID());
anApp->Close(aDoc);
}
@@ -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 <gtest/gtest.h>
#include <TDataStd_TreeNode.hxx>
#include <TDF_Data.hxx>
#include <TDF_Label.hxx>
// Test BUC60817: TDataStd_TreeNode descendant relationship
TEST(TDataStd_TreeNode_Test, BUC60817_DescendantRelationship)
{
// Create TDF document
Handle(TDF_Data) aDF = new TDF_Data();
// Create two labels
TDF_Label aLabel1 = aDF->Root().FindChild(2, Standard_True);
TDF_Label aLabel2 = aDF->Root().FindChild(3, Standard_True);
// Create TreeNodes on the labels
Handle(TDataStd_TreeNode) aTN1 = TDataStd_TreeNode::Set(aLabel1);
Handle(TDataStd_TreeNode) aTN2 = TDataStd_TreeNode::Set(aLabel2);
// Append TN2 as a child of TN1
aTN1->Append(aTN2);
// Verify that TN2 is a descendant of TN1
EXPECT_TRUE(aTN2->IsDescendant(aTN1)) << "TN2 should be a descendant of TN1 after Append";
// Verify that TN1 is NOT a descendant of TN2
EXPECT_FALSE(aTN1->IsDescendant(aTN2)) << "TN1 should not be a descendant of TN2";
}
@@ -0,0 +1,57 @@
// 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 <BRepPrimAPI_MakeBox.hxx>
#include <TDocStd_Document.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TopoDS_Shape.hxx>
#include <gp_Pnt.hxx>
// Test OCC361bug: TNaming_Builder preservation of shape orientation
TEST(TNaming_Builder_Test, OCC361_ShapeOrientationPreservation)
{
// Create a document
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinOcaf");
// Create a box shape
BRepPrimAPI_MakeBox aBoxMaker(gp_Pnt(0, 0, 0), 100, 100, 100);
TopoDS_Shape aBox = aBoxMaker.Shape();
aBox.Orientation(TopAbs_FORWARD);
// Get the main label
TDF_Label aTestLabel = aDoc->Main();
// Create a TNaming_Builder and add the shape
TNaming_Builder aBuilder(aTestLabel);
aBuilder.Generated(aBox);
// Create a copy with REVERSED orientation
TopoDS_Shape aBox1 = aBox;
aBox1.Orientation(TopAbs_REVERSED);
// Clear all attributes from the label
aTestLabel.ForgetAllAttributes();
// Create a new builder with the reversed shape
TNaming_Builder aBuilder2(aTestLabel);
aBuilder2.Generated(aBox1);
// Get the shape from the builder and verify orientation
aBox = aBuilder2.NamedShape()->Get();
EXPECT_EQ(TopAbs_REVERSED, aBox.Orientation())
<< "Shape orientation should be preserved as REVERSED after TNaming_Builder operations";
}
@@ -0,0 +1,47 @@
// 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 <TDF_Data.hxx>
#include <TDF_Label.hxx>
#include <TDF_LabelMap.hxx>
#include <TNaming_Name.hxx>
#include <TNaming_NamedShape.hxx>
// Test BUC60925: TNaming_Name solve with empty NamedShape
TEST(TNaming_Name_Test, BUC60925_SolveWithEmptyNamedShape)
{
// Create TDF document
Handle(TDF_Data) aDF = new TDF_Data();
// Create a label
TDF_Label aLabel = aDF->Root().FindChild(2, Standard_True);
// Create label map
TDF_LabelMap aLabelMap;
aLabelMap.Add(aLabel);
// Create an empty NamedShape
Handle(TNaming_NamedShape) aNS = new TNaming_NamedShape;
// Create TNaming_Name and configure it
TNaming_Name aNN;
aNN.Type(TNaming_IDENTITY);
aNN.Append(aNS);
// Test that Solve returns false for empty NamedShape
Standard_Boolean aResult = aNN.Solve(aLabel, aLabelMap);
EXPECT_FALSE(aResult) << "Solve should return false for empty NamedShape";
}