From 7de5c8e6406baa5fe74087a91ddb54b6d1754608 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 20 Aug 2019 10:57:03 +0300 Subject: [PATCH] Improve code coverage metrics. --- src/Config/Config_FeatureMessage.cpp | 3 ++- .../FeaturesPlugin_MultiTranslation.cpp | 18 ++++++++++----- src/FiltersPlugin/Test/TestFilters.py | 4 ++-- src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp | 22 ------------------- .../GeomValidators_MinObjectsSelected.cpp | 2 +- src/ModelAPI/Test/TestFolder_Sketch.py | 4 ++++ 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/src/Config/Config_FeatureMessage.cpp b/src/Config/Config_FeatureMessage.cpp index fdc684cc3..47baeae2e 100644 --- a/src/Config/Config_FeatureMessage.cpp +++ b/src/Config/Config_FeatureMessage.cpp @@ -147,6 +147,7 @@ void Config_FeatureMessage::setPluginLibrary(const std::string& myPluginLibrary) this->myPluginLibrary = myPluginLibrary; } +// LCOV_EXCL_START bool Config_FeatureMessage::isUseInput() const { return myUseInput; @@ -176,7 +177,7 @@ bool Config_FeatureMessage::isApplyContinue() const { return myIsApplyContinue; } - +// LCOV_EXCL_STOP void Config_FeatureMessage::setUseInput(bool isUseInput) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp index b9af96713..10368e91e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp @@ -173,8 +173,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() } else { std::string anError; ListOfShape aListOfShape; - std::shared_ptr - aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList); + ListOfMakeShape aMakeShapeList; for (int i=0; i aTranslationAlgo( @@ -194,8 +193,12 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() break; } aListOfShape.push_back(aTranslationAlgo->shape()); - aListOfTranslationAlgo->appendAlgo(aTranslationAlgo); + aMakeShapeList.push_back(aTranslationAlgo); } + + std::shared_ptr + aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList(aMakeShapeList)); + std::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aListOfShape); ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); @@ -366,8 +369,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() } else { std::string anError; ListOfShape aListOfShape; - std::shared_ptr - aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList); + ListOfMakeShape aMakeShapeList; for (int j=0; jshape()); - aListOfTranslationAlgo->appendAlgo(aTranslationAlgo); + aMakeShapeList.push_back(aTranslationAlgo); } } + + std::shared_ptr + aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList(aMakeShapeList)); + std::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aListOfShape); ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); diff --git a/src/FiltersPlugin/Test/TestFilters.py b/src/FiltersPlugin/Test/TestFilters.py index c08497fe8..75b480faf 100644 --- a/src/FiltersPlugin/Test/TestFilters.py +++ b/src/FiltersPlugin/Test/TestFilters.py @@ -25,13 +25,13 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Bottom"), model.selection("FACE", "Box_1_1/Top"), model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = []), model.addFilter(name = "HorizontalFaces")])]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Bottom"), model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection("SOLID", "Box_1_1")]), model.addFilter(name = "HorizontalFaces"), model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "PartSet/XOY")])])]) model.end() aFactory = ModelAPI_Session.get().validators() GroupFeature = Group_1.feature() assert(aFactory.validate(GroupFeature)) -assert(GroupFeature.selectionList("group_list").size() == 2) +assert(GroupFeature.selectionList("group_list").size() == 1) assert(model.checkPythonDump()) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp index 264c6bd30..24fc81624 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp @@ -79,30 +79,8 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes) } //================================================================================================== -#include #include -typedef std::map MapFaceSolid; -static void facesBelongingToSolids(const GeomShapePtr& theShape, - MapFaceSolid& theShapeRelations) -{ - for (GeomAPI_ShapeExplorer aSolidExp(theShape, GeomAPI_Shape::SHELL); - aSolidExp.more(); aSolidExp.next()) { - GeomShapePtr aSolid = aSolidExp.current(); - for (GeomAPI_ShapeExplorer aFaceExp(aSolid, GeomAPI_Shape::FACE); - aFaceExp.more(); aFaceExp.next()) - theShapeRelations[aFaceExp.current()].push_back(aSolid); - } -} - -static bool isShapeInList(const GeomShapePtr& theShape, const ListOfShape& theList) -{ - for (ListOfShape::const_iterator anIt = theList.begin(); anIt != theList.end(); ++anIt) - if (theShape->isEqual(*anIt)) - return true; - return false; -} - void GeomAlgoAPI_Sewing::modified(const std::shared_ptr theShape, ListOfShape& theHistory) { diff --git a/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp b/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp index 56f93b2bf..ca3ebc7a2 100644 --- a/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp +++ b/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp @@ -52,7 +52,7 @@ bool GeomValidators_MinObjectsSelected::isValid(const std::shared_ptr