From 1275279528617154993f494f43184bfdbf202097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 6 Mar 2017 11:19:31 +0100 Subject: [PATCH] #1292 Fixed CppCheck Issues in UnitTests --- .../UnitTests/RigReservoir-Test.cpp | 1 - .../UnitTests/RigStatisticsMath-Test.cpp | 2 +- .../UnitTests/ScalarMapper-Test.cpp | 7 ++---- .../UnitTests/cvfGeometryTools-Test.cpp | 25 ++++++++----------- ApplicationCode/UnitTests/opm-parser-Test.cpp | 2 +- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/UnitTests/RigReservoir-Test.cpp b/ApplicationCode/UnitTests/RigReservoir-Test.cpp index e074f1d067..b6b3db35cc 100644 --- a/ApplicationCode/UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/UnitTests/RigReservoir-Test.cpp @@ -35,7 +35,6 @@ TEST(RigGridManager, BasicTest) cvf::ref eclipseCase = new RigEclipseCaseData; eclipseCase->setMainGrid(mainGridA.p()); - int count = mainGridA->refCount(); EXPECT_EQ(mainGridA->refCount(), 2); RigGridManager gridCollection; diff --git a/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp b/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp index ca5f1aaab9..8c304e9946 100644 --- a/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp +++ b/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp @@ -130,7 +130,7 @@ TEST(RigStatisticsMath, HistogramPercentiles) std::vector histogram; RigHistogramCalculator histCalc(min, max, 100, &histogram); histCalc.addData(values); - std::vector pVals; + double p10, p50, p90; p10 = histCalc.calculatePercentil(0.1); p50 = histCalc.calculatePercentil(0.5); diff --git a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp index fbe39089c6..71ef74b9f9 100644 --- a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp +++ b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp @@ -14,11 +14,8 @@ TEST(ScalarMapperTest, TestHumanReadableTickmarks) cvf::ref m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; - double adjustedMin = 0.0; - double adjustedMax = 0.0; - - adjustedMin = 2141234; - adjustedMax = 2165239; + double adjustedMin = 2141234; + double adjustedMax = 2165239; size_t m_numLevels = 10; diff --git a/ApplicationCode/UnitTests/cvfGeometryTools-Test.cpp b/ApplicationCode/UnitTests/cvfGeometryTools-Test.cpp index 578e833f4e..428cf1816e 100644 --- a/ApplicationCode/UnitTests/cvfGeometryTools-Test.cpp +++ b/ApplicationCode/UnitTests/cvfGeometryTools-Test.cpp @@ -167,14 +167,13 @@ TEST(CellFaceIntersectionTst, Intersection1) edgeIntersectionStorage.setVertexCount(nodes.size()); { std::vector polygon; - bool isOk = false; - isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( - &polygon, - &additionalVertices, - &edgeIntersectionStorage, - wrapArrayConst(&nodes), - faces[0].data(), - faces[1].data(), + bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( + &polygon, + &additionalVertices, + &edgeIntersectionStorage, + wrapArrayConst(&nodes), + faces[0].data(), + faces[1].data(), 1e-6); EXPECT_EQ( (size_t)5, polygon.size()); @@ -187,8 +186,7 @@ TEST(CellFaceIntersectionTst, Intersection1) { std::vector polygon; - bool isOk = false; - isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( + bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &additionalVertices, &edgeIntersectionStorage, @@ -207,8 +205,7 @@ TEST(CellFaceIntersectionTst, Intersection1) { std::vector polygon; - bool isOk = false; - isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( + bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &additionalVertices, &edgeIntersectionStorage, @@ -230,7 +227,7 @@ TEST(CellFaceIntersectionTst, Intersection1) for (cvf::uint vxIdx = 0; vxIdx < nodes.size(); ++vxIdx) { - bool inserted = GeometryTools::insertVertexInPolygon( + GeometryTools::insertVertexInPolygon( &basePolygon, wrapArrayConst(&nodes), vxIdx, @@ -245,7 +242,7 @@ TEST(CellFaceIntersectionTst, Intersection1) { for (cvf::uint vxIdx = 0; vxIdx < nodes.size(); ++vxIdx) { - bool inserted = GeometryTools::insertVertexInPolygon( + GeometryTools::insertVertexInPolygon( &overlapPolygons[pIdx], wrapArrayConst(&nodes), vxIdx, diff --git a/ApplicationCode/UnitTests/opm-parser-Test.cpp b/ApplicationCode/UnitTests/opm-parser-Test.cpp index 980449ff61..17e8624a6d 100644 --- a/ApplicationCode/UnitTests/opm-parser-Test.cpp +++ b/ApplicationCode/UnitTests/opm-parser-Test.cpp @@ -20,7 +20,7 @@ TEST(opm_parser_test, basicConstruction) std::string filename = "d:/Models/Statoil/Brillig/BRILLIG.DATA"; */ - std::string filename = "d:/gitroot-magnesj/opm-parser/testdata/cases_with_issues/testcase_juli_2011/TEST10K_FLT_LGR_NNC.DATA"; + // std::string filename = "d:/gitroot-magnesj/opm-parser/testdata/cases_with_issues/testcase_juli_2011/TEST10K_FLT_LGR_NNC.DATA"; /* std::string filename = "d:/Models/Statoil/1.2.0_Osesyd_segfault/BASEPRED6.DATA"; std::string filename = "d:/Models/Statoil/1.3.0_fault_assert_binary/BV-R2-11-0.DATA";