From f1690821a3bc433f789aa173bd17e2f872632a22 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 16 May 2024 13:42:53 -0400 Subject: [PATCH] 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);