From ca584b4c39ebd65cc57ef5a710dfb42fa4703da4 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Sat, 3 Oct 2020 09:20:32 +0200 Subject: [PATCH] rm '== false' from boolean expressions (advised by clang-tidy) --- .clang-tidy | 5 ++++- Tests/UnitTests/GUI/TestComponentProxyModel.cpp | 10 +++++----- Tests/UnitTests/GUI/TestExternalProperty.cpp | 8 ++++---- Tests/UnitTests/GUI/TestMapperCases.cpp | 4 ++-- Tests/UnitTests/GUI/TestMaterialModel.cpp | 2 +- .../UnitTests/GUI/TestMaterialPropertyController.cpp | 4 ++-- Tests/UnitTests/GUI/TestOutputDataIOService.cpp | 12 ++++++------ Tests/UnitTests/GUI/TestParticleItem.cpp | 2 +- Tests/UnitTests/GUI/TestProjectDocument.cpp | 4 ++-- Tests/UnitTests/GUI/TestProjectUtils.cpp | 2 +- Tests/UnitTests/GUI/TestProxyModelStrategy.cpp | 6 +++--- Tests/UnitTests/GUI/TestSessionItem.cpp | 2 +- 12 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a3e59d4f69a..905f69bbb3c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,8 @@ --- Checks: '*, +-*braces-around-statements, +-*magic-numbers, +-*named-parameter, -clang-analyzer-alpha*, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-bounds-constant-array-index, @@ -14,4 +17,4 @@ Checks: '*, -google-runtime-int, -modernize-raw-string-literal, -modernize-use-trailing-return-type, --readability-magic-numbers' \ No newline at end of file +' \ No newline at end of file diff --git a/Tests/UnitTests/GUI/TestComponentProxyModel.cpp b/Tests/UnitTests/GUI/TestComponentProxyModel.cpp index 1b46b9c7242..f5c138f0686 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_TRUE(model.hasChildren(QModelIndex()) == false); - EXPECT_TRUE(proxy.hasChildren(QModelIndex()) == false); + EXPECT_FALSE(model.hasChildren(QModelIndex()) ); + EXPECT_FALSE(proxy.hasChildren(QModelIndex()) ); QSignalSpy spyProxy(&proxy, &ComponentProxyModel::layoutChanged); @@ -270,7 +270,7 @@ TEST_F(TestComponentProxyModel, test_componentStrategy) // CylinderItem shouldn't exist anymore in proxy QModelIndex ffProxyIndex = proxy.mapFromSource(ffIndex); - EXPECT_TRUE(ffProxyIndex.isValid() == false); + EXPECT_FALSE(ffProxyIndex.isValid() ); QModelIndex radiusProxyIndex = proxy.mapFromSource(radiusIndex); EXPECT_TRUE(radiusProxyIndex.isValid() == true); @@ -370,7 +370,7 @@ TEST_F(TestComponentProxyModel, test_setRootIndexLayer) EXPECT_EQ(proxy.columnCount(QModelIndex()), 2); QModelIndex multilayerProxyIndex = proxy.mapFromSource(model.indexOfItem(multilayer)); - EXPECT_TRUE(multilayerProxyIndex.isValid() == false); + 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_TRUE(layoutProxyIndex.isValid() == false); + EXPECT_FALSE(layoutProxyIndex.isValid() ); } diff --git a/Tests/UnitTests/GUI/TestExternalProperty.cpp b/Tests/UnitTests/GUI/TestExternalProperty.cpp index 698c2360118..3dc4ff468d4 100644 --- a/Tests/UnitTests/GUI/TestExternalProperty.cpp +++ b/Tests/UnitTests/GUI/TestExternalProperty.cpp @@ -15,8 +15,8 @@ public: TEST_F(TestExternalProperty, test_initialState) { ExternalProperty property; - EXPECT_TRUE(property.isValid() == false); - EXPECT_TRUE(property.color().isValid() == false); + EXPECT_FALSE(property.isValid() ); + EXPECT_FALSE(property.color().isValid() ); EXPECT_TRUE(property.identifier().isEmpty() == true); EXPECT_TRUE(property.text().isEmpty() == true); @@ -25,12 +25,12 @@ TEST_F(TestExternalProperty, test_initialState) EXPECT_TRUE(property.color() == QColor(Qt::red)); EXPECT_TRUE(property.isValid() == true); property.setColor(QColor()); - EXPECT_TRUE(property.isValid() == false); + EXPECT_FALSE(property.isValid() ); property.setText("aaa"); EXPECT_TRUE(property.text() == "aaa"); EXPECT_TRUE(property.isValid() == true); property.setText(QString()); - EXPECT_TRUE(property.isValid() == false); + EXPECT_FALSE(property.isValid() ); } //! Testing equality operators. diff --git a/Tests/UnitTests/GUI/TestMapperCases.cpp b/Tests/UnitTests/GUI/TestMapperCases.cpp index 2c841c6f448..fe405fe2205 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_TRUE(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == false); + EXPECT_FALSE(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() ); composition = distribution->takeRow(ParentRow(*composition)); EXPECT_TRUE(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); @@ -45,7 +45,7 @@ TEST_F(TestMapperCases, test_SimulationOptionsComputationToggle) ComboProperty combo = item->getItemValue(SimulationOptionsItem::P_COMPUTATION_METHOD).value<ComboProperty>(); EXPECT_EQ(combo.getValue(), "Analytical"); - EXPECT_TRUE(item->getItem(SimulationOptionsItem::P_MC_POINTS)->isEnabled() == false); + EXPECT_FALSE(item->getItem(SimulationOptionsItem::P_MC_POINTS)->isEnabled() ); combo.setValue("Monte-Carlo Integration"); item->setItemValue(SimulationOptionsItem::P_COMPUTATION_METHOD, combo.variant()); diff --git a/Tests/UnitTests/GUI/TestMaterialModel.cpp b/Tests/UnitTests/GUI/TestMaterialModel.cpp index 8befb501a23..1e2717364e6 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_TRUE(property.isValid() == false); + 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 7e5616e5b35..282f33cb88f 100644 --- a/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp +++ b/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp @@ -56,7 +56,7 @@ class TestMaterialPropertyController : public ::testing::Test // materialModel.removeRows(0, 1, QModelIndex()); // EXPECT_EQ(property_changed, 3); // property = layer->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); -// EXPECT_TRUE(property.isValid() == false); +// EXPECT_FALSE(property.isValid() ); //} //! Test MaterialProperty update in sample items when working on model clone. @@ -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_TRUE(property.isValid() == false); + 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 93fef24291a..bf24957ffeb 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -99,7 +99,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataSaveInfo) QTest::qSleep(nap_time); OutputDataSaveInfo info = OutputDataSaveInfo::createSaved(item); - EXPECT_TRUE(info.wasModifiedSinceLastSave() == false); + EXPECT_FALSE(info.wasModifiedSinceLastSave() ); QTest::qSleep(nap_time); item->setLastModified(QDateTime::currentDateTime()); @@ -121,7 +121,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) // empty history OutputDataDirHistory history; - EXPECT_TRUE(history.contains(item1) == false); + EXPECT_FALSE(history.contains(item1) ); // non-existing item is treated as modified EXPECT_TRUE(history.wasModifiedSinceLastSave(item1) == true); @@ -131,8 +131,8 @@ TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) EXPECT_TRUE(history.contains(item1) == true); // Empty DataItems are not added to history: - EXPECT_TRUE(history.contains(item2) == false); - EXPECT_TRUE(history.wasModifiedSinceLastSave(item1) == false); + EXPECT_FALSE(history.contains(item2) ); + EXPECT_FALSE(history.wasModifiedSinceLastSave(item1) ); // Attempt to save same item second time EXPECT_THROW(history.markAsSaved(item1), GUIHelpers::Error); @@ -177,7 +177,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataIOHistory) EXPECT_TRUE(history.wasModifiedSinceLastSave("dir1", item1) == true); EXPECT_TRUE(history.wasModifiedSinceLastSave("dir2", item1) == true); - EXPECT_TRUE(history.wasModifiedSinceLastSave("dir1", item2) == false); + 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_TRUE(ProjectUtils::exists(fname2) == false); + EXPECT_FALSE(ProjectUtils::exists(fname2) ); } TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) diff --git a/Tests/UnitTests/GUI/TestParticleItem.cpp b/Tests/UnitTests/GUI/TestParticleItem.cpp index 59210203b7e..615d27cbad2 100644 --- a/Tests/UnitTests/GUI/TestParticleItem.cpp +++ b/Tests/UnitTests/GUI/TestParticleItem.cpp @@ -60,7 +60,7 @@ TEST_F(TestParticleItem, test_distributionContext) // adding particle to distribution, checking that abundance is default SessionItem* distribution = model.insertNewItem("ParticleDistribution"); model.moveItem(particle, distribution, -1, ParticleDistributionItem::T_PARTICLES); - EXPECT_TRUE(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == false); + 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 diff --git a/Tests/UnitTests/GUI/TestProjectDocument.cpp b/Tests/UnitTests/GUI/TestProjectDocument.cpp index fd740fcfb17..83bcff2315f 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_TRUE(document.isModified() == false); - EXPECT_TRUE(document.hasValidNameAndPath() == false); + 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 1bc38497f6f..0364a4a4681 100644 --- a/Tests/UnitTests/GUI/TestProjectUtils.cpp +++ b/Tests/UnitTests/GUI/TestProjectUtils.cpp @@ -32,7 +32,7 @@ TEST_F(TestProjectUtils, test_nonXMLDataInDir) QDir dir(projectDir); if (dir.exists()) { EXPECT_TRUE(ProjectUtils::removeRecursively(projectDir) == true); - EXPECT_TRUE(dir.exists() == false); + EXPECT_FALSE(dir.exists() ); } GUIHelpers::createSubdir(".", projectDir); diff --git a/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp b/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp index 800ae4f79a8..4a589267eb5 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_TRUE(ffProxyIndex.isValid() == false); // 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_TRUE(particleProxyIndex.isValid() == false); // 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_TRUE(ffProxyIndex.isValid() == false); // 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 1ebb4c9cfa2..00dd39d724d 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_TRUE(item->roleProperty(SessionFlags::EndSessionRoles + i).isValid() == false); + EXPECT_FALSE(item->roleProperty(SessionFlags::EndSessionRoles + i).isValid() ); item->setRoleProperty(SessionFlags::EndSessionRoles + i, i); EXPECT_TRUE(item->roleProperty(SessionFlags::EndSessionRoles + i) == i); } -- GitLab