From 6339a313040360f6bb16c867b23ce4a72b5c0fb3 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Sat, 3 Oct 2020 13:00:50 +0200 Subject: [PATCH] size()==0 -> empty, as recommended by clang-tidy --- Core/Computation/ProcessedSample.cpp | 5 +-- Core/Detector/DetectorMask.cpp | 2 +- Core/Export/OrderedMap.h | 5 +-- Core/Export/SampleToPython.cpp | 34 +++++++++---------- Core/Export/SimulationToPython.cpp | 2 +- Core/Fitting/SimDataPair.cpp | 16 ++++----- .../FormFactorEllipsoidalCylinder.cpp | 3 +- Core/HardParticle/FormFactorFullSpheroid.cpp | 3 +- Core/HardParticle/FormFactorHemiEllipsoid.cpp | 3 +- Core/Instrument/SimulationResult.h | 1 + Core/Intensity/IntensityDataFunctions.cpp | 2 +- .../IInterferenceFunctionStrategy.cpp | 2 +- Core/Parametrization/IParameterized.cpp | 2 +- Core/Parametrization/ParameterPool.h | 1 + Core/Particle/FormFactorWeighted.cpp | 4 +-- Core/Particle/ParticleComposition.cpp | 2 +- Core/Simulation/DepthProbeSimulation.cpp | 6 ++-- Core/Simulation/Simulation.cpp | 2 +- Fit/Minimizer/MinimizerOptions.cpp | 2 +- Fit/RootAdapter/MinimizerResultUtils.cpp | 4 +-- Fit/RootAdapter/ResidualFunctionAdapter.cpp | 2 +- Fit/RootAdapter/ScalarFunctionAdapter.cpp | 3 +- Fit/Tools/OptionContainer.h | 1 + GUI/coregui/Models/ComboProperty.cpp | 4 +-- GUI/coregui/Models/DomainObjectBuilder.cpp | 2 +- GUI/coregui/Models/FitParameterItems.cpp | 2 +- GUI/coregui/Models/ModelMapper.h | 7 ++-- .../Models/ParticleDistributionItem.cpp | 4 +-- .../CommonWidgets/ItemSelectorWidget.cpp | 2 +- .../Views/CommonWidgets/ItemStackPresenter.h | 2 +- .../Views/FitWidgets/FitSessionController.cpp | 2 +- .../Views/JobWidgets/JobSelectorActions.cpp | 2 +- .../MaskWidgets/MaskEditorPropertyPanel.cpp | 4 +-- .../PropertyEditor/TestComponentView.cpp | 2 +- .../RealSpaceWidgets/RealSpaceCanvas.cpp | 2 +- .../Views/SampleDesigner/DesignerMimeData.cpp | 2 +- .../Views/SampleDesigner/ILayerView.cpp | 2 +- .../Views/SampleDesigner/MultiLayerView.cpp | 4 +-- .../SampleDesigner/SamplePropertyWidget.cpp | 2 +- GUI/main/MessageHandler.cpp | 2 +- .../GUI/Translate/GUITranslationTest.cpp | 2 +- .../UnitTests/GUI/TestComponentProxyModel.cpp | 12 +++---- Tests/UnitTests/GUI/TestExternalProperty.cpp | 16 ++++----- Tests/UnitTests/GUI/TestGroupItem.cpp | 2 +- Tests/UnitTests/GUI/TestMapperCases.cpp | 6 ++-- Tests/UnitTests/GUI/TestMaterialModel.cpp | 2 +- .../GUI/TestMaterialPropertyController.cpp | 2 +- .../UnitTests/GUI/TestOutputDataIOService.cpp | 24 ++++++------- Tests/UnitTests/GUI/TestParticleCoreShell.cpp | 2 +- Tests/UnitTests/GUI/TestParticleItem.cpp | 6 ++-- Tests/UnitTests/GUI/TestProjectDocument.cpp | 4 +-- Tests/UnitTests/GUI/TestProjectUtils.cpp | 6 ++-- .../UnitTests/GUI/TestProxyModelStrategy.cpp | 6 ++-- Tests/UnitTests/GUI/TestSessionItem.cpp | 2 +- 54 files changed, 127 insertions(+), 119 deletions(-) diff --git a/Core/Computation/ProcessedSample.cpp b/Core/Computation/ProcessedSample.cpp index 96558ca0b75..1625fc6b5f1 100644 --- a/Core/Computation/ProcessedSample.cpp +++ b/Core/Computation/ProcessedSample.cpp @@ -248,7 +248,7 @@ void ProcessedSample::addNSlices(size_t n, double thickness, const Material& mat void ProcessedSample::initBFields() { - if (m_slices.size() == 0) + if (m_slices.empty()) return; double m_z0 = m_slices[0].material().magnetization().z(); double b_z = Slice::Magnetic_Permeability * (m_ext_field.z() + m_z0); @@ -286,7 +286,8 @@ std::unique_ptr<IFresnelMap> CreateFresnelMap(const MultiLayer& sample, if (ContainsMagneticSlice(slices)) P_result = std::make_unique<MatrixFresnelMap>(SpecularStrategyBuilder::build(sample, true)); else - P_result = std::make_unique<ScalarFresnelMap>(SpecularStrategyBuilder::build(sample, false)); + P_result = + std::make_unique<ScalarFresnelMap>(SpecularStrategyBuilder::build(sample, false)); if (options.isIntegrate()) P_result->disableCaching(); return P_result; diff --git a/Core/Detector/DetectorMask.cpp b/Core/Detector/DetectorMask.cpp index ed415dfe420..3b6979d5c2b 100644 --- a/Core/Detector/DetectorMask.cpp +++ b/Core/Detector/DetectorMask.cpp @@ -111,7 +111,7 @@ const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value) void DetectorMask::process_masks() { m_mask_data.setAllTo(false); - if (!m_shapes.size()) + if (!!m_shapes.empty()) return; m_number_of_masked_channels = 0; diff --git a/Core/Export/OrderedMap.h b/Core/Export/OrderedMap.h index 616a930c708..7f3c2e4ab12 100644 --- a/Core/Export/OrderedMap.h +++ b/Core/Export/OrderedMap.h @@ -48,11 +48,12 @@ public: iterator begin() { return m_list.begin(); } iterator end() { return m_list.end(); } - size_t size() + size_t size() const { ASSERT(m_list.size() == m_map.size()); return m_list.size(); } + bool empty() const { return size() == 0; } // if such key exists, pair will be deleted, and new pair appended to the end void insert(const Key& key, const Object& object) @@ -91,7 +92,7 @@ public: return 1; } - const Object& value(const Key& key) + const Object& value(const Key& key) const { typename map_t::const_iterator mit = m_map.find(key); if (mit == m_map.end()) { diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index 6c09f74d190..77d98fcb9fd 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -100,8 +100,8 @@ const std::map<MATERIAL_TYPES, std::string> factory_names{ std::string SampleToPython::defineMaterials() const { - const auto themap = m_label->materialMap(); - if (themap->size() == 0) + const LabelMap<const Material*>* themap = m_label->materialMap(); + if (themap->empty()) return "# No Materials.\n\n"; std::ostringstream result; result << std::setprecision(12); @@ -139,7 +139,7 @@ std::string SampleToPython::defineMaterials() const std::string SampleToPython::defineLayers() const { const auto themap = m_label->layerMap(); - if (themap->size() == 0) + if (themap->empty()) return "# No Layers.\n\n"; std::ostringstream result; result << std::setprecision(12); @@ -161,7 +161,7 @@ std::string SampleToPython::defineLayers() const std::string SampleToPython::defineFormFactors() const { const auto themap = m_label->formFactorMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -177,7 +177,7 @@ std::string SampleToPython::defineFormFactors() const std::string SampleToPython::defineParticles() const { const auto themap = m_label->particleMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -200,7 +200,7 @@ std::string SampleToPython::defineParticles() const std::string SampleToPython::defineCoreShellParticles() const { const auto themap = m_label->particleCoreShellMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -221,7 +221,7 @@ std::string SampleToPython::defineCoreShellParticles() const std::string SampleToPython::defineParticleDistributions() const { const auto themap = m_label->particleDistributionsMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; @@ -249,7 +249,7 @@ std::string SampleToPython::defineParticleDistributions() const // linked parameters std::vector<std::string> linked_pars = par_distr.getLinkedParameterNames(); - if (linked_pars.size()) { + if (!linked_pars.empty()) { result << indent() << s_par_distr; for (size_t i = 0; i < linked_pars.size(); ++i) result << ".linkParameter(\"" << linked_pars[i] << "\")"; @@ -269,7 +269,7 @@ std::string SampleToPython::defineParticleDistributions() const std::string SampleToPython::defineParticleCompositions() const { const auto themap = m_label->particleCompositionMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -292,7 +292,7 @@ std::string SampleToPython::defineParticleCompositions() const std::string SampleToPython::defineLattices() const { const auto themap = m_label->latticeMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -317,7 +317,7 @@ std::string SampleToPython::defineLattices() const std::string SampleToPython::defineCrystals() const { const auto themap = m_label->crystalMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -339,7 +339,7 @@ std::string SampleToPython::defineCrystals() const std::string SampleToPython::defineMesoCrystals() const { const auto themap = m_label->mesocrystalMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -363,7 +363,7 @@ std::string SampleToPython::defineMesoCrystals() const std::string SampleToPython::defineInterferenceFunctions() const { const auto themap = m_label->interferenceFunctionMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -486,7 +486,7 @@ std::string SampleToPython::defineInterferenceFunctions() const std::string SampleToPython::defineParticleLayouts() const { const auto themap = m_label->particleLayoutMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -517,7 +517,7 @@ std::string SampleToPython::defineParticleLayouts() const std::string SampleToPython::defineRoughnesses() const { const auto themap = m_label->layerRoughnessMap(); - if (themap->size() == 0) + if (themap->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -530,7 +530,7 @@ std::string SampleToPython::defineRoughnesses() const std::string SampleToPython::addLayoutsToLayers() const { - if (m_label->particleLayoutMap()->size() == 0) + if (m_label->particleLayoutMap()->empty()) return ""; std::ostringstream result; result << std::setprecision(12); @@ -549,7 +549,7 @@ std::string SampleToPython::addLayoutsToLayers() const std::string SampleToPython::defineMultiLayers() const { const auto themap = m_label->multiLayerMap(); - if (themap->size() == 0) + if (themap->empty()) return "# No MultiLayers.\n\n"; std::ostringstream result; result << std::setprecision(12); diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index fb39ce7bb34..5275186e248 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -333,7 +333,7 @@ std::string SimulationToPython::defineParameterDistributions(const Simulation* s std::ostringstream result; const std::vector<ParameterDistribution>& distributions = simulation->getDistributionHandler().getDistributions(); - if (distributions.size() == 0) + if (distributions.empty()) return ""; for (size_t i = 0; i < distributions.size(); ++i) { std::string main_par_name = distributions[i].getMainParameterName(); diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp index ed6738ca6b7..395b1151a22 100644 --- a/Core/Fitting/SimDataPair.cpp +++ b/Core/Fitting/SimDataPair.cpp @@ -91,21 +91,21 @@ size_t SimDataPair::numberOfFitElements() const SimulationResult SimDataPair::simulationResult() const { - if (m_sim_data.size() == 0) + if (m_sim_data.empty()) throwInitializationException("simulationResult"); return m_sim_data; } SimulationResult SimDataPair::experimentalData() const { - if (m_exp_data.size() == 0) + if (m_exp_data.empty()) throwInitializationException("experimentalData"); return m_exp_data; } SimulationResult SimDataPair::uncertainties() const { - if (m_uncertainties.size() == 0) + if (m_uncertainties.empty()) throwInitializationException("uncertainties"); return m_uncertainties; } @@ -113,7 +113,7 @@ SimulationResult SimDataPair::uncertainties() const //! Returns the user uncertainties cut to the ROI area. SimulationResult SimDataPair::userWeights() const { - if (m_user_weights.size() == 0) + if (m_user_weights.empty()) throwInitializationException("userWeights"); return m_user_weights; } @@ -146,28 +146,28 @@ SimulationResult SimDataPair::absoluteDifference() const std::vector<double> SimDataPair::experimental_array() const { - if (m_exp_data.size() == 0) + if (m_exp_data.empty()) throwInitializationException("experimental_array"); return m_exp_data.data()->getRawDataVector(); } std::vector<double> SimDataPair::simulation_array() const { - if (m_sim_data.size() == 0) + if (m_sim_data.empty()) throwInitializationException("simulation_array"); return m_sim_data.data()->getRawDataVector(); } std::vector<double> SimDataPair::uncertainties_array() const { - if (m_uncertainties.size() == 0) + if (m_uncertainties.empty()) throwInitializationException("uncertainties_array"); return m_uncertainties.data()->getRawDataVector(); } std::vector<double> SimDataPair::user_weights_array() const { - if (m_user_weights.size() == 0) + if (m_user_weights.empty()) throwInitializationException("user_weights_array"); return m_user_weights.data()->getRawDataVector(); } diff --git a/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp b/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp index 3781743237c..cded89c4ee5 100644 --- a/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp +++ b/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp @@ -68,5 +68,6 @@ IFormFactor* FormFactorEllipsoidalCylinder::sliceFormFactor(ZLimits limits, cons void FormFactorEllipsoidalCylinder::onChange() { - mP_shape = std::make_unique<DoubleEllipse>(m_radius_x, m_radius_y, m_height, m_radius_x, m_radius_y); + mP_shape = + std::make_unique<DoubleEllipse>(m_radius_x, m_radius_y, m_height, m_radius_x, m_radius_y); } diff --git a/Core/HardParticle/FormFactorFullSpheroid.cpp b/Core/HardParticle/FormFactorFullSpheroid.cpp index 88133ae8eb7..e6dc0f48adc 100644 --- a/Core/HardParticle/FormFactorFullSpheroid.cpp +++ b/Core/HardParticle/FormFactorFullSpheroid.cpp @@ -68,5 +68,6 @@ IFormFactor* FormFactorFullSpheroid::sliceFormFactor(ZLimits limits, const IRota void FormFactorFullSpheroid::onChange() { - mP_shape = std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_height / 2.0, m_height, 0.0); + mP_shape = + std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_height / 2.0, m_height, 0.0); } diff --git a/Core/HardParticle/FormFactorHemiEllipsoid.cpp b/Core/HardParticle/FormFactorHemiEllipsoid.cpp index 759c1fee46c..1cac04558eb 100644 --- a/Core/HardParticle/FormFactorHemiEllipsoid.cpp +++ b/Core/HardParticle/FormFactorHemiEllipsoid.cpp @@ -78,5 +78,6 @@ complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const void FormFactorHemiEllipsoid::onChange() { - mP_shape = std::make_unique<TruncatedEllipsoid>(m_radius_x, m_radius_x, m_height, m_height, 0.0); + mP_shape = + std::make_unique<TruncatedEllipsoid>(m_radius_x, m_radius_x, m_height, m_height, 0.0); } diff --git a/Core/Instrument/SimulationResult.h b/Core/Instrument/SimulationResult.h index e634e5a6387..2177126729f 100644 --- a/Core/Instrument/SimulationResult.h +++ b/Core/Instrument/SimulationResult.h @@ -64,6 +64,7 @@ public: double& operator[](size_t i); const double& operator[](size_t i) const; size_t size() const; + bool empty() const { return size() == 0; } //! returns intensity data as Python numpy array #ifdef BORNAGAIN_PYTHON diff --git a/Core/Intensity/IntensityDataFunctions.cpp b/Core/Intensity/IntensityDataFunctions.cpp index 79e8583cf2f..24e7fa011cc 100644 --- a/Core/Intensity/IntensityDataFunctions.cpp +++ b/Core/Intensity/IntensityDataFunctions.cpp @@ -32,7 +32,7 @@ double IntensityDataFunctions::RelativeDifference(const SimulationResult& dat, if (dat.size() != ref.size()) throw std::runtime_error("Error in IntensityDataFunctions::RelativeDifference: " "different number of elements"); - if (dat.size() == 0) + if (dat.empty()) return 0.0; double sum_of_diff = 0.0; for (size_t i = 0; i < dat.size(); ++i) { diff --git a/Core/Multilayer/IInterferenceFunctionStrategy.cpp b/Core/Multilayer/IInterferenceFunctionStrategy.cpp index 96277e44db9..704419b984b 100644 --- a/Core/Multilayer/IInterferenceFunctionStrategy.cpp +++ b/Core/Multilayer/IInterferenceFunctionStrategy.cpp @@ -33,7 +33,7 @@ void IInterferenceFunctionStrategy::init( const std::vector<FormFactorCoherentSum>& weighted_formfactors, const IInterferenceFunction* p_iff) { - if (weighted_formfactors.size() == 0) + if (weighted_formfactors.empty()) throw Exceptions::ClassInitializationException( "IInterferenceFunctionStrategy::init: strategy gets no form factors."); m_formfactor_wrappers = weighted_formfactors; diff --git a/Core/Parametrization/IParameterized.cpp b/Core/Parametrization/IParameterized.cpp index 82e67b66b50..f0a034ae8a3 100644 --- a/Core/Parametrization/IParameterized.cpp +++ b/Core/Parametrization/IParameterized.cpp @@ -25,7 +25,7 @@ IParameterized::IParameterized(const std::string& name) : m_name{name}, m_pool{n IParameterized::IParameterized(const IParameterized& other) : IParameterized(other.getName()) { - if (other.parameterPool()->size()) + if (!other.parameterPool()->empty()) throw std::runtime_error("BUG: not prepared to copy parameters of " + getName()); } diff --git a/Core/Parametrization/ParameterPool.h b/Core/Parametrization/ParameterPool.h index 97988e29b54..0ffc380d9b3 100644 --- a/Core/Parametrization/ParameterPool.h +++ b/Core/Parametrization/ParameterPool.h @@ -40,6 +40,7 @@ public: //! Returns number of parameters in the pool. size_t size() const { return m_params.size(); } + bool empty() const { return size() == 0; } RealParameter& addParameter(RealParameter* newPar); diff --git a/Core/Particle/FormFactorWeighted.cpp b/Core/Particle/FormFactorWeighted.cpp index 71c192bffc1..defc4782d30 100644 --- a/Core/Particle/FormFactorWeighted.cpp +++ b/Core/Particle/FormFactorWeighted.cpp @@ -44,7 +44,7 @@ double FormFactorWeighted::radialExtension() const double FormFactorWeighted::bottomZ(const IRotation& rotation) const { - if (m_form_factors.size() == 0) + if (m_form_factors.empty()) throw std::runtime_error("FormFactorWeighted::bottomZ() -> Error: " "'this' contains no form factors."); return algo::min_value(m_form_factors.begin(), m_form_factors.end(), @@ -53,7 +53,7 @@ double FormFactorWeighted::bottomZ(const IRotation& rotation) const double FormFactorWeighted::topZ(const IRotation& rotation) const { - if (m_form_factors.size() == 0) + if (m_form_factors.empty()) throw std::runtime_error("FormFactorWeighted::topZ() -> Error: " "'this' contains no form factors."); return algo::max_value(m_form_factors.begin(), m_form_factors.end(), diff --git a/Core/Particle/ParticleComposition.cpp b/Core/Particle/ParticleComposition.cpp index 4f73a415a2b..053ee5dfe97 100644 --- a/Core/Particle/ParticleComposition.cpp +++ b/Core/Particle/ParticleComposition.cpp @@ -45,7 +45,7 @@ ParticleComposition* ParticleComposition::clone() const IFormFactor* ParticleComposition::createFormFactor() const { - if (m_particles.size() == 0) + if (m_particles.empty()) return {}; std::unique_ptr<FormFactorWeighted> P_result{new FormFactorWeighted()}; auto particles = decompose(); diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp index b65d7e4de0d..d14f5945a4b 100644 --- a/Core/Simulation/DepthProbeSimulation.cpp +++ b/Core/Simulation/DepthProbeSimulation.cpp @@ -13,6 +13,7 @@ // ************************************************************************** // #include "Core/Simulation/DepthProbeSimulation.h" +#include "Core/Basics/Assert.h" #include "Core/Basics/MathConstants.h" #include "Core/Beam/IFootprintFactor.h" #include "Core/Computation/DepthProbeComputation.h" @@ -109,9 +110,8 @@ DepthProbeSimulation::DepthProbeSimulation(const DepthProbeSimulation& other) m_alpha_axis.reset(other.m_alpha_axis->clone()); if (other.m_z_axis) m_z_axis.reset(other.m_z_axis->clone()); - if (!m_sim_elements.empty()) - for (auto iter = m_sim_elements.begin(); iter != m_sim_elements.end(); ++iter) - iter->setZPositions(m_alpha_axis.get()); + for (auto iter = m_sim_elements.begin(); iter != m_sim_elements.end(); ++iter) + iter->setZPositions(m_alpha_axis.get()); initialize(); } diff --git a/Core/Simulation/Simulation.cpp b/Core/Simulation/Simulation.cpp index 198a9f09516..ba74ed9745e 100644 --- a/Core/Simulation/Simulation.cpp +++ b/Core/Simulation/Simulation.cpp @@ -93,7 +93,7 @@ void runComputations(std::vector<std::unique_ptr<IComputation>> computations) if (!comp->isCompleted()) failure_messages.push_back(comp->errorMessage()); - if (failure_messages.size() == 0) + if (failure_messages.empty()) return; throw Exceptions::RuntimeErrorException( "Error in runComputations: " diff --git a/Fit/Minimizer/MinimizerOptions.cpp b/Fit/Minimizer/MinimizerOptions.cpp index 769b849fa8e..97348b4cefe 100644 --- a/Fit/Minimizer/MinimizerOptions.cpp +++ b/Fit/Minimizer/MinimizerOptions.cpp @@ -38,7 +38,7 @@ void MinimizerOptions::setOptionString(const std::string& options) std::vector<std::string> tokens = StringUtils::split(options, delimeter); try { for (std::string opt : tokens) - if (opt.size()) + if (!opt.empty()) processCommand(opt); } catch (std::exception& ex) { std::ostringstream ostr; diff --git a/Fit/RootAdapter/MinimizerResultUtils.cpp b/Fit/RootAdapter/MinimizerResultUtils.cpp index bf89141dc5b..a1c9110b610 100644 --- a/Fit/RootAdapter/MinimizerResultUtils.cpp +++ b/Fit/RootAdapter/MinimizerResultUtils.cpp @@ -67,7 +67,7 @@ std::string MinimizerResultUtils::reportParameters(const Fit::Parameters& parame } Fit::Parameters::corr_matrix_t matrix = parameters.correlationMatrix(); - if (matrix.size()) { + if (!matrix.empty()) { result << MinimizerUtils::sectionString("Correlations"); for (size_t i = 0; i < matrix.size(); ++i) { result << boost::format("#%-2d ") % i; @@ -93,7 +93,7 @@ std::string reportDescription(const RootMinimizerAdapter& minimizer) std::string reportOption(const RootMinimizerAdapter& minimizer) { - if (minimizer.options().size() == 0) + if (minimizer.options().empty()) return ""; std::ostringstream result; diff --git a/Fit/RootAdapter/ResidualFunctionAdapter.cpp b/Fit/RootAdapter/ResidualFunctionAdapter.cpp index a20266b132f..39f411737a7 100644 --- a/Fit/RootAdapter/ResidualFunctionAdapter.cpp +++ b/Fit/RootAdapter/ResidualFunctionAdapter.cpp @@ -104,7 +104,7 @@ double ResidualFunctionAdapter::element_residual(const std::vector<double>& pars m_residuals = get_residuals(pars); } - if (gradients.size()) { + if (!gradients.empty()) { // Non zero size means that minimizer wants to know gradients. if (pars.size() != gradients.size()) throw std::runtime_error("ResidualFunctionAdapter::element_residual() -> Error. " diff --git a/Fit/RootAdapter/ScalarFunctionAdapter.cpp b/Fit/RootAdapter/ScalarFunctionAdapter.cpp index 5c7eef7fb74..3891fe16c90 100644 --- a/Fit/RootAdapter/ScalarFunctionAdapter.cpp +++ b/Fit/RootAdapter/ScalarFunctionAdapter.cpp @@ -34,6 +34,7 @@ const RootScalarFunction* ScalarFunctionAdapter::rootObjectiveFunction() return m_fcn(m_parameters); }; - m_root_objective = std::make_unique<RootScalarFunction>(rootfun, static_cast<int>(m_parameters.size())); + m_root_objective = + std::make_unique<RootScalarFunction>(rootfun, static_cast<int>(m_parameters.size())); return m_root_objective.get(); } diff --git a/Fit/Tools/OptionContainer.h b/Fit/Tools/OptionContainer.h index 424ff4fe63d..828d1031796 100644 --- a/Fit/Tools/OptionContainer.h +++ b/Fit/Tools/OptionContainer.h @@ -54,6 +54,7 @@ public: const_iterator end() const { return m_options.end(); } size_t size() const { return m_options.size(); } + bool empty() const { return size() == 0; } protected: bool exists(const std::string& name); diff --git a/GUI/coregui/Models/ComboProperty.cpp b/GUI/coregui/Models/ComboProperty.cpp index 7af2c87483f..cdba924253a 100644 --- a/GUI/coregui/Models/ComboProperty.cpp +++ b/GUI/coregui/Models/ComboProperty.cpp @@ -93,7 +93,7 @@ void ComboProperty::setCurrentIndex(int index) ComboProperty& ComboProperty::operator<<(const QString& str) { m_values.append(str); - if (m_values.size()) + if (!m_values.empty()) setCurrentIndex(0); return *this; } @@ -101,7 +101,7 @@ ComboProperty& ComboProperty::operator<<(const QString& str) ComboProperty& ComboProperty::operator<<(const QStringList& str) { m_values.append(str); - if (m_values.size()) + if (!m_values.empty()) setCurrentIndex(0); return *this; } diff --git a/GUI/coregui/Models/DomainObjectBuilder.cpp b/GUI/coregui/Models/DomainObjectBuilder.cpp index 9a35e8f74bb..5bfa534db6f 100644 --- a/GUI/coregui/Models/DomainObjectBuilder.cpp +++ b/GUI/coregui/Models/DomainObjectBuilder.cpp @@ -85,7 +85,7 @@ std::unique_ptr<ParticleLayout> DomainObjectBuilder::buildParticleLayout(const S QString par_name = prop.getValue(); if (par_name == ParticleDistributionItem::NO_SELECTION) { auto grandchildren = children[i]->getItems(); - if (grandchildren.size() == 0) { + if (grandchildren.empty()) { continue; } if (grandchildren.size() > 1) { diff --git a/GUI/coregui/Models/FitParameterItems.cpp b/GUI/coregui/Models/FitParameterItems.cpp index 8db8b1e303f..ae45fe4253a 100644 --- a/GUI/coregui/Models/FitParameterItems.cpp +++ b/GUI/coregui/Models/FitParameterItems.cpp @@ -283,7 +283,7 @@ void FitParameterContainerItem::setValuesInParameterContainer( int index(0); for (int i = 0; i < fitPars.size(); ++i) { auto link_list = fitPars[i]->getItems(FitParameterItem::T_LINK); - if (link_list.size() == 0) + if (link_list.empty()) continue; for (auto linkItem : link_list) { QString parPath = linkItem->getItemValue(FitParameterLinkItem::P_LINK).toString(); diff --git a/GUI/coregui/Models/ModelMapper.h b/GUI/coregui/Models/ModelMapper.h index 5af3c798f92..082601c55d5 100644 --- a/GUI/coregui/Models/ModelMapper.h +++ b/GUI/coregui/Models/ModelMapper.h @@ -107,10 +107,9 @@ private: template <class U> inline void ModelMapper::clean_container(U& v, const void* caller) { - v.erase(std::remove_if(v.begin(), v.end(), - [caller](typename U::value_type const& x) -> bool { - return (x.second == caller); - }), + v.erase(std::remove_if( + v.begin(), v.end(), + [caller](typename U::value_type const& x) -> bool { return (x.second == caller); }), v.end()); } diff --git a/GUI/coregui/Models/ParticleDistributionItem.cpp b/GUI/coregui/Models/ParticleDistributionItem.cpp index 131cf152a4c..2f8a70c5de6 100644 --- a/GUI/coregui/Models/ParticleDistributionItem.cpp +++ b/GUI/coregui/Models/ParticleDistributionItem.cpp @@ -81,7 +81,7 @@ ParticleDistributionItem::ParticleDistributionItem() : SessionGraphicsItem("Part std::unique_ptr<ParticleDistribution> ParticleDistributionItem::createParticleDistribution() const { - if (children().size() == 0) + if (children().empty()) return nullptr; std::unique_ptr<IParticle> P_particle = TransformToDomain::createIParticle(*getItem()); if (!P_particle) @@ -199,7 +199,7 @@ QString ParticleDistributionItem::translateParameterNameToGUI(const QString& dom const SessionItem* ParticleDistributionItem::childParticle() const { - if (getItems(T_PARTICLES).size() == 0) + if (getItems(T_PARTICLES).empty()) return nullptr; ASSERT(getItems(T_PARTICLES).size() == 1); diff --git a/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp b/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp index e42926e481f..c467479df55 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp +++ b/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp @@ -100,7 +100,7 @@ void ItemSelectorWidget::onSelectionChanged(const QItemSelection& selected, cons QModelIndexList indexes = selected.indexes(); SessionItem* selectedItem(0); - if (indexes.size()) + if (!indexes.empty()) selectedItem = m_model->itemForIndex(indexes.back()); emit selectionChanged(selectedItem); diff --git a/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h b/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h index 9d26e2f6764..8d603615f79 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h +++ b/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h @@ -85,7 +85,7 @@ template <class T> T* ItemStackPresenter<T>::currentWidget() template <class T> T* ItemStackPresenter<T>::itemWidget(SessionItem* item) { if (m_single_widget) { - if (m_itemToWidget.size()) + if (!m_itemToWidget.empty()) return m_itemToWidget.first(); } else { return m_itemToWidget[item]; diff --git a/GUI/coregui/Views/FitWidgets/FitSessionController.cpp b/GUI/coregui/Views/FitWidgets/FitSessionController.cpp index fd72f1992b8..378816dfd10 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionController.cpp +++ b/GUI/coregui/Views/FitWidgets/FitSessionController.cpp @@ -177,7 +177,7 @@ void FitSessionController::updateLog(const FitProgressInfo& info) int index(0); QVector<double> values = GUIHelpers::fromStdVector(info.parValues()); for (auto item : fitParContainer->getItems(FitParameterContainerItem::T_FIT_PARAMETERS)) { - if (item->getItems(FitParameterItem::T_LINK).size() == 0) + if (item->getItems(FitParameterItem::T_LINK).empty()) continue; QString parinfo = QString(" %1 %2\n").arg(item->displayName()).arg(values[index++]); message.append(parinfo); diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp b/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp index 5e144ee0138..eed5b59a629 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp +++ b/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp @@ -115,7 +115,7 @@ void JobSelectorActions::initItemContextMenu(QMenu& menu, const QModelIndex& ind QModelIndex targetIndex = indexAtPoint; if (!targetIndex.isValid()) { QModelIndexList indexList = m_selectionModel->selectedIndexes(); - if (indexList.size()) + if (!indexList.empty()) targetIndex = indexList.first(); } m_runJobAction->setEnabled(canRunJob(targetIndex)); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp index ee403d40ec0..47af7004027 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp @@ -123,7 +123,7 @@ void MaskEditorPropertyPanel::setPanelHidden(bool value) m_plotPropertyEditor->setItem(nullptr); } else { QModelIndexList indexes = selectionModel()->selectedIndexes(); - if (indexes.size()) + if (!indexes.empty()) m_maskPropertyEditor->setItem(m_maskModel->itemForIndex(indexes.front())); m_plotPropertyEditor->setItem(m_intensityDataItem); @@ -133,7 +133,7 @@ void MaskEditorPropertyPanel::setPanelHidden(bool value) void MaskEditorPropertyPanel::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) { - if (selected.size()) + if (!selected.empty()) m_maskPropertyEditor->setItem(m_maskModel->itemForIndex(selected.indexes().front())); else m_maskPropertyEditor->setItem(nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp b/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp index bfd5971d6df..3f2c1aa2f35 100644 --- a/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp +++ b/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp @@ -130,7 +130,7 @@ void TestComponentView::onSelectionChanged(const QItemSelection& selected, const { QModelIndexList indices = selected.indexes(); - if (indices.size()) { + if (!indices.empty()) { // QModelIndex selectedIndex = indices.front(); // m_componentTree->setRootIndex(selectedIndex); // m_componentTree->treeView()->expandAll(); diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp index 6d92ab07f3c..adcd229f925 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp @@ -81,7 +81,7 @@ void RealSpaceCanvas::updateToSelection() if (!m_view_locked) { QModelIndexList indices = m_selectionModel->selection().indexes(); - if (indices.size()) + if (!indices.empty()) m_currentSelection = FilterPropertyProxy::toSourceIndex(indices.back()); else m_currentSelection = {}; diff --git a/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp b/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp index 279302d0dea..5ca04343759 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp @@ -91,7 +91,7 @@ void DesignerMimeData::read_widget(QXmlStreamReader& reader) Qt::DropAction DesignerMimeData::execDrag(const QString& name, const QString& xmldescr, QWidget* dragSource) { - if (!xmldescr.size()) + if (xmldescr.size() == 0) return Qt::IgnoreAction; QDrag* drag = new QDrag(dragSource); diff --git a/GUI/coregui/Views/SampleDesigner/ILayerView.cpp b/GUI/coregui/Views/SampleDesigner/ILayerView.cpp index c1f2da5f1c1..55094908a30 100644 --- a/GUI/coregui/Views/SampleDesigner/ILayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ILayerView.cpp @@ -246,7 +246,7 @@ MultiLayerCandidate ILayerView::getMultiLayerCandidate() } } // sorting MultiLayerView candidates to find one whose drop area is closer - if (candidates.size()) { + if (!candidates.empty()) { std::sort(candidates.begin(), candidates.end()); return candidates.back(); } diff --git a/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp b/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp index b3cc843b84d..3445d7e3935 100644 --- a/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp @@ -37,7 +37,7 @@ MultiLayerView::MultiLayerView(QGraphicsItem* parent) : ILayerView(parent) QRectF MultiLayerView::boundingRect() const { QRectF result = m_rect; - if (m_layers.size()) { + if (!m_layers.empty()) { qreal toplayer_height = m_layers.front()->boundingRect().height(); qreal bottomlayer_height = m_layers.back()->boundingRect().height(); result.setTop(-toplayer_height / 2.); @@ -118,7 +118,7 @@ void MultiLayerView::updateHeight() m_interfaces.clear(); int total_height = 0; - if (m_layers.size()) { + if (!m_layers.empty()) { for (ILayerView* layer : m_layers) { layer->setY(total_height); layer->update(); diff --git a/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp b/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp index 808e423f2cd..0af33132b72 100644 --- a/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp +++ b/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp @@ -72,7 +72,7 @@ void SamplePropertyWidget::selectionChanged(const QItemSelection& selected, cons { QModelIndexList indices = selected.indexes(); - if (indices.size()) { + if (!indices.empty()) { QModelIndex index = indices.back(); if (auto proxy = dynamic_cast<QSortFilterProxyModel*>( diff --git a/GUI/main/MessageHandler.cpp b/GUI/main/MessageHandler.cpp index b2086165c99..99a18d53096 100644 --- a/GUI/main/MessageHandler.cpp +++ b/GUI/main/MessageHandler.cpp @@ -21,7 +21,7 @@ void MessageHandler(QtMsgType type, const QMessageLogContext&, const QString& ms { switch (type) { case QtDebugMsg: - if (!msg.size()) // KDE will pass a zero-length msg qstring + if (msg.size() == 0) // KDE will pass a zero-length msg qstring break; std::cerr << "DEBUG: " << msg.toStdString() << std::endl; break; diff --git a/Tests/Functional/GUI/Translate/GUITranslationTest.cpp b/Tests/Functional/GUI/Translate/GUITranslationTest.cpp index c249bab5948..dd1da306d8b 100644 --- a/Tests/Functional/GUI/Translate/GUITranslationTest.cpp +++ b/Tests/Functional/GUI/Translate/GUITranslationTest.cpp @@ -288,7 +288,7 @@ bool GUITranslationTest::checkMissedTranslations() } } - if (missedNames.size()) { + if (!missedNames.empty()) { std::cout << header() << std::endl; std::cout << "Translation doesn't exist:" << std::endl; std::cout << header() << std::endl; diff --git a/Tests/UnitTests/GUI/TestComponentProxyModel.cpp b/Tests/UnitTests/GUI/TestComponentProxyModel.cpp index 15959f284f0..9d720346b3f 100644 --- a/Tests/UnitTests/GUI/TestComponentProxyModel.cpp +++ b/Tests/UnitTests/GUI/TestComponentProxyModel.cpp @@ -222,8 +222,8 @@ TEST_F(TestComponentProxyModel, test_insertRows) ComponentProxyModel proxy; proxy.setSessionModel(&model); - EXPECT_FALSE(model.hasChildren(QModelIndex()) ); - EXPECT_FALSE(proxy.hasChildren(QModelIndex()) ); + EXPECT_FALSE(model.hasChildren(QModelIndex())); + EXPECT_FALSE(proxy.hasChildren(QModelIndex())); QSignalSpy spyProxy(&proxy, &ComponentProxyModel::layoutChanged); @@ -270,10 +270,10 @@ TEST_F(TestComponentProxyModel, test_componentStrategy) // CylinderItem shouldn't exist anymore in proxy QModelIndex ffProxyIndex = proxy.mapFromSource(ffIndex); - EXPECT_FALSE(ffProxyIndex.isValid() ); + EXPECT_FALSE(ffProxyIndex.isValid()); QModelIndex radiusProxyIndex = proxy.mapFromSource(radiusIndex); - EXPECT_TRUE(radiusProxyIndex.isValid() ); + EXPECT_TRUE(radiusProxyIndex.isValid()); EXPECT_TRUE(radiusProxyIndex.parent() == groupProxyIndex); } @@ -370,7 +370,7 @@ TEST_F(TestComponentProxyModel, test_setRootIndexLayer) EXPECT_EQ(proxy.columnCount(QModelIndex()), 2); QModelIndex multilayerProxyIndex = proxy.mapFromSource(model.indexOfItem(multilayer)); - EXPECT_FALSE(multilayerProxyIndex.isValid() ); + EXPECT_FALSE(multilayerProxyIndex.isValid()); QModelIndex layerProxyIndex = proxy.mapFromSource(model.indexOfItem(layer1)); EXPECT_EQ(proxy.rowCount(layerProxyIndex), 4); // thickness, material, slices, roughness @@ -380,5 +380,5 @@ TEST_F(TestComponentProxyModel, test_setRootIndexLayer) // ParticleLayout should be excluded from proxy tree QModelIndex layoutProxyIndex = proxy.mapFromSource(model.indexOfItem(layout)); - EXPECT_FALSE(layoutProxyIndex.isValid() ); + EXPECT_FALSE(layoutProxyIndex.isValid()); } diff --git a/Tests/UnitTests/GUI/TestExternalProperty.cpp b/Tests/UnitTests/GUI/TestExternalProperty.cpp index 902ebdc0035..f9b31332613 100644 --- a/Tests/UnitTests/GUI/TestExternalProperty.cpp +++ b/Tests/UnitTests/GUI/TestExternalProperty.cpp @@ -15,22 +15,22 @@ public: TEST_F(TestExternalProperty, test_initialState) { ExternalProperty property; - EXPECT_FALSE(property.isValid() ); - EXPECT_FALSE(property.color().isValid() ); - EXPECT_TRUE(property.identifier().isEmpty() ); - EXPECT_TRUE(property.text().isEmpty() ); + EXPECT_FALSE(property.isValid()); + EXPECT_FALSE(property.color().isValid()); + EXPECT_TRUE(property.identifier().isEmpty()); + EXPECT_TRUE(property.text().isEmpty()); // changing any property should change state to valid property.setColor(QColor(Qt::red)); EXPECT_TRUE(property.color() == QColor(Qt::red)); - EXPECT_TRUE(property.isValid() ); + EXPECT_TRUE(property.isValid()); property.setColor(QColor()); - EXPECT_FALSE(property.isValid() ); + EXPECT_FALSE(property.isValid()); property.setText("aaa"); EXPECT_TRUE(property.text() == "aaa"); - EXPECT_TRUE(property.isValid() ); + EXPECT_TRUE(property.isValid()); property.setText(QString()); - EXPECT_FALSE(property.isValid() ); + EXPECT_FALSE(property.isValid()); } //! Testing equality operators. diff --git a/Tests/UnitTests/GUI/TestGroupItem.cpp b/Tests/UnitTests/GUI/TestGroupItem.cpp index a1e37fe6c80..86b837fa42b 100644 --- a/Tests/UnitTests/GUI/TestGroupItem.cpp +++ b/Tests/UnitTests/GUI/TestGroupItem.cpp @@ -76,7 +76,7 @@ TEST_F(TestGroupItem, test_CreateGroup) // checking current variant QVariant value = groupItem->value(); - EXPECT_TRUE(value.canConvert<ComboProperty>() ); + EXPECT_TRUE(value.canConvert<ComboProperty>()); ComboProperty combo = value.value<ComboProperty>(); EXPECT_EQ(combo.getValues(), groupInfo.itemLabels()); int index = groupInfo.itemTypes().indexOf(groupInfo.defaultType()); diff --git a/Tests/UnitTests/GUI/TestMapperCases.cpp b/Tests/UnitTests/GUI/TestMapperCases.cpp index fff65d59b79..c0436e1343b 100644 --- a/Tests/UnitTests/GUI/TestMapperCases.cpp +++ b/Tests/UnitTests/GUI/TestMapperCases.cpp @@ -28,7 +28,7 @@ TEST_F(TestMapperCases, test_ParticeleCompositionUpdate) // composition added to distribution should have abundance disabled SessionItem* distribution = model.insertNewItem("ParticleDistribution", layout->index()); SessionItem* composition = model.insertNewItem("ParticleComposition", distribution->index()); - EXPECT_FALSE(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() ); + EXPECT_FALSE(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); composition = distribution->takeRow(ParentRow(*composition)); EXPECT_TRUE(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); @@ -45,9 +45,9 @@ TEST_F(TestMapperCases, test_SimulationOptionsComputationToggle) ComboProperty combo = item->getItemValue(SimulationOptionsItem::P_COMPUTATION_METHOD).value<ComboProperty>(); EXPECT_EQ(combo.getValue(), "Analytical"); - EXPECT_FALSE(item->getItem(SimulationOptionsItem::P_MC_POINTS)->isEnabled() ); + EXPECT_FALSE(item->getItem(SimulationOptionsItem::P_MC_POINTS)->isEnabled()); combo.setValue("Monte-Carlo Integration"); item->setItemValue(SimulationOptionsItem::P_COMPUTATION_METHOD, combo.variant()); - EXPECT_TRUE(item->getItem(SimulationOptionsItem::P_MC_POINTS)->isEnabled() ); + EXPECT_TRUE(item->getItem(SimulationOptionsItem::P_MC_POINTS)->isEnabled()); } diff --git a/Tests/UnitTests/GUI/TestMaterialModel.cpp b/Tests/UnitTests/GUI/TestMaterialModel.cpp index 1e2717364e6..82215a56f83 100644 --- a/Tests/UnitTests/GUI/TestMaterialModel.cpp +++ b/Tests/UnitTests/GUI/TestMaterialModel.cpp @@ -123,7 +123,7 @@ TEST_F(TestMaterialModel, defaultMaterialProperty) // testing default material property from MaterialItemUtils // in the absence of any materials, property should be in invalid state ExternalProperty property = MaterialItemUtils::defaultMaterialProperty(); - EXPECT_FALSE(property.isValid() ); + EXPECT_FALSE(property.isValid()); // adding materials to the model, default property should refer to first material in a model auto mat1 = model.addRefractiveMaterial("Something1", 1.0, 2.0); diff --git a/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp b/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp index 282f33cb88f..ec7acd982dc 100644 --- a/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp +++ b/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp @@ -122,7 +122,7 @@ TEST_F(TestMaterialPropertyController, test_ControllerInEditorContext) // layer2 should have undefined material property ExternalProperty property = layer2->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); - EXPECT_FALSE(property.isValid() ); + EXPECT_FALSE(property.isValid()); // layer3 should have different MaterialProperty name property = layer3->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index c4178305820..43eefcbb7e4 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -99,11 +99,11 @@ TEST_F(TestOutputDataIOService, test_OutputDataSaveInfo) QTest::qSleep(nap_time); OutputDataSaveInfo info = OutputDataSaveInfo::createSaved(item); - EXPECT_FALSE(info.wasModifiedSinceLastSave() ); + EXPECT_FALSE(info.wasModifiedSinceLastSave()); QTest::qSleep(nap_time); item->setLastModified(QDateTime::currentDateTime()); - EXPECT_TRUE(info.wasModifiedSinceLastSave() ); + EXPECT_TRUE(info.wasModifiedSinceLastSave()); } //! Tests OutputDataDirHistory class intended for storing save history of several @@ -121,18 +121,18 @@ TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) // empty history OutputDataDirHistory history; - EXPECT_FALSE(history.contains(item1) ); + EXPECT_FALSE(history.contains(item1)); // non-existing item is treated as modified - EXPECT_TRUE(history.wasModifiedSinceLastSave(item1) ); + EXPECT_TRUE(history.wasModifiedSinceLastSave(item1)); // Saving item in a history history.markAsSaved(item1); history.markAsSaved(item2); - EXPECT_TRUE(history.contains(item1) ); + EXPECT_TRUE(history.contains(item1)); // Empty DataItems are not added to history: - EXPECT_FALSE(history.contains(item2) ); - EXPECT_FALSE(history.wasModifiedSinceLastSave(item1) ); + EXPECT_FALSE(history.contains(item2)); + EXPECT_FALSE(history.wasModifiedSinceLastSave(item1)); // Attempt to save same item second time EXPECT_THROW(history.markAsSaved(item1), GUIHelpers::Error); @@ -141,7 +141,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) QTest::qSleep(10); item1->setLastModified(QDateTime::currentDateTime()); - EXPECT_TRUE(history.wasModifiedSinceLastSave(item1) ); + EXPECT_TRUE(history.wasModifiedSinceLastSave(item1)); } //! Tests OutputDataIOHistory class (save info for several independent directories). @@ -174,10 +174,10 @@ TEST_F(TestOutputDataIOService, test_OutputDataIOHistory) history.setHistory("dir1", dirHistory1); history.setHistory("dir2", dirHistory2); - EXPECT_TRUE(history.wasModifiedSinceLastSave("dir1", item1) ); - EXPECT_TRUE(history.wasModifiedSinceLastSave("dir2", item1) ); + EXPECT_TRUE(history.wasModifiedSinceLastSave("dir1", item1)); + EXPECT_TRUE(history.wasModifiedSinceLastSave("dir2", item1)); - EXPECT_FALSE(history.wasModifiedSinceLastSave("dir1", item2) ); + EXPECT_FALSE(history.wasModifiedSinceLastSave("dir1", item2)); EXPECT_TRUE(history.wasModifiedSinceLastSave("dir2", item2) == true); // since item2 doesn't exist @@ -241,7 +241,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataIOService) EXPECT_TRUE(GuiUnittestUtils::isTheSame(fname2new, *realData2->dataItem()->getOutputData())); // Check that file with old name was removed. - EXPECT_FALSE(ProjectUtils::exists(fname2) ); + EXPECT_FALSE(ProjectUtils::exists(fname2)); } TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) diff --git a/Tests/UnitTests/GUI/TestParticleCoreShell.cpp b/Tests/UnitTests/GUI/TestParticleCoreShell.cpp index c6192e95123..1496ca23b72 100644 --- a/Tests/UnitTests/GUI/TestParticleCoreShell.cpp +++ b/Tests/UnitTests/GUI/TestParticleCoreShell.cpp @@ -106,7 +106,7 @@ TEST_F(TestParticleCoreShell, test_distributionContext) // coreshell particle SessionItem* coreshell = model.insertNewItem("ParticleCoreShell"); coreshell->setItemValue(ParticleItem::P_ABUNDANCE, 0.2); - EXPECT_TRUE(coreshell->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() ); + EXPECT_TRUE(coreshell->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); EXPECT_EQ(coreshell->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 0.2); // create distribution, adding coreshell to it diff --git a/Tests/UnitTests/GUI/TestParticleItem.cpp b/Tests/UnitTests/GUI/TestParticleItem.cpp index 8c657fd6b1f..9160d060b02 100644 --- a/Tests/UnitTests/GUI/TestParticleItem.cpp +++ b/Tests/UnitTests/GUI/TestParticleItem.cpp @@ -54,17 +54,17 @@ TEST_F(TestParticleItem, test_distributionContext) SampleModel model; SessionItem* particle = model.insertNewItem("Particle"); particle->setItemValue(ParticleItem::P_ABUNDANCE, 0.2); - EXPECT_TRUE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() ); + EXPECT_TRUE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); EXPECT_EQ(particle->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 0.2); // adding particle to distribution, checking that abundance is default SessionItem* distribution = model.insertNewItem("ParticleDistribution"); model.moveItem(particle, distribution, -1, ParticleDistributionItem::T_PARTICLES); - EXPECT_FALSE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() ); + EXPECT_FALSE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); EXPECT_EQ(particle->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); // removing particle, checking that abundance is enabled again distribution->takeRow(ParentRow(*particle)); - EXPECT_TRUE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() ); + EXPECT_TRUE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); delete particle; } diff --git a/Tests/UnitTests/GUI/TestProjectDocument.cpp b/Tests/UnitTests/GUI/TestProjectDocument.cpp index 83bcff2315f..c7a482f9102 100644 --- a/Tests/UnitTests/GUI/TestProjectDocument.cpp +++ b/Tests/UnitTests/GUI/TestProjectDocument.cpp @@ -65,8 +65,8 @@ TEST_F(TestProjectDocument, test_projectDocument) document.setApplicationModels(&models); // Checking initial document status - EXPECT_FALSE(document.isModified() ); - EXPECT_FALSE(document.hasValidNameAndPath() ); + EXPECT_FALSE(document.isModified()); + EXPECT_FALSE(document.hasValidNameAndPath()); EXPECT_EQ(document.projectDir(), QString()); EXPECT_EQ(document.projectName(), QString()); EXPECT_EQ(document.projectFileName(), QString()); diff --git a/Tests/UnitTests/GUI/TestProjectUtils.cpp b/Tests/UnitTests/GUI/TestProjectUtils.cpp index 4a04fcb184d..8dd95ad3f44 100644 --- a/Tests/UnitTests/GUI/TestProjectUtils.cpp +++ b/Tests/UnitTests/GUI/TestProjectUtils.cpp @@ -31,8 +31,8 @@ TEST_F(TestProjectUtils, test_nonXMLDataInDir) QDir dir(projectDir); if (dir.exists()) { - EXPECT_TRUE(ProjectUtils::removeRecursively(projectDir) ); - EXPECT_FALSE(dir.exists() ); + EXPECT_TRUE(ProjectUtils::removeRecursively(projectDir)); + EXPECT_FALSE(dir.exists()); } GUIHelpers::createSubdir(".", projectDir); @@ -61,7 +61,7 @@ TEST_F(TestProjectUtils, test_nonXMLDataInDir) EXPECT_EQ(test_nonxml_files, nonxml); std::cout << "remove nonxml files ..." << std::endl; - EXPECT_TRUE(ProjectUtils::removeFiles(projectDir, nonxml) ); + EXPECT_TRUE(ProjectUtils::removeFiles(projectDir, nonxml)); std::cout << "check that no files left ..." << std::endl; nonxml = ProjectUtils::nonXMLDataInDir(projectDir); diff --git a/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp b/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp index 4a589267eb5..15e7746b136 100644 --- a/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp +++ b/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp @@ -123,7 +123,7 @@ TEST_F(TestProxyModelStrategy, test_componentStrategyParticle) QModelIndex radiusProxyIndex = strategy.sourceToProxy().value(radiusIndex); EXPECT_TRUE(particleProxyIndex.isValid()); EXPECT_TRUE(groupProxyIndex.isValid()); - EXPECT_FALSE(ffProxyIndex.isValid() ); // ff is excluded from hierarchy + EXPECT_FALSE(ffProxyIndex.isValid()); // ff is excluded from hierarchy EXPECT_TRUE(radiusProxyIndex.isValid()); // Checking "real" parents of indices @@ -159,12 +159,12 @@ TEST_F(TestProxyModelStrategy, test_setRootIndex) QModelIndex groupProxyIndex = strategy.sourceToProxy().value(groupIndex); QModelIndex ffProxyIndex = strategy.sourceToProxy().value(ffIndex); QModelIndex radiusProxyIndex = strategy.sourceToProxy().value(radiusIndex); - EXPECT_FALSE(particleProxyIndex.isValid() ); // particle is not in a tree + EXPECT_FALSE(particleProxyIndex.isValid()); // particle is not in a tree EXPECT_TRUE(groupProxyIndex.isValid()); EXPECT_EQ(groupProxyIndex.row(), 0); EXPECT_EQ(groupProxyIndex.column(), 0); EXPECT_TRUE(groupProxyIndex.parent() == QModelIndex()); - EXPECT_FALSE(ffProxyIndex.isValid() ); // ff is excluded from hierarchy + EXPECT_FALSE(ffProxyIndex.isValid()); // ff is excluded from hierarchy EXPECT_TRUE(radiusProxyIndex.isValid()); // checking that new parent of groupItem is root diff --git a/Tests/UnitTests/GUI/TestSessionItem.cpp b/Tests/UnitTests/GUI/TestSessionItem.cpp index 00dd39d724d..cb2d30975fa 100644 --- a/Tests/UnitTests/GUI/TestSessionItem.cpp +++ b/Tests/UnitTests/GUI/TestSessionItem.cpp @@ -231,7 +231,7 @@ TEST_F(TestSessionItem, dataRoles) EXPECT_TRUE(item->roleProperty(Qt::DisplayRole) == 5432); EXPECT_TRUE(item->roleProperty(Qt::EditRole) == 5432); for (int i = 0; i < 10; i++) { - EXPECT_FALSE(item->roleProperty(SessionFlags::EndSessionRoles + i).isValid() ); + EXPECT_FALSE(item->roleProperty(SessionFlags::EndSessionRoles + i).isValid()); item->setRoleProperty(SessionFlags::EndSessionRoles + i, i); EXPECT_TRUE(item->roleProperty(SessionFlags::EndSessionRoles + i) == i); } -- GitLab