From 895803a8cb9e4a8a8757088ad219f6eb9db3f197 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 29 Apr 2024 12:56:55 -0500 Subject: [PATCH 1/3] Toponaming: Enable FC_USE_TNP_FIX code --- .../FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake index fc734d5f84..39107344a0 100644 --- a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake +++ b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake @@ -90,4 +90,8 @@ macro(SetGlobalCompilerAndLinkerSettings) link_libraries(-lgdi32) endif() endif(MINGW) + + # Enable the Topological Naming Problem mitigation code + add_compile_options(-DFC_ENABLE_TNP_FIX) + endmacro(SetGlobalCompilerAndLinkerSettings) From 9bc5675ab3e731ad160ab5adf80dbc9dda6f88d7 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 30 Apr 2024 16:19:21 -0500 Subject: [PATCH 2/3] Correct flag --- cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake index 39107344a0..dc97e691f0 100644 --- a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake +++ b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake @@ -92,6 +92,6 @@ macro(SetGlobalCompilerAndLinkerSettings) endif(MINGW) # Enable the Topological Naming Problem mitigation code - add_compile_options(-DFC_ENABLE_TNP_FIX) + add_compile_options(-DFC_USE_TNP_FIX) endmacro(SetGlobalCompilerAndLinkerSettings) From f1690821a3bc433f789aa173bd17e2f872632a22 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 16 May 2024 13:42:53 -0400 Subject: [PATCH 3/3] Toponaming: Test fixes --- tests/CMakeLists.txt | 2 + tests/src/Mod/Material/App/TestMaterials.cpp | 2 + tests/src/Mod/Part/App/TopoShape.cpp | 61 ++++++++++++++----- tests/src/Mod/Part/App/TopoShapeExpansion.cpp | 1 + 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eb9d9cc7bb..b2db7ee0e8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,6 +28,8 @@ if(MSVC) endif() endif() +add_compile_options("-DFC_USE_TNP_FIX") + if(WIN32) add_definitions(-DCOIN_DLL -D_USE_MATH_DEFINES) endif(WIN32) diff --git a/tests/src/Mod/Material/App/TestMaterials.cpp b/tests/src/Mod/Material/App/TestMaterials.cpp index 7b0b42ae05..d8b9ccb1df 100644 --- a/tests/src/Mod/Material/App/TestMaterials.cpp +++ b/tests/src/Mod/Material/App/TestMaterials.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -55,6 +56,7 @@ class TestMaterial : public ::testing::Test { } void SetUp() override { + Base::Interpreter().runString("import Part"); _modelManager = new Materials::ModelManager(); _materialManager = new Materials::MaterialManager(); } diff --git a/tests/src/Mod/Part/App/TopoShape.cpp b/tests/src/Mod/Part/App/TopoShape.cpp index b7f7b754a8..75afcf1c99 100644 --- a/tests/src/Mod/Part/App/TopoShape.cpp +++ b/tests/src/Mod/Part/App/TopoShape.cpp @@ -3,93 +3,124 @@ #include "gtest/gtest.h" #include "PartTestHelpers.h" #include +#include "src/App/InitApplication.h" + + +class TopoShapeTest: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } + + void SetUp() override + { + Base::Interpreter().runString("import Part"); + _docName = App::GetApplication().getUniqueDocumentName("test"); + App::GetApplication().newDocument(_docName.c_str(), "testUser"); + _hasher = Base::Reference(new App::StringHasher); + ASSERT_EQ(_hasher.getRefCount(), 1); + } + + void TearDown() override + { + App::GetApplication().closeDocument(_docName.c_str()); + } + + +private: + std::string _docName; + Data::ElementIDRefs _sid; + App::StringHasherRef _hasher; +}; // clang-format off -TEST(TopoShape, TestElementTypeFace1) +TEST_F(TopoShapeTest, TestElementTypeFace1) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Face1"), std::make_pair(std::string("Face"), 1UL)); } -TEST(TopoShape, TestElementTypeEdge12) +TEST_F(TopoShapeTest, TestElementTypeEdge12) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Edge12"), std::make_pair(std::string("Edge"), 12UL)); } -TEST(TopoShape, TestElementTypeVertex3) +TEST_F(TopoShapeTest, TestElementTypeVertex3) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Vertex3"), std::make_pair(std::string("Vertex"), 3UL)); } -TEST(TopoShape, TestElementTypeFacer) +TEST_F(TopoShapeTest, TestElementTypeFacer) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Facer"), std::make_pair(std::string(), 0UL)); } -TEST(TopoShape, TestElementTypeVertex) +TEST_F(TopoShapeTest, TestElementTypeVertex) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Vertex"), std::make_pair(std::string(), 0UL)); } -TEST(TopoShape, TestElementTypeEmpty) +TEST_F(TopoShapeTest, TestElementTypeEmpty) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex(""), std::make_pair(std::string(), 0UL)); } -TEST(TopoShape, TestElementTypeNull) +TEST_F(TopoShapeTest, TestElementTypeNull) { EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex(nullptr), std::make_pair(std::string(), 0UL)); } -TEST(TopoShape, TestTypeFace1) +TEST_F(TopoShapeTest, TestTypeFace1) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex("Face1"), std::make_pair(std::string("Face"), 1UL)); } -TEST(TopoShape, TestTypeEdge12) +TEST_F(TopoShapeTest, TestTypeEdge12) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex("Edge12"), std::make_pair(std::string("Edge"), 12UL)); } -TEST(TopoShape, TestTypeVertex3) +TEST_F(TopoShapeTest, TestTypeVertex3) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex("Vertex3"), std::make_pair(std::string("Vertex"), 3UL)); } -TEST(TopoShape, TestTypeFacer) +TEST_F(TopoShapeTest, TestTypeFacer) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex("Facer"), std::make_pair(std::string("Facer"), 0UL)); } -TEST(TopoShape, TestTypeVertex) +TEST_F(TopoShapeTest, TestTypeVertex) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex("Vertex"), std::make_pair(std::string("Vertex"), 0UL)); } -TEST(TopoShape, TestTypeEmpty) +TEST_F(TopoShapeTest, TestTypeEmpty) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex(""), std::make_pair(std::string(), 0UL)); } -TEST(TopoShape, TestTypeNull) +TEST_F(TopoShapeTest, TestTypeNull) { EXPECT_EQ(Part::TopoShape::getTypeAndIndex(nullptr), std::make_pair(std::string(), 0UL)); } -TEST(TopoShape, TestGetSubshape) +TEST_F(TopoShapeTest, TestGetSubshape) { // Arrange auto [cube1, cube2] = PartTestHelpers::CreateTwoTopoShapeCubes(); diff --git a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp index 3230a490f2..33952c3e78 100644 --- a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp +++ b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp @@ -45,6 +45,7 @@ protected: void SetUp() override { + Base::Interpreter().runString("import Part"); _docName = App::GetApplication().getUniqueDocumentName("test"); App::GetApplication().newDocument(_docName.c_str(), "testUser"); _hasher = Base::Reference(new App::StringHasher);