From 4a1fccd1dfa5e62ebc7c47945d6c2060e50ff91d Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 18 Feb 2020 15:09:34 +0300 Subject: [PATCH] Adjust test according to new behavior --- src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp | 13 +++++++++++++ .../SHAPER/Transformations/TestAPI_MultiRotation.py | 4 ++-- test.API/SHAPER/Transformations/TestAPI_Rotation.py | 6 +++--- test.API/SHAPER/Transformations/TestAPI_Scale.py | 2 +- test.API/SHAPER/Transformations/TestAPI_Symmetry.py | 8 ++++---- test.API/SHAPER/Transformations/TestScale.py | 8 ++++---- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp index bde61cc26..8ebd28b10 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp @@ -28,6 +28,10 @@ GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr theSourceSha std::shared_ptr theCenterPoint, double theScaleFactor) { + if (!theCenterPoint) { + myError = "Scale builder :: center point is not valid."; + return; + } if (fabs(theScaleFactor) < Precision::Confusion()) { myError = "Scale builder :: the scale factor is null."; return; @@ -46,6 +50,10 @@ GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr theSourceSha double theScaleFactorY, double theScaleFactorZ) { + if (!theCenterPoint) { + myError = "Scale builder :: center point is not valid."; + return; + } if (fabs(theScaleFactorX) < Precision::Confusion()) { myError = "Scale builder :: the scale factor in X is null."; return; @@ -70,6 +78,11 @@ void GeomAlgoAPI_Scale::buildByDimensions(std::shared_ptr theSour double theScaleFactorY, double theScaleFactorZ) { + if (!theSourceShape) { + myError = "Scale builder :: source shape is not valid."; + return; + } + const gp_Pnt& aCenterPoint = theCenterPoint->impl(); // Perform the rotation matrix diff --git a/test.API/SHAPER/Transformations/TestAPI_MultiRotation.py b/test.API/SHAPER/Transformations/TestAPI_MultiRotation.py index f20b8b1a0..1c063206c 100644 --- a/test.API/SHAPER/Transformations/TestAPI_MultiRotation.py +++ b/test.API/SHAPER/Transformations/TestAPI_MultiRotation.py @@ -50,7 +50,7 @@ except myExcept as ec: try: MultiRotation_4 = shaperpy.makeMultiRotation(None, ax1, 45., 5) except myExcept as ec: - assert(ec.what() == "Rotation builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") try: MultiRotation_5 = shaperpy.makeMultiRotation(Box_4, None, 45., 5) @@ -67,7 +67,7 @@ except myExcept as ec: try: MultiRotation_8 = shaperpy.makeMultiRotation(None, ax1, 5) except myExcept as ec: - assert(ec.what() == "Rotation builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") try: MultiRotation_9 = shaperpy.makeMultiRotation(Box_7, None, 5) diff --git a/test.API/SHAPER/Transformations/TestAPI_Rotation.py b/test.API/SHAPER/Transformations/TestAPI_Rotation.py index 3ebc9248f..87632169e 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Rotation.py +++ b/test.API/SHAPER/Transformations/TestAPI_Rotation.py @@ -74,7 +74,7 @@ except myExcept as ec: try: Rotation_8 = shaperpy.makeRotation(None, ax1, 180) except myExcept as ec: - assert(ec.what() == "Rotation builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") Rotation_9 = shaperpy.makeRotation(Box_8, pntOrigin, pnt1, pnt2) Rotation_10 = shaperpy.makeRotation(Box_9, pnt3, pnt1, pnt2) @@ -112,9 +112,9 @@ except myExcept as ec: try: Rotation_17 = shaperpy.makeRotation(None, pntOrigin, pnt3, pnt2) except myExcept as ec: - assert(ec.what() == "Rotation builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") try: Rotation_18 = shaperpy.makeRotation(shape(), ax1, 450) except myExcept as ec: - assert(ec.what() == "Rotation builder :: source shape does not contain any actual shape.") + assert(ec.what() == "Transformation :: source shape does not contain any actual shape.") diff --git a/test.API/SHAPER/Transformations/TestAPI_Scale.py b/test.API/SHAPER/Transformations/TestAPI_Scale.py index bc2c41a7f..be3c60f4f 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Scale.py +++ b/test.API/SHAPER/Transformations/TestAPI_Scale.py @@ -86,7 +86,7 @@ except myExcept as ec : try : Scale_20 = shaperpy.makeScale(shape(), pntOrigin, 2.) except myExcept as ec : - assert(ec.what() == "Scale builder :: source shape does not contain any actual shape.") + assert(ec.what() == "Transformation :: source shape does not contain any actual shape.") try : Scale_21 = shaperpy.makeScale(shape(), pntOrigin, 2., 3., 1.) diff --git a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py index 3c50f4298..1b321cfd8 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py +++ b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py @@ -74,19 +74,19 @@ Symmetry_6 = shaperpy.makeSymmetry(Box_6, planeXOY) try : Symmetry_7 = shaperpy.makeSymmetry(None, pnt1) except myExcept as ec : - assert(ec.what() == "Symmetry builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") try : Symmetry_8 = shaperpy.makeSymmetry(None, axZ) except myExcept as ec : - assert(ec.what() == "Symmetry builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") try : Symmetry_9 = shaperpy.makeSymmetry(None, planeXOY) except myExcept as ec : - assert(ec.what() == "Symmetry builder :: source shape is not valid.") + assert(ec.what() == "Transformation :: incorrect input data.") try : Symmetry_10 = shaperpy.makeSymmetry(shape(), pnt1) except myExcept as ec : - assert(ec.what() == "Symmetry builder :: source shape does not contain any actual shape.") + assert(ec.what() == "Transformation :: source shape does not contain any actual shape.") diff --git a/test.API/SHAPER/Transformations/TestScale.py b/test.API/SHAPER/Transformations/TestScale.py index 55fe459ab..edddcdc28 100644 --- a/test.API/SHAPER/Transformations/TestScale.py +++ b/test.API/SHAPER/Transformations/TestScale.py @@ -177,19 +177,19 @@ model.testHaveNamingFaces(Scale_17, model, Part_1_doc) model.testNbResults(Scale_6, 0) -assert(Scale_6.feature().error() == 'Scale builder :: the scale factor is null.') +assert(Scale_6.feature().error() == 'Error: Scale algorithm failed. Scale builder :: the scale factor is null.') model.testNbResults(Scale_8, 0) assert(Scale_8.feature().error() == 'Attribute "center_point" is not initialized.') model.testNbResults(Scale_14, 0) -assert(Scale_14.feature().error() == 'Scale builder :: the scale factor in X is null.') +assert(Scale_14.feature().error() == 'Error: Scale algorithm failed. Scale builder :: the scale factor in X is null.') model.testNbResults(Scale_15, 0) -assert(Scale_15.feature().error() == 'Scale builder :: the scale factor in Y is null.') +assert(Scale_15.feature().error() == 'Error: Scale algorithm failed. Scale builder :: the scale factor in Y is null.') model.testNbResults(Scale_16, 0) -assert(Scale_16.feature().error() == 'Scale builder :: the scale factor in Z is null.') +assert(Scale_16.feature().error() == 'Error: Scale algorithm failed. Scale builder :: the scale factor in Z is null.') model.testNbResults(Scale_18, 0) assert(Scale_18.feature().error() == 'Attribute "center_point" is not initialized.') -- 2.39.2