From dd507064b01bb8ef1ecbda1f1e8db75bdcc0547b Mon Sep 17 00:00:00 2001 From: Andreas Salzburger <Andreas.Salzburger@cern.ch> Date: Fri, 27 Mar 2020 11:27:54 +0100 Subject: [PATCH] fix wrong consistency checks --- Core/include/Acts/Geometry/CuboidVolumeBounds.hpp | 3 ++- .../Core/Geometry/CuboidVolumeBoundsTests.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp index 124d1b7d6..6e8f60f13 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp @@ -159,7 +159,8 @@ inline std::vector<double> CuboidVolumeBounds::values() const { } inline void CuboidVolumeBounds::checkConsistency() noexcept(false) { - if (get(eHalfLengthX) * get(eHalfLengthY) * get(eHalfLengthZ) <= 0.) { + if (get(eHalfLengthX) <= 0 or get(eHalfLengthY) <= 0 or + get(eHalfLengthZ) <= 0.) { throw std::invalid_argument( "CuboidVolumeBounds: invalid input, zero or negative."); } diff --git a/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp index b3b3da779..504f4373d 100644 --- a/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp @@ -47,12 +47,18 @@ BOOST_AUTO_TEST_CASE(CuboidVolumeRecreation) { BOOST_AUTO_TEST_CASE(CuboidVolumeException) { // Test exception negative x BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, hy, hz), std::logic_error); - // Test exception negative y BOOST_CHECK_THROW(CuboidVolumeBounds(hx, -hy, hz), std::logic_error); - // Test exception negative z BOOST_CHECK_THROW(CuboidVolumeBounds(hx, hy, -hz), std::logic_error); + // Other iterations 0 + BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, hy, -hz), std::logic_error); + // Other iterations 1 + BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, -hy, hz), std::logic_error); + // Other iterations 2 + BOOST_CHECK_THROW(CuboidVolumeBounds(hx, -hy, -hz), std::logic_error); + // Other iterations : all + BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, -hy, -hz), std::logic_error); } BOOST_AUTO_TEST_CASE(CuboidVolumeProperties) { -- GitLab