From 9c73e9610c7479ff97436717ab72998e2ceff05b Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 10 Oct 2021 12:46:07 +0200 Subject: [PATCH] [T] clang-format. --- Tests/BaseLib/TestConfigTree.cpp | 6 +- Tests/BaseLib/TestQuicksort.cpp | 42 ++++--- Tests/GeoLib/TestComputeRotationMatrix.cpp | 5 +- Tests/GeoLib/TestLineSegmentIntersect2d.cpp | 44 +++---- Tests/GeoLib/TestPointVec.cpp | 8 +- Tests/GeoLib/TestSortSegments.cpp | 46 ++++---- ...ctiveThermalConductivityPorosityMixing.cpp | 5 +- Tests/MaterialLib/TestMPL.cpp | 4 +- Tests/MaterialLib/TestMPLExponential.cpp | 6 +- .../TestMPLSaturationExponential.cpp | 1 + Tests/MathLib/KelvinVector.cpp | 40 ++++--- .../MathLib/TestGaussLegendreIntegration.cpp | 5 +- Tests/MathLib/TestODESolver.cpp | 5 +- Tests/MathLib/TestPoint3d.cpp | 39 +++--- Tests/MeshGeoToolsLib/TestGeoMapper.cpp | 3 +- Tests/MeshLib/ConvertToLinearMesh.cpp | 10 +- Tests/MeshLib/TestBoundaryElementSearch.cpp | 8 +- .../MeshLib/TestFindElementsWithinRadius.cpp | 16 +-- Tests/MeshLib/TestFlipElements.cpp | 6 +- Tests/MeshLib/TestLineMesh.cpp | 3 +- Tests/MeshLib/TestMeshGenerator.cpp | 9 +- Tests/MeshLib/TestQuadMesh.cpp | 111 ++++++++++-------- Tests/NumLib/NewtonRaphson.cpp | 20 ++-- Tests/NumLib/TestExtrapolation.cpp | 3 +- Tests/NumLib/TestMeshComponentMap.cpp | 5 +- Tests/NumLib/TestODEInt.cpp | 3 +- Tests/NumLib/TestSerialExecutor.cpp | 34 +++--- Tests/NumLib/TestSerialLinearSolver.cpp | 3 +- Tests/NumLib/TestShapeFunctions.cpp | 6 +- Tests/NumLib/TestShapeMatrices.cpp | 3 +- Tests/ParameterLib/Parameter.cpp | 32 +++-- .../MicroporosityComputation.cpp | 18 +-- .../TestTH2MPhaseTransitionEvaporation.cpp | 3 +- .../TH2M/TestTH2MPhaseTransitionNone.cpp | 3 +- Tests/testrunner.cpp | 10 +- 35 files changed, 315 insertions(+), 250 deletions(-) diff --git a/Tests/BaseLib/TestConfigTree.cpp b/Tests/BaseLib/TestConfigTree.cpp index 41c2e087d0a..4a87f26b395 100644 --- a/Tests/BaseLib/TestConfigTree.cpp +++ b/Tests/BaseLib/TestConfigTree.cpp @@ -45,7 +45,8 @@ public: BaseLib::ConfigTree::Callback get_error_cb() { return [this](std::string const& filename, std::string const& path, - std::string const& message) { + std::string const& message) + { (void)path; (void)message; @@ -62,7 +63,8 @@ public: BaseLib::ConfigTree::Callback get_warning_cb() { return [this](std::string const& filename, std::string const& path, - std::string const& message) { + std::string const& message) + { (void)path; (void)message; diff --git a/Tests/BaseLib/TestQuicksort.cpp b/Tests/BaseLib/TestQuicksort.cpp index 914a32419f6..11a7983c0d5 100644 --- a/Tests/BaseLib/TestQuicksort.cpp +++ b/Tests/BaseLib/TestQuicksort.cpp @@ -33,9 +33,8 @@ struct BaseLibQuicksort : public ::testing::Test { cls.trivial([](const std::vector<int>& xs) { return xs.size() < 2; }); - cls.collect([](std::vector<int> const& xs) { - return xs.size() < 10 ? "short" : "long"; - }); + cls.collect([](std::vector<int> const& xs) + { return xs.size() < 10 ? "short" : "long"; }); } ac::gtest_reporter gtest_reporter; @@ -45,13 +44,12 @@ struct BaseLibQuicksort : public ::testing::Test // Quicksort result is sorted. TEST_F(BaseLibQuicksort, SortsAsSTLSort) { - cls.classify( - [](std::vector<int> const& xs) { - return std::is_sorted(xs.begin(), xs.end()); - }, - "sorted"); + cls.classify([](std::vector<int> const& xs) + { return std::is_sorted(xs.begin(), xs.end()); }, + "sorted"); - auto quicksortSortsAsSTLSort = [](std::vector<int>& xs) -> bool { + auto quicksortSortsAsSTLSort = [](std::vector<int>& xs) -> bool + { std::vector<std::size_t> perm(xs.size()); if (!xs.empty()) { @@ -88,7 +86,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutations) { auto gen = ac::make_arbitrary(OrderedUniqueListGen<int>()); - auto quicksortCheckPermutations = [](std::vector<int>& xs) { + auto quicksortCheckPermutations = [](std::vector<int>& xs) + { std::vector<std::size_t> perm(xs.size()); std::iota(perm.begin(), perm.end(), 0); @@ -116,7 +115,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsWithPointer) { auto gen = ac::make_arbitrary(OrderedUniqueListGen<int>()); - auto quicksortCheckPermutations = [](std::vector<int>& xs) { + auto quicksortCheckPermutations = [](std::vector<int>& xs) + { std::vector<std::size_t> perm(xs.size()); std::iota(perm.begin(), perm.end(), 0); @@ -149,7 +149,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsWithPointer) TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverse) { auto reverse = [](std::vector<int>&& xs, - std::size_t /*unused*/) -> std::vector<int> { + std::size_t /*unused*/) -> std::vector<int> + { std::reverse(xs.begin(), xs.end()); return std::move(xs); }; @@ -157,7 +158,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverse) auto gen = ac::make_arbitrary(ac::map(reverse, OrderedUniqueListGen<int>())); - auto quicksortCheckPermutations = [](std::vector<int>& xs) { + auto quicksortCheckPermutations = [](std::vector<int>& xs) + { std::vector<std::size_t> perm(xs.size()); std::iota(perm.begin(), perm.end(), 0); @@ -183,7 +185,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverse) TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverseWithPointer) { auto reverse = [](std::vector<int>&& xs, - std::size_t /*unused*/) -> std::vector<int> { + std::size_t /*unused*/) -> std::vector<int> + { std::reverse(xs.begin(), xs.end()); return std::move(xs); }; @@ -191,7 +194,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverseWithPointer) auto gen = ac::make_arbitrary(ac::map(reverse, OrderedUniqueListGen<int>())); - auto quicksortCheckPermutations = [](std::vector<int>& xs) { + auto quicksortCheckPermutations = [](std::vector<int>& xs) + { std::vector<std::size_t> perm(xs.size()); std::iota(perm.begin(), perm.end(), 0); @@ -241,7 +245,8 @@ TEST_F(BaseLibQuicksort, SortsRangeAsSTLSort) { auto quicksortSortsRangeAsSTLSort = [](std::vector<int>& xs, - std::tuple<std::size_t, std::size_t> const& range) -> bool { + std::tuple<std::size_t, std::size_t> const& range) -> bool + { if (xs.empty()) { return true; @@ -263,8 +268,7 @@ TEST_F(BaseLibQuicksort, SortsRangeAsSTLSort) ac::make_arbitrary(ac::generator<std::vector<int>>(), randomSortedPairGenerator<std::size_t>()) .discard_if([](std::vector<int> const& xs, - std::tuple<std::size_t, std::size_t> const& range) { - return std::get<1>(range) >= xs.size(); - }), + std::tuple<std::size_t, std::size_t> const& range) + { return std::get<1>(range) >= xs.size(); }), gtest_reporter); } diff --git a/Tests/GeoLib/TestComputeRotationMatrix.cpp b/Tests/GeoLib/TestComputeRotationMatrix.cpp index 6c48002ec4d..8d22f6946bf 100644 --- a/Tests/GeoLib/TestComputeRotationMatrix.cpp +++ b/Tests/GeoLib/TestComputeRotationMatrix.cpp @@ -13,8 +13,9 @@ #include "GeoLib/AnalyticalGeometry.h" -auto test3equal = [](double a, double b, double c, - Eigen::Vector3d const& result) { +auto test3equal = + [](double a, double b, double c, Eigen::Vector3d const& result) +{ EXPECT_EQ(a, result[0]); EXPECT_EQ(b, result[1]); EXPECT_EQ(c, result[2]); diff --git a/Tests/GeoLib/TestLineSegmentIntersect2d.cpp b/Tests/GeoLib/TestLineSegmentIntersect2d.cpp index a0c25101657..1fe840ad896 100644 --- a/Tests/GeoLib/TestLineSegmentIntersect2d.cpp +++ b/Tests/GeoLib/TestLineSegmentIntersect2d.cpp @@ -43,14 +43,14 @@ public: [&](auto p) { return ac::reflect(point_generator2.center, p); }}; Eigen::Vector3d const translation_vector1 = {2, 2, 0}; - PairSegmentGenerator pair_segment_generator1 = PairSegmentGenerator{ - segment_generator1, - [&](auto p) { return ac::translate(translation_vector1, p); }}; + PairSegmentGenerator pair_segment_generator1 = + PairSegmentGenerator{segment_generator1, [&](auto p) + { return ac::translate(translation_vector1, p); }}; Eigen::Vector3d const translation_vector2 = {0, 0, 0}; - PairSegmentGenerator pair_segment_generator2 = PairSegmentGenerator{ - segment_generator1, - [&](auto p) { return ac::translate(translation_vector2, p); }}; + PairSegmentGenerator pair_segment_generator2 = + PairSegmentGenerator{segment_generator1, [&](auto p) + { return ac::translate(translation_vector2, p); }}; ac::gtest_reporter gtest_reporter; }; @@ -60,8 +60,9 @@ public: // consequence the center of the circle is the intersection point. TEST_F(LineSegmentIntersect2dTest, RandomSegmentOrientationIntersecting) { - auto intersect = [](GeoLib::LineSegment const& s0, - GeoLib::LineSegment const& s1) { + auto intersect = + [](GeoLib::LineSegment const& s0, GeoLib::LineSegment const& s1) + { auto ipnts = GeoLib::lineSegmentIntersect2d(s0, s1); if (ipnts.size() == 1) { @@ -84,8 +85,9 @@ TEST_F(LineSegmentIntersect2dTest, RandomSegmentOrientationIntersecting) // chords of non-intersecting circles. TEST_F(LineSegmentIntersect2dTest, RandomSegmentOrientationNonIntersecting) { - auto intersect = [](GeoLib::LineSegment const& s0, - GeoLib::LineSegment const& s1) { + auto intersect = + [](GeoLib::LineSegment const& s0, GeoLib::LineSegment const& s1) + { auto ipnts = GeoLib::lineSegmentIntersect2d(s0, s1); return ipnts.empty(); }; @@ -103,11 +105,12 @@ TEST_F(LineSegmentIntersect2dTest, ParallelNonIntersectingSegmentOrientation) { auto intersect = [](std::pair<GeoLib::LineSegment const&, - GeoLib::LineSegment const&> const& segment_pair) { - auto ipnts = GeoLib::lineSegmentIntersect2d(segment_pair.first, - segment_pair.second); - return ipnts.empty(); - }; + GeoLib::LineSegment const&> const& segment_pair) + { + auto ipnts = GeoLib::lineSegmentIntersect2d(segment_pair.first, + segment_pair.second); + return ipnts.empty(); + }; // generate non-intersecting segments ac::check<std::pair<GeoLib::LineSegment, GeoLib::LineSegment>>( @@ -120,11 +123,12 @@ TEST_F(LineSegmentIntersect2dTest, ParallelIntersectingSegmentOrientation) { auto intersect = [](std::pair<GeoLib::LineSegment const&, - GeoLib::LineSegment const&> const& segment_pair) { - auto ipnts = GeoLib::lineSegmentIntersect2d(segment_pair.first, - segment_pair.second); - return ipnts.size() == 2; - }; + GeoLib::LineSegment const&> const& segment_pair) + { + auto ipnts = GeoLib::lineSegmentIntersect2d(segment_pair.first, + segment_pair.second); + return ipnts.size() == 2; + }; // generate non-intersecting segments ac::check<std::pair<GeoLib::LineSegment, GeoLib::LineSegment>>( diff --git a/Tests/GeoLib/TestPointVec.cpp b/Tests/GeoLib/TestPointVec.cpp index e21a5ad1635..61b72353366 100644 --- a/Tests/GeoLib/TestPointVec.cpp +++ b/Tests/GeoLib/TestPointVec.cpp @@ -27,9 +27,11 @@ protected: void generateRandomPoints(VectorOfPoints& ps, std::size_t const n = 1000) { std::uniform_real_distribution<double> rnd(-1, 1); - std::generate_n(std::back_inserter(ps), n, [&]() { - return new GeoLib::Point(rnd(gen), rnd(gen), rnd(gen), ps.size()); - }); + std::generate_n(std::back_inserter(ps), n, + [&]() { + return new GeoLib::Point(rnd(gen), rnd(gen), + rnd(gen), ps.size()); + }); } protected: diff --git a/Tests/GeoLib/TestSortSegments.cpp b/Tests/GeoLib/TestSortSegments.cpp index 7c17a3af982..6ba269a28e8 100644 --- a/Tests/GeoLib/TestSortSegments.cpp +++ b/Tests/GeoLib/TestSortSegments.cpp @@ -41,7 +41,8 @@ TEST_F(GeoLibSortLineSegments, SortSubSegments) auto partitionSegment = [](GeoLib::LineSegment const& s0, std::vector<std::size_t> const& sub_seg_ids, double const dt, - std::vector<GeoLib::LineSegment>& sub_segments) { + std::vector<GeoLib::LineSegment>& sub_segments) + { for (auto sub_seg_id : sub_seg_ids) { double t(dt * sub_seg_id); @@ -61,32 +62,33 @@ TEST_F(GeoLibSortLineSegments, SortSubSegments) auto checkSortedSubSegments = [](GeoLib::LineSegment const& s0, - std::vector<GeoLib::LineSegment> const& sub_segments) { - double eps(std::numeric_limits<double>::epsilon()); - if (MathLib::sqrDist(s0.getBeginPoint(), - sub_segments.front().getBeginPoint()) >= eps) - { - return false; - } - if (MathLib::sqrDist(s0.getEndPoint(), - sub_segments.back().getEndPoint()) >= eps) + std::vector<GeoLib::LineSegment> const& sub_segments) + { + double eps(std::numeric_limits<double>::epsilon()); + if (MathLib::sqrDist(s0.getBeginPoint(), + sub_segments.front().getBeginPoint()) >= eps) + { + return false; + } + if (MathLib::sqrDist(s0.getEndPoint(), + sub_segments.back().getEndPoint()) >= eps) + { + return false; + } + for (std::size_t k(0); k < sub_segments.size() - 1; ++k) + { + if (MathLib::sqrDist(sub_segments[k].getEndPoint(), + sub_segments[k + 1].getBeginPoint()) >= eps) { return false; } - for (std::size_t k(0); k < sub_segments.size() - 1; ++k) - { - if (MathLib::sqrDist(sub_segments[k].getEndPoint(), - sub_segments[k + 1].getBeginPoint()) >= - eps) - { - return false; - } - } - return true; - }; + } + return true; + }; auto testSortSegments = [partitionSegment, checkSortedSubSegments]( - GeoLib::LineSegment const& s0) { + GeoLib::LineSegment const& s0) + { std::size_t const n_sub_segments(4); double const dt(1.0 / static_cast<double>(n_sub_segments)); std::vector<std::size_t> sub_seg_ids(n_sub_segments); diff --git a/Tests/MaterialLib/TestEffectiveThermalConductivityPorosityMixing.cpp b/Tests/MaterialLib/TestEffectiveThermalConductivityPorosityMixing.cpp index d486c45a799..dfc6af23361 100644 --- a/Tests/MaterialLib/TestEffectiveThermalConductivityPorosityMixing.cpp +++ b/Tests/MaterialLib/TestEffectiveThermalConductivityPorosityMixing.cpp @@ -64,8 +64,9 @@ TEST(MaterialPropertyLib, EffectiveThermalConductivityPorosityMixing) variable_array[static_cast<int>(MaterialPropertyLib::Variable::porosity)] = 0.12; auto const eff_th_cond = MaterialPropertyLib::formEigenTensor<3>( - medium->property(MaterialPropertyLib::PropertyType::thermal_conductivity) - .value(variable_array, pos, time, dt)); + medium + ->property(MaterialPropertyLib::PropertyType::thermal_conductivity) + .value(variable_array, pos, time, dt)); ASSERT_NEAR(eff_th_cond.trace(), 2.481, 1.e-10); } diff --git a/Tests/MaterialLib/TestMPL.cpp b/Tests/MaterialLib/TestMPL.cpp index b9c96d40f16..8539ae9b448 100644 --- a/Tests/MaterialLib/TestMPL.cpp +++ b/Tests/MaterialLib/TestMPL.cpp @@ -14,6 +14,8 @@ #include "TestMPL.h" +#include <sstream> + #include "BaseLib/ConfigTree.h" #include "MaterialLib/MPL/CreateMedium.h" #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h" @@ -21,8 +23,6 @@ #include "ParameterLib/Parameter.h" #include "Tests/TestTools.h" -#include <sstream> - namespace Tests { std::unique_ptr<MPL::Medium> createTestMaterial( diff --git a/Tests/MaterialLib/TestMPLExponential.cpp b/Tests/MaterialLib/TestMPLExponential.cpp index 042f3659e8e..a847572991a 100644 --- a/Tests/MaterialLib/TestMPLExponential.cpp +++ b/Tests/MaterialLib/TestMPLExponential.cpp @@ -55,13 +55,15 @@ TEST_F(MaterialPropertyLibExponentialProperty, TestNumericalDerivatives) double const time = std::numeric_limits<double>::quiet_NaN(); double const dt = std::numeric_limits<double>::quiet_NaN(); - auto y = [&](double const T) { + auto y = [&](double const T) + { MPL::VariableArray variable_array; variable_array[static_cast<int>(MPL::Variable::temperature)] = T; return p->template value<double>(variable_array, pos, time, dt); }; - auto f = [&](double const T) { + auto f = [&](double const T) + { MPL::VariableArray variable_array; variable_array[static_cast<int>(MPL::Variable::temperature)] = T; double const v = diff --git a/Tests/MaterialLib/TestMPLSaturationExponential.cpp b/Tests/MaterialLib/TestMPLSaturationExponential.cpp index e1af368eda1..88edb909b4a 100644 --- a/Tests/MaterialLib/TestMPLSaturationExponential.cpp +++ b/Tests/MaterialLib/TestMPLSaturationExponential.cpp @@ -8,6 +8,7 @@ * */ #include <gtest/gtest.h> + #include <iomanip> #include "MaterialLib/MPL/Medium.h" diff --git a/Tests/MathLib/KelvinVector.cpp b/Tests/MathLib/KelvinVector.cpp index 6a8ed9cd7fa..6d02f6d5063 100644 --- a/Tests/MathLib/KelvinVector.cpp +++ b/Tests/MathLib/KelvinVector.cpp @@ -39,7 +39,8 @@ struct MaterialLibSolidsKelvinVector6 : public ::testing::Test TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor) { - auto f = [](KelvinVectorType<2> const& v) { + auto f = [](KelvinVectorType<2> const& v) + { return (v - tensorToKelvin<2>(kelvinVectorToTensor(v))).norm() <= 2 * std::numeric_limits<double>::epsilon() * v.norm(); }; @@ -50,7 +51,8 @@ TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor) TEST_F(MaterialLibSolidsKelvinVector6, SelfTestMappingKelvinToTensor) { - auto f = [](KelvinVectorType<3> const& v) { + auto f = [](KelvinVectorType<3> const& v) + { return (v - tensorToKelvin<3>(kelvinVectorToTensor(v))).norm() <= 1.5 * std::numeric_limits<double>::epsilon() * v.norm(); }; @@ -65,7 +67,8 @@ TEST_F(MaterialLibSolidsKelvinVector6, SelfTestMappingKelvinToTensor) TEST_F(MaterialLibSolidsKelvinVector4, Determinant) { - auto f = [](KelvinVectorType<2> const& v) { + auto f = [](KelvinVectorType<2> const& v) + { return std::abs(Invariants<4>::determinant(v) - kelvinVectorToTensor(v).determinant()) <= std::numeric_limits<double>::epsilon() * @@ -78,7 +81,8 @@ TEST_F(MaterialLibSolidsKelvinVector4, Determinant) TEST_F(MaterialLibSolidsKelvinVector6, Determinant) { - auto f = [](KelvinVectorType<3> const& v) { + auto f = [](KelvinVectorType<3> const& v) + { return std::abs(Invariants<6>::determinant(v) - kelvinVectorToTensor(v).determinant()) <= std::numeric_limits<double>::epsilon() * @@ -95,7 +99,8 @@ TEST_F(MaterialLibSolidsKelvinVector6, Determinant) TEST_F(MaterialLibSolidsKelvinVector4, Inverse) { - auto f = [](KelvinVectorType<2> const& v) { + auto f = [](KelvinVectorType<2> const& v) + { auto const error = (inverse(v) - tensorToKelvin<2>(kelvinVectorToTensor(v).inverse())) .norm(); @@ -106,16 +111,20 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse) ac::check<KelvinVectorType<2>>( f, 1000, ac::make_arbitrary(kelvinVectorGenerator) - .discard_if([](KelvinVectorType<2> const& v) { - // only invertable matrices - return (std::abs(kelvinVectorToTensor(v).determinant()) == 0); - }), + .discard_if( + [](KelvinVectorType<2> const& v) + { + // only invertable matrices + return (std::abs(kelvinVectorToTensor(v).determinant()) == + 0); + }), gtest_reporter); } TEST_F(MaterialLibSolidsKelvinVector6, Inverse) { - auto f = [](KelvinVectorType<3> const& v) { + auto f = [](KelvinVectorType<3> const& v) + { auto const error = (inverse(v) - tensorToKelvin<3>(kelvinVectorToTensor(v).inverse())) .norm(); @@ -126,10 +135,13 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse) ac::check<KelvinVectorType<3>>( f, 1000, ac::make_arbitrary(kelvinVectorGenerator) - .discard_if([](KelvinVectorType<3> const& v) { - // only invertable matrices - return (std::abs(kelvinVectorToTensor(v).determinant()) == 0); - }), + .discard_if( + [](KelvinVectorType<3> const& v) + { + // only invertable matrices + return (std::abs(kelvinVectorToTensor(v).determinant()) == + 0); + }), gtest_reporter); } diff --git a/Tests/MathLib/TestGaussLegendreIntegration.cpp b/Tests/MathLib/TestGaussLegendreIntegration.cpp index 60e37487d45..7cb7bfb99fd 100644 --- a/Tests/MathLib/TestGaussLegendreIntegration.cpp +++ b/Tests/MathLib/TestGaussLegendreIntegration.cpp @@ -174,9 +174,8 @@ public: LocalAssemblerDataInterface::Function getClosure() const { - return [this](std::array<double, 3> const& coords) { - return this->operator()(coords); - }; + return [this](std::array<double, 3> const& coords) + { return this->operator()(coords); }; } virtual ~FBase() = default; diff --git a/Tests/MathLib/TestODESolver.cpp b/Tests/MathLib/TestODESolver.cpp index 91fc28af536..566f5a0e254 100644 --- a/Tests/MathLib/TestODESolver.cpp +++ b/Tests/MathLib/TestODESolver.cpp @@ -183,9 +183,8 @@ TEST(MathLibCVodeTest, ExponentialExtraData) ExtraData data; auto f_lambda = [&](double t, MathLib::ODE::MappedConstVector<1> const& y, - MathLib::ODE::MappedVector<1>& ydot) { - return f_extra(t, y, ydot, data); - }; + MathLib::ODE::MappedVector<1>& ydot) + { return f_extra(t, y, ydot, data); }; ode_solver->setFunction(f_lambda, nullptr); diff --git a/Tests/MathLib/TestPoint3d.cpp b/Tests/MathLib/TestPoint3d.cpp index 41d7bce3963..fad484968ac 100644 --- a/Tests/MathLib/TestPoint3d.cpp +++ b/Tests/MathLib/TestPoint3d.cpp @@ -35,7 +35,8 @@ struct MathLibPoint3d : public ::testing::Test TEST_F(MathLibPoint3d, ComparisonOperatorLessEqSamePoint) { // A point is always less or equal to itself and its copy. - auto samePointLessEqualCompare = [](MathLib::Point3d const& p) { + auto samePointLessEqualCompare = [](MathLib::Point3d const& p) + { const auto& q = p; return lessEq(p, p) && lessEq(p, q) && lessEq(q, p); }; @@ -52,7 +53,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessEqualLargePerturbation) // And the original point is always smaller or equal to the perturbed point. auto pointWithLargeAddedValue = [](MathLib::Point3d const& p, double const perturbation, - unsigned const coordinate) { + unsigned const coordinate) + { auto q = p; q[coordinate] = q[coordinate] + perturbation; return !lessEq(q, p) && lessEq(p, q); @@ -65,9 +67,9 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessEqualLargePerturbation) ac::make_arbitrary(pointGenerator, ac::map(&ac::absoluteValue, ac::generator<double>()), coordGenerator) - .discard_if( - [&eps](MathLib::Point3d const& /*unused*/, double const v, - unsigned const /*unused*/) { return !(v > eps); }), + .discard_if([&eps](MathLib::Point3d const& /*unused*/, + double const v, unsigned const /*unused*/) + { return !(v > eps); }), gtest_reporter); } @@ -78,7 +80,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessEqualSmallPerturbation) // coordinates is always less or equal to the original point. auto pointWithSmallAddedValue = [](MathLib::Point3d const& p, double const perturbation, - unsigned const coordinate) { + unsigned const coordinate) + { auto q = p; q[coordinate] = q[coordinate] + perturbation; return lessEq(p, q) && lessEq(q, p); @@ -97,7 +100,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessEqualSmallPerturbation) TEST_F(MathLibPoint3d, ComparisonOperatorEqualSamePoint) { // A point is always equal to itself and its copy. - auto samePointEqualCompare = [](MathLib::Point3d const& p) { + auto samePointEqualCompare = [](MathLib::Point3d const& p) + { const auto& q = p; return (p == p) && (p == q) && (q == p); }; @@ -113,7 +117,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorEqualLargePerturbation) // never equal to the original point. auto pointWithLargeAddedValue = [](MathLib::Point3d const& p, double const perturbation, - unsigned const coordinate) { + unsigned const coordinate) + { auto q = p; q[coordinate] = q[coordinate] + perturbation; return !(p == q) && !(q == p); @@ -125,9 +130,9 @@ TEST_F(MathLibPoint3d, ComparisonOperatorEqualLargePerturbation) pointWithLargeAddedValue, 10000, ac::make_arbitrary(pointGenerator, ac::generator<double>(), coordGenerator) - .discard_if( - [&eps](MathLib::Point3d const& /*unused*/, double const v, - unsigned const /*unused*/) { return !(v > eps); }), + .discard_if([&eps](MathLib::Point3d const& /*unused*/, + double const v, unsigned const /*unused*/) + { return !(v > eps); }), gtest_reporter); } @@ -138,7 +143,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorEqualSmallPerturbation) // coordinates is always equal to the original point. auto pointWithSmallAddedValue = [](MathLib::Point3d const& p, double const perturbation, - unsigned const coordinate) { + unsigned const coordinate) + { auto q = p; q[coordinate] = q[coordinate] + perturbation; return (p == q) && (q == p); @@ -158,7 +164,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorEqualSmallPerturbation) TEST_F(MathLibPoint3d, ComparisonOperatorLessSamePoint) { // A point is never less than itself or its copy. - auto samePointLessCompare = [](MathLib::Point3d const& p) { + auto samePointLessCompare = [](MathLib::Point3d const& p) + { const auto& q = p; return !(p < p) && !(p < q) && !(q < p); }; @@ -173,7 +180,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessLargePerturbation) // A point with any positive value added to one of its coordinates is // always larger then the original point. auto pointWithAddedValue = [](MathLib::Point3d const& p, double const eps, - unsigned const coordinate) { + unsigned const coordinate) + { auto q = p; q[coordinate] = q[coordinate] + eps; return (p < q) && !(q < p); @@ -195,7 +203,8 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessSmallPerturbation) // always smaller then the original point. auto pointWithSubtractedValue = [](MathLib::Point3d const& p, double const eps, - unsigned const coordinate) { + unsigned const coordinate) + { auto q = p; q[coordinate] = q[coordinate] - eps; return (q < p) && !(p < q); diff --git a/Tests/MeshGeoToolsLib/TestGeoMapper.cpp b/Tests/MeshGeoToolsLib/TestGeoMapper.cpp index 3a10444d911..95b51dd63d2 100644 --- a/Tests/MeshGeoToolsLib/TestGeoMapper.cpp +++ b/Tests/MeshGeoToolsLib/TestGeoMapper.cpp @@ -49,7 +49,8 @@ struct MeshGeoToolsLibGeoMapper : public ::testing::Test TEST_F(MeshGeoToolsLibGeoMapper, PointsOnSurfaceMesh) { auto testMapPointsOnMeshSurface = - [this](std::vector<GeoLib::Point>& pnts) -> bool { + [this](std::vector<GeoLib::Point>& pnts) -> bool + { GeoLib::GEOObjects geo_obj; std::string geo_name("TestGeoMapperPoints"); auto points = std::make_unique<std::vector<GeoLib::Point*>>(); diff --git a/Tests/MeshLib/ConvertToLinearMesh.cpp b/Tests/MeshLib/ConvertToLinearMesh.cpp index 86850d43995..f265d486448 100644 --- a/Tests/MeshLib/ConvertToLinearMesh.cpp +++ b/Tests/MeshLib/ConvertToLinearMesh.cpp @@ -55,8 +55,11 @@ std::variant<std::vector<std::size_t>, std::string> compareNodes( for (std::size_t i = 0; i < nnodes; ++i) { Node* a_node = a_nodes[i]; - auto const b_it = - std::find_if(begin(b_nodes), end(b_nodes), [&](Node* const b_node) { + auto const b_it = std::find_if( + begin(b_nodes), + end(b_nodes), + [&](Node* const b_node) + { return *a_node == *b_node; // coordinate comparison up to epsilon }); @@ -220,7 +223,8 @@ TEST_F(ConvertToLinearMesh, GeneratedHexMeshRandomizedNodes) << "Quadratic mesh nodes permutation test failed: " << *result; } - auto clone_element_using_permuted_nodes = [&](Element* const e) { + auto clone_element_using_permuted_nodes = [&](Element* const e) + { Node** nodes = new Node*[e->getNumberOfNodes()]; for (std::size_t i = 0; i < e->getNumberOfNodes(); ++i) { diff --git a/Tests/MeshLib/TestBoundaryElementSearch.cpp b/Tests/MeshLib/TestBoundaryElementSearch.cpp index 4f40788ed89..b0b2e1c43b5 100644 --- a/Tests/MeshLib/TestBoundaryElementSearch.cpp +++ b/Tests/MeshLib/TestBoundaryElementSearch.cpp @@ -197,9 +197,11 @@ TEST_F(MeshLibBoundaryElementSearchInSimpleQuadMesh, PolylineSearch) template <typename ElementIterator> double computeAreaOfFaceElements(ElementIterator first, ElementIterator last) { - return std::accumulate(first, last, 0.0, [](double v, MeshLib::Element* e) { - return v + e->getContent(); - }); + return std::accumulate(first, + last, + 0.0, + [](double v, MeshLib::Element* e) + { return v + e->getContent(); }); } void MeshLibBoundaryElementSearchInSimpleHexMesh:: diff --git a/Tests/MeshLib/TestFindElementsWithinRadius.cpp b/Tests/MeshLib/TestFindElementsWithinRadius.cpp index db8c6b838ed..3f5d87399da 100644 --- a/Tests/MeshLib/TestFindElementsWithinRadius.cpp +++ b/Tests/MeshLib/TestFindElementsWithinRadius.cpp @@ -34,7 +34,8 @@ TEST_F(MeshLibFindElementWithinRadius, ZeroRadius) auto mesh = std::unique_ptr<Mesh>(MeshGenerator::generateRegularQuadMesh(10., 10)); - auto same_element_returned = [&mesh](std::size_t& element_id) -> bool { + auto same_element_returned = [&mesh](std::size_t& element_id) -> bool + { auto result = findElementsWithinRadius(*mesh->getElement(element_id), 0.); return (result.size() == 1) && (result[0] == element_id); @@ -164,7 +165,8 @@ TEST_F(MeshLibFindElementWithinRadius, VeryLargeRadius) auto mesh = std::unique_ptr<Mesh>(MeshGenerator::generateRegularQuadMesh(10., 10)); - auto all_elements_returned = [&mesh](std::size_t& element_id) -> bool { + auto all_elements_returned = [&mesh](std::size_t& element_id) -> bool + { auto result = findElementsWithinRadius(*mesh->getElement(element_id), 1e5); BaseLib::makeVectorUnique(result); @@ -211,9 +213,8 @@ TEST_F(MeshLibFindElementWithinRadius, RandomPositiveRadius2d) compare_to_brute_force_search, 100, ac::make_arbitrary(ac::generator<std::size_t>(), ac::map(&ac::absoluteValue, ac::generator<double>())) - .discard_if([](std::size_t /*unused*/, double const r) { - return (r < 1e-16); - }), + .discard_if([](std::size_t /*unused*/, double const r) + { return (r < 1e-16); }), gtest_reporter); } @@ -230,8 +231,7 @@ TEST_F(MeshLibFindElementWithinRadius, RandomPositiveRadius3d) compare_to_brute_force_search, 100, ac::make_arbitrary(ac::generator<std::size_t>(), ac::map(&ac::absoluteValue, ac::generator<double>())) - .discard_if([](std::size_t /*unused*/, double const r) { - return (r < 1e-16); - }), + .discard_if([](std::size_t /*unused*/, double const r) + { return (r < 1e-16); }), gtest_reporter); } diff --git a/Tests/MeshLib/TestFlipElements.cpp b/Tests/MeshLib/TestFlipElements.cpp index a52871dccc9..05e9ed7d5f0 100644 --- a/Tests/MeshLib/TestFlipElements.cpp +++ b/Tests/MeshLib/TestFlipElements.cpp @@ -52,7 +52,8 @@ TEST(MeshLib, FlipTriMesh) ASSERT_EQ(mesh->getElement(i)->getNode(2)->getID(), result->getElement(i)->getNode(2)->getID()); ASSERT_EQ( - 1.0, MeshLib::FaceRule::getSurfaceNormal(*result->getElement(i))[2]); + 1.0, + MeshLib::FaceRule::getSurfaceNormal(*result->getElement(i))[2]); } } @@ -75,7 +76,8 @@ TEST(MeshLib, FlipQuadMesh) ASSERT_EQ(mesh->getElement(i)->getNode(3)->getID(), result->getElement(i)->getNode(2)->getID()); ASSERT_EQ( - 1.0, MeshLib::FaceRule::getSurfaceNormal(*result->getElement(i))[2]); + 1.0, + MeshLib::FaceRule::getSurfaceNormal(*result->getElement(i))[2]); } } diff --git a/Tests/MeshLib/TestLineMesh.cpp b/Tests/MeshLib/TestLineMesh.cpp index eafb0b122d2..e361fd29aeb 100644 --- a/Tests/MeshLib/TestLineMesh.cpp +++ b/Tests/MeshLib/TestLineMesh.cpp @@ -55,7 +55,8 @@ TEST_F(MeshLibLineMesh, Construction) TEST_F(MeshLibLineMesh, ElementNeigbors) { - auto count_neighbors = [](MeshLib::Element const* const e) { + auto count_neighbors = [](MeshLib::Element const* const e) + { unsigned count = 0; for (int i = 0; i < 2; i++) { diff --git a/Tests/MeshLib/TestMeshGenerator.cpp b/Tests/MeshLib/TestMeshGenerator.cpp index 3f5cdfcd05e..7eebd3ce09e 100644 --- a/Tests/MeshLib/TestMeshGenerator.cpp +++ b/Tests/MeshLib/TestMeshGenerator.cpp @@ -201,11 +201,10 @@ TEST(MeshLib, MeshGeneratorRegularPyramid) ASSERT_DOUBLE_EQ(L, node_n1[2]); // check if the domain volume equals the volume of the elements - long double const element_volumes = - std::accumulate(cbegin(msh->getElements()), cend(msh->getElements()), - 0., [](double const volume, auto* const element) { - return volume + element->computeVolume(); - }); + long double const element_volumes = std::accumulate( + cbegin(msh->getElements()), cend(msh->getElements()), 0., + [](double const volume, auto* const element) + { return volume + element->computeVolume(); }); EXPECT_NEAR(L * L * L, element_volumes, 1e-10); diff --git a/Tests/MeshLib/TestQuadMesh.cpp b/Tests/MeshLib/TestQuadMesh.cpp index 64a98ada4ec..5d8b17ba492 100644 --- a/Tests/MeshLib/TestQuadMesh.cpp +++ b/Tests/MeshLib/TestQuadMesh.cpp @@ -183,14 +183,14 @@ TEST_F(MeshLibQuadMesh, Construction) ASSERT_EQ(n_nodes * n_nodes, mesh->getNumberOfNodes()); // All elements have maximum four neighbors. - testAllElements([](MeshLib::Element const* const e, ...) { - ASSERT_EQ(4u, e->getNumberOfNeighbors()); - }); + testAllElements([](MeshLib::Element const* const e, ...) + { ASSERT_EQ(4u, e->getNumberOfNeighbors()); }); } TEST_F(MeshLibQuadMesh, ElementNeighbors) { - auto count_neighbors = [](MeshLib::Element const* const e) { + auto count_neighbors = [](MeshLib::Element const* const e) + { unsigned count = 0; for (int i = 0; i < 4; i++) { @@ -202,14 +202,14 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors) return count; }; - auto getNeighborIndices = [this](std::size_t const i, std::size_t const j) { - return std::make_pair(getNeighbor(i), getNeighbor(j)); - }; + auto getNeighborIndices = [this](std::size_t const i, std::size_t const j) + { return std::make_pair(getNeighbor(i), getNeighbor(j)); }; auto testNeighbors = [this](MeshLib::Element const* const e, std::size_t const i, std::size_t const j, - std::pair<Indices, Indices> const& neighbors) { + std::pair<Indices, Indices> const& neighbors) + { for (auto i_neighbor : neighbors.first) { ASSERT_TRUE(areNeighbors(e, getElement(i_neighbor, j))); @@ -222,63 +222,72 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors) }; // Two neighbors for corner elements. - testCornerElements([&](MeshLib::Element const* const e, std::size_t const i, - std::size_t const j) { - EXPECT_EQ(2u, count_neighbors(e)); + testCornerElements( + [&](MeshLib::Element const* const e, std::size_t const i, + std::size_t const j) + { + EXPECT_EQ(2u, count_neighbors(e)); - std::pair<Indices, Indices> const ij_neighbors = - getNeighborIndices(i, j); - // Test the test - EXPECT_EQ(1u, ij_neighbors.first.size()); - EXPECT_EQ(1u, ij_neighbors.second.size()); - ASSERT_TRUE(e->isBoundaryElement()); + std::pair<Indices, Indices> const ij_neighbors = + getNeighborIndices(i, j); + // Test the test + EXPECT_EQ(1u, ij_neighbors.first.size()); + EXPECT_EQ(1u, ij_neighbors.second.size()); + ASSERT_TRUE(e->isBoundaryElement()); - testNeighbors(e, i, j, ij_neighbors); - }); + testNeighbors(e, i, j, ij_neighbors); + }); // Three neighbors for boundary elements. - testBoundaryElements([&](MeshLib::Element const* const e, - std::size_t const i, std::size_t const j) { - EXPECT_EQ(3u, count_neighbors(e)); + testBoundaryElements( + [&](MeshLib::Element const* const e, std::size_t const i, + std::size_t const j) + { + EXPECT_EQ(3u, count_neighbors(e)); - std::pair<Indices, Indices> const ij_neighbors = - getNeighborIndices(i, j); - // Test the test - EXPECT_EQ(3u, ij_neighbors.first.size() + ij_neighbors.second.size()); - ASSERT_TRUE(e->isBoundaryElement()); + std::pair<Indices, Indices> const ij_neighbors = + getNeighborIndices(i, j); + // Test the test + EXPECT_EQ(3u, + ij_neighbors.first.size() + ij_neighbors.second.size()); + ASSERT_TRUE(e->isBoundaryElement()); - testNeighbors(e, i, j, ij_neighbors); - }); + testNeighbors(e, i, j, ij_neighbors); + }); // Four neighbors inside mesh. - testInsideElements([&](MeshLib::Element const* const e, std::size_t const i, - std::size_t const j) { - EXPECT_EQ(4u, count_neighbors(e)); - - std::pair<Indices, Indices> const ij_neighbors = - getNeighborIndices(i, j); - // Test the test - EXPECT_EQ(2u, ij_neighbors.first.size()); - EXPECT_EQ(2u, ij_neighbors.second.size()); - ASSERT_FALSE(e->isBoundaryElement()); - - testNeighbors(e, i, j, ij_neighbors); - }); + testInsideElements( + [&](MeshLib::Element const* const e, std::size_t const i, + std::size_t const j) + { + EXPECT_EQ(4u, count_neighbors(e)); + + std::pair<Indices, Indices> const ij_neighbors = + getNeighborIndices(i, j); + // Test the test + EXPECT_EQ(2u, ij_neighbors.first.size()); + EXPECT_EQ(2u, ij_neighbors.second.size()); + ASSERT_FALSE(e->isBoundaryElement()); + + testNeighbors(e, i, j, ij_neighbors); + }); } TEST_F(MeshLibQuadMesh, ElementToNodeConnectivity) { // An element (i,j) consists of four nodes (i,j), (i+1,j), (i+1, j+1), // and (i, j+1). - testAllElements([this](MeshLib::Element const* const e, - std::size_t const i, - std::size_t const j) { - EXPECT_EQ(4u, e->getNumberOfBaseNodes()); - EXPECT_EQ(getNode(i, j), e->getNode(0)); - EXPECT_EQ(getNode(i, j + 1), e->getNode(1)); - EXPECT_EQ(getNode(i + 1, j + 1), e->getNode(2)); - EXPECT_EQ(getNode(i + 1, j), e->getNode(3)); - }); + testAllElements( + [this](MeshLib::Element const* const e, + std::size_t const i, + std::size_t const j) + { + EXPECT_EQ(4u, e->getNumberOfBaseNodes()); + EXPECT_EQ(getNode(i, j), e->getNode(0)); + EXPECT_EQ(getNode(i, j + 1), e->getNode(1)); + EXPECT_EQ(getNode(i + 1, j + 1), e->getNode(2)); + EXPECT_EQ(getNode(i + 1, j), e->getNode(3)); + }); } // A node is connected to four elements inside the mesh, two on the boundary, diff --git a/Tests/NumLib/NewtonRaphson.cpp b/Tests/NumLib/NewtonRaphson.cpp index 5335ffe2bad..7f9aa9ab456 100644 --- a/Tests/NumLib/NewtonRaphson.cpp +++ b/Tests/NumLib/NewtonRaphson.cpp @@ -29,18 +29,14 @@ TEST(NumLibNewtonRaphson, Sqrt3) // Initial value double state = 1; - auto const update_jacobian = [&state](LocalJacobianMatrix& jacobian) { - jacobian(0, 0) = 2 * state; - }; - - auto const update_residual = [&state](LocalResidualVector& residual) { - residual[0] = state * state - 3; - }; - - auto const update_solution = - [&state](LocalResidualVector const& increment) { - state += increment[0]; - }; + auto const update_jacobian = [&state](LocalJacobianMatrix& jacobian) + { jacobian(0, 0) = 2 * state; }; + + auto const update_residual = [&state](LocalResidualVector& residual) + { residual[0] = state * state - 3; }; + + auto const update_solution = [&state](LocalResidualVector const& increment) + { state += increment[0]; }; auto const newton_solver = NumLib::NewtonRaphson<decltype(linear_solver), LocalJacobianMatrix, diff --git a/Tests/NumLib/TestExtrapolation.cpp b/Tests/NumLib/TestExtrapolation.cpp index 95712d625a3..2041c88ae2e 100644 --- a/Tests/NumLib/TestExtrapolation.cpp +++ b/Tests/NumLib/TestExtrapolation.cpp @@ -170,7 +170,8 @@ public: { auto cb = [](std::size_t id, LocalAssembler& loc_asm, NumLib::LocalToGlobalIndexMap const& dof_table, - GlobalVector const& x) { + GlobalVector const& x) + { auto const indices = NumLib::getIndices(id, dof_table); auto const local_x = x.get(indices); diff --git a/Tests/NumLib/TestMeshComponentMap.cpp b/Tests/NumLib/TestMeshComponentMap.cpp index 4248f571c50..991882f8ea7 100644 --- a/Tests/NumLib/TestMeshComponentMap.cpp +++ b/Tests/NumLib/TestMeshComponentMap.cpp @@ -153,9 +153,8 @@ MeshLib::Mesh createMeshFromSelectedNodes( std::vector<MeshLib::Node*> some_nodes; std::transform(begin(selected_nodes), end(selected_nodes), back_inserter(some_nodes), - [&mesh](std::size_t const node_id) { - return new MeshLib::Node(*mesh.getNode(node_id)); - }); + [&mesh](std::size_t const node_id) + { return new MeshLib::Node(*mesh.getNode(node_id)); }); // The resulting mesh without elements containing the selected nodes. MeshLib::Mesh result("boundary_mesh", some_nodes, {}); diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index 1e8bbafbeb3..a6f10074e06 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -96,7 +96,8 @@ public: sol.ts.push_back(t0); sol.solutions.push_back(x0); - auto cb = [&sol](const double t, GlobalVector const& x) { + auto cb = [&sol](const double t, GlobalVector const& x) + { sol.ts.push_back(t); sol.solutions.push_back(x); }; diff --git a/Tests/NumLib/TestSerialExecutor.cpp b/Tests/NumLib/TestSerialExecutor.cpp index 36f9349cae5..457d9294c53 100644 --- a/Tests/NumLib/TestSerialExecutor.cpp +++ b/Tests/NumLib/TestSerialExecutor.cpp @@ -61,9 +61,8 @@ public: static bool referenceIsZero(Container const& reference) { return std::all_of(reference.begin(), reference.end(), - [](ContainerElement const reference_value) { - return reference_value == 0; - }); + [](ContainerElement const reference_value) + { return reference_value == 0; }); } static std::size_t const size = 100; @@ -79,18 +78,23 @@ TYPED_TEST(NumLibSerialExecutor, ContainerArgument) using Container = typename TestFixture::Container; using PtrContainer = typename TestFixture::PtrContainer; - TestFixture::test([](PtrContainer const& ctnr, Container& ref) { - auto cb_static = [](Elem const value, std::size_t const index, - Container& ref_inner) { - TestFixture::subtractFromReferenceStatic(value, index, ref_inner); - }; + TestFixture::test( + [](PtrContainer const& ctnr, Container& ref) + { + auto cb_static = [](Elem const value, std::size_t const index, + Container& ref_inner) { + TestFixture::subtractFromReferenceStatic(value, index, + ref_inner); + }; - NumLib::SerialExecutor::executeDereferenced(cb_static, ctnr, ref); - }); + NumLib::SerialExecutor::executeDereferenced(cb_static, ctnr, ref); + }); - TestFixture::test([this](PtrContainer const& ctnr, Container& ref) { - NumLib::SerialExecutor::executeMemberDereferenced( - *static_cast<TestFixture*>(this), - &TestFixture::subtractFromReference, ctnr, ref); - }); + TestFixture::test( + [this](PtrContainer const& ctnr, Container& ref) + { + NumLib::SerialExecutor::executeMemberDereferenced( + *static_cast<TestFixture*>(this), + &TestFixture::subtractFromReference, ctnr, ref); + }); } diff --git a/Tests/NumLib/TestSerialLinearSolver.cpp b/Tests/NumLib/TestSerialLinearSolver.cpp index 4f9a64fc840..4855833954d 100644 --- a/Tests/NumLib/TestSerialLinearSolver.cpp +++ b/Tests/NumLib/TestSerialLinearSolver.cpp @@ -75,7 +75,8 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) auto local_asm_builder = [&](std::size_t const id, - MeshLib::Element const& item) -> LocalAssembler* { + MeshLib::Element const& item) -> LocalAssembler* + { assert(local_to_global_index_map.size() > id); auto const num_local_dof = diff --git a/Tests/NumLib/TestShapeFunctions.cpp b/Tests/NumLib/TestShapeFunctions.cpp index 5bccfd9192b..3ee0fb8a6ce 100644 --- a/Tests/NumLib/TestShapeFunctions.cpp +++ b/Tests/NumLib/TestShapeFunctions.cpp @@ -112,7 +112,8 @@ TYPED_TEST(ShapeFunctionTest, PartitionOfUnity) { auto isPartitionOfUnity = [](std::array<double, TypeParam::DIM>& natural_coordinates_point) - -> bool { + -> bool + { // compute shape functions std::array<double, TypeParam::NPOINTS> N; TypeParam::computeShapeFunction(natural_coordinates_point, N); @@ -132,7 +133,8 @@ TYPED_TEST(ShapeFunctionTest, SumOfGradientsIsZero) { auto isSumOfGradientsZero = [](std::array<double, TypeParam::DIM>& natural_coordinates_point) - -> bool { + -> bool + { // compute shape functions std::array<double, TypeParam::DIM * TypeParam::NPOINTS> dNdr; TypeParam::computeGradShapeFunction(natural_coordinates_point, dNdr); diff --git a/Tests/NumLib/TestShapeMatrices.cpp b/Tests/NumLib/TestShapeMatrices.cpp index 6ec85b400a1..1bda546394f 100644 --- a/Tests/NumLib/TestShapeMatrices.cpp +++ b/Tests/NumLib/TestShapeMatrices.cpp @@ -34,7 +34,8 @@ TEST(NumLib, FemShapeMatricesWithEigen) using ShapeMatricesType = ShapeMatrices<NodalVector, DimNodalMatrix, DimMatrix, DimNodalMatrix>; - auto setShapeDataToOnes = [](ShapeMatricesType& shape) { + auto setShapeDataToOnes = [](ShapeMatricesType& shape) + { shape.N.setOnes(); shape.dNdr.setOnes(); shape.dNdx.setOnes(); diff --git a/Tests/ParameterLib/Parameter.cpp b/Tests/ParameterLib/Parameter.cpp index 28e45c7b1b7..d78c4c6ca4c 100644 --- a/Tests/ParameterLib/Parameter.cpp +++ b/Tests/ParameterLib/Parameter.cpp @@ -116,7 +116,9 @@ bool testNodalValuesOfElement( double const t) { return std::all_of( - begin(elements), end(elements), [&](MeshLib::Element* const e) { + begin(elements), end(elements), + [&](MeshLib::Element* const e) + { // scalar values, 2 nodes. Eigen::Matrix<double, 2, 1> const nodal_values = parameter.getNodalValuesOnElement(*e, t); @@ -156,10 +158,9 @@ TEST_F(ParameterLibParameter, GetNodalValuesOnElement_constant) meshes); double const t = 0; - auto expected_value = [](MeshLib::Element* const /*e*/, - std::size_t const /*local_node_id*/) { - return 42.23; - }; + auto expected_value = + [](MeshLib::Element* const /*e*/, std::size_t const /*local_node_id*/) + { return 42.23; }; ASSERT_TRUE(testNodalValuesOfElement(meshes[0]->getElements(), expected_value, *parameter, t)); @@ -180,10 +181,9 @@ TEST_F(ParameterLibParameter, GetNodalValuesOnElement_node) double const t = 0; // For all elements all nodes have the value of the node id. - auto expected_value = [](MeshLib::Element* const e, - std::size_t const local_node_id) { - return static_cast<double>(e->getNode(local_node_id)->getID()); - }; + auto expected_value = + [](MeshLib::Element* const e, std::size_t const local_node_id) + { return static_cast<double>(e->getNode(local_node_id)->getID()); }; ASSERT_TRUE(testNodalValuesOfElement(meshes[0]->getElements(), expected_value, *parameter, t)); @@ -204,10 +204,9 @@ TEST_F(ParameterLibParameter, GetNodalValuesOnElement_element) double const t = 0; // For all elements all nodes have the value of the element id. - auto expected_value = [](MeshLib::Element* const e, - std::size_t const /*local_node_id*/) { - return static_cast<double>(e->getID()); - }; + auto expected_value = + [](MeshLib::Element* const e, std::size_t const /*local_node_id*/) + { return static_cast<double>(e->getID()); }; ASSERT_TRUE(testNodalValuesOfElement(meshes[0]->getElements(), expected_value, *parameter, t)); @@ -245,10 +244,9 @@ TEST_F(ParameterLibParameter, GetNodalValuesOnElement_curveScaledNode) double const t = 0.5; // For all elements all nodes have the value of the node id times the time. - auto expected_value = [&t](MeshLib::Element* const e, - std::size_t const local_node_id) { - return static_cast<double>(e->getNode(local_node_id)->getID()) * t; - }; + auto expected_value = + [&t](MeshLib::Element* const e, std::size_t const local_node_id) + { return static_cast<double>(e->getNode(local_node_id)->getID()) * t; }; ASSERT_TRUE(testNodalValuesOfElement(meshes[0]->getElements(), expected_value, *parameter, t)); diff --git a/Tests/ProcessLib/RichardsMechanics/MicroporosityComputation.cpp b/Tests/ProcessLib/RichardsMechanics/MicroporosityComputation.cpp index ba02d607a84..6a4bc6daa72 100644 --- a/Tests/ProcessLib/RichardsMechanics/MicroporosityComputation.cpp +++ b/Tests/ProcessLib/RichardsMechanics/MicroporosityComputation.cpp @@ -128,7 +128,8 @@ TEST(RichardsMechanics, computeMicroPorosity) double const alpha_B = 1; double const phi_M = 0.45; - auto saturation = [&](double const p_L) { + auto saturation = [&](double const p_L) + { MPL::VariableArray v; v[static_cast<int>(MPL::Variable::capillary_pressure)] = -p_L; return saturation_micro.template value<double>(v, pos, t0, dt); @@ -185,9 +186,10 @@ TEST(RichardsMechanics, computeMicroPorosity) // update state += state_increment; - if (std::find_if(begin(t_coords), end(t_coords), [&](auto const value) { - return std::abs(t - value) < eps; - }) != end(t_coords)) + if (std::find_if(begin(t_coords), end(t_coords), + [&](auto const value) { + return std::abs(t - value) < eps; + }) != end(t_coords)) { results.push_back(state); /* Keep for possible result updates @@ -234,13 +236,13 @@ TEST(RichardsMechanics, computeMicroPorosity) {-10063.017103021764, -10063.017103021764, -10063.017103021764, 0}}}; - auto eps_equal = [](double const a, double const b) { - return std::abs(a - b) < eps; - }; + auto eps_equal = [](double const a, double const b) + { return std::abs(a - b) < eps; }; auto const [mismatch_it_expected, mismatch_it_results] = std::mismatch( begin(expected_results), end(expected_results), begin(results), - [&](auto const& a, auto const& b) { + [&](auto const& a, auto const& b) + { EXPECT_TRUE(eps_equal(a.phi_m, b.phi_m)) << "with eps = " << eps; EXPECT_TRUE(eps_equal(a.e_sw, b.e_sw)) << "with eps = " << eps; EXPECT_TRUE(eps_equal(a.p_L_m / 1e9, b.p_L_m / 1e9)) diff --git a/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionEvaporation.cpp b/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionEvaporation.cpp index ff939f1ccb7..aaf763a946d 100644 --- a/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionEvaporation.cpp +++ b/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionEvaporation.cpp @@ -126,7 +126,8 @@ TEST(ProcessLib, TH2MPhaseTransitionEvaporation) variable_array[static_cast<int>( MaterialPropertyLib::Variable::temperature)] = T; - ptm->computeConstitutiveVariables(medium.get(), variable_array, pos, time, dt); + ptm->computeConstitutiveVariables(medium.get(), variable_array, pos, time, + dt); auto const& cv = ptm->cv; // reference values diff --git a/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionNone.cpp b/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionNone.cpp index 9844b8073d7..5a30e7e07c8 100644 --- a/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionNone.cpp +++ b/Tests/ProcessLib/TH2M/TestTH2MPhaseTransitionNone.cpp @@ -97,7 +97,8 @@ TEST(ProcessLib, TH2MPhaseTransitionNone) variable_array[static_cast<int>( MaterialPropertyLib::Variable::temperature)] = T; - ptm->computeConstitutiveVariables(medium.get(), variable_array, pos, time, dt); + ptm->computeConstitutiveVariables(medium.get(), variable_array, pos, time, + dt); auto const& cv = ptm->cv; // reference values diff --git a/Tests/testrunner.cpp b/Tests/testrunner.cpp index 35e99d19d0a..3549bc70e52 100644 --- a/Tests/testrunner.cpp +++ b/Tests/testrunner.cpp @@ -56,10 +56,12 @@ int main(int argc, char* argv[]) BaseLib::setConsoleLogLevel(logLevel); spdlog::set_pattern("%^%l:%$ %v"); - spdlog::set_error_handler([](const std::string& msg) { - std::cerr << "spdlog error: " << msg << std::endl; - OGS_FATAL("spdlog logger error occurred."); - }); + spdlog::set_error_handler( + [](const std::string& msg) + { + std::cerr << "spdlog error: " << msg << std::endl; + OGS_FATAL("spdlog logger error occurred."); + }); #ifdef USE_PETSC { // Can be called only after MPI_INIT. int mpi_rank; -- GitLab