From 25075c0f9101d47df0d952e63b4ae135d6173eaf Mon Sep 17 00:00:00 2001 From: Lukas Riedel Date: Thu, 22 Aug 2019 20:23:08 +0200 Subject: [PATCH] Fix boundary condition manager test Make tests properly fail if they never evaluate the respective expressions. Update grid configuration to only contain a single cell. --- .../test/test-boundary-condition-manager.cc | 22 ++++++++++++++----- .../test/test-boundary-condition.mini.in | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dune/dorie/test/test-boundary-condition-manager.cc b/dune/dorie/test/test-boundary-condition-manager.cc index 8425ccc6..13aa6e52 100644 --- a/dune/dorie/test/test-boundary-condition-manager.cc +++ b/dune/dorie/test/test-boundary-condition-manager.cc @@ -40,6 +40,8 @@ using BC = Dune::Dorie::BoundaryCondition; /* ------------------------------------------------------------------------- */ // Test BC factory creating BCs from YAML nodes +// This tests checks if the construction throws appropriate exceptions for +// incompatible input. /// BCFactory fixture. Create three factories with a different mode each. class BCFactory : public ::testing::Test @@ -59,7 +61,7 @@ protected: void SetUp () override { - auto [inifile, log, helper] = Dune::Dorie::Setup::init(_argc, _argv); + auto log = Dune::Dorie::create_logger(Dune::Dorie::log_base, helper); _bcf_none = std::make_unique>(log); _bcf_richards = std::make_unique>(log); _bcf_transport = std::make_unique>(log); @@ -126,6 +128,7 @@ TEST_F(BCFactory, Outflow) /* ------------------------------------------------------------------------- */ // Test BC manager and loaded BC data. +// This verifies that YAML data is properly interpreted /// BoundaryConditionManager fixture /** \tparam T BCMMode wrapped into an integral constant to appear as type @@ -199,7 +202,7 @@ TEST_F(BCManager, Neumann) auto gv = _grid->leafGridView(); auto cell = *Dune::elements(gv).begin(); if (not cell.hasBoundaryIntersections()) { - ADD_FAILURE(); + FAIL(); } for (auto&& is : Dune::intersections(gv, cell)) { const auto coords = is.geometry().center(); @@ -220,8 +223,11 @@ TEST_F(BCManager, Neumann) dynamic_cast&>(*bc); EXPECT_TRUE(bc_neumann.horizontal_projection()); } + return; } } + + FAIL(); } TEST_F(BCManager, Dirichlet) @@ -229,7 +235,7 @@ TEST_F(BCManager, Dirichlet) auto gv = _grid->leafGridView(); auto cell = *Dune::elements(gv).begin(); if (not cell.hasBoundaryIntersections()) { - ADD_FAILURE(); + FAIL(); } for (auto&& is : Dune::intersections(gv, cell)) { const auto coords = is.geometry().center(); @@ -259,8 +265,11 @@ TEST_F(BCManager, Dirichlet) EXPECT_EQ(bc->type(), Operator::BCType::Neumann); EXPECT_DOUBLE_EQ(bc->evaluate(time), 0.0); } + return; } } + + FAIL(); } TEST_F(BCManager, Outflow) @@ -268,11 +277,11 @@ TEST_F(BCManager, Outflow) auto gv = _grid->leafGridView(); auto cell = *Dune::elements(gv).begin(); if (not cell.hasBoundaryIntersections()) { - ADD_FAILURE(); + FAIL(); } for (auto&& is : Dune::intersections(gv, cell)) { const auto coords = is.geometry().center(); - if (Dune::FloatCmp::eq(coords[1], 1.0)) + if (Dune::FloatCmp::eq(coords[0], 0.0)) { for (auto time: {0.0, 1.0, 1.5, 1.9}) { _manager->set_time(time); @@ -284,8 +293,11 @@ TEST_F(BCManager, Outflow) EXPECT_DOUBLE_EQ(time_int.begin, 0.0); EXPECT_DOUBLE_EQ(time_int.end, 2.0); } + return; } } + + FAIL(); } // --- Main Function --- // diff --git a/dune/dorie/test/test-boundary-condition.mini.in b/dune/dorie/test/test-boundary-condition.mini.in index 26f51ca0..f1d9875b 100644 --- a/dune/dorie/test/test-boundary-condition.mini.in +++ b/dune/dorie/test/test-boundary-condition.mini.in @@ -5,7 +5,7 @@ _asset_path = "${PROJECT_SOURCE_DIR}/test" [grid] dimensions = 2 -initialLevel = 1 +initialLevel = 0 gridType = rectangular cells = 1 1 extensions = 1 1 -- GitLab