Skip to content
Snippets Groups Projects
Commit ecbe1b99 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add few tests for MeshVariant

parent 3368ffff
Branches
Tags
1 merge request!182Get rid of IMesh (mesh interface class) and use MeshVariant instead
......@@ -197,6 +197,7 @@ add_executable (mpi_unit_tests
test_MeshLineNodeBoundary.cpp
test_MeshNodeBoundary.cpp
test_MeshNodeInterface.cpp
test_MeshVariant.cpp
test_Messenger.cpp
test_OFStream.cpp
test_ParallelChecker_read.cpp
......
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include <MeshDataBaseForTests.hpp>
#include <mesh/Mesh.hpp>
#include <mesh/MeshVariant.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE("MeshVariant", "[mesh]")
{
SECTION("1D")
{
auto mesh_v = MeshDataBaseForTests::get().unordered1DMesh();
auto mesh = mesh_v->get<Mesh<1>>();
const std::string error_msg =
R"(error: invalid mesh type type
- required Mesh<3ul>
- contains Mesh<1ul>)";
REQUIRE_THROWS_WITH(mesh_v->get<Mesh<3>>(), error_msg);
REQUIRE(mesh->id() == mesh_v->id());
REQUIRE(mesh->numberOfCells() == mesh_v->numberOfCells());
REQUIRE(mesh->numberOfFaces() == mesh_v->numberOfFaces());
REQUIRE(mesh->numberOfEdges() == mesh_v->numberOfEdges());
REQUIRE(mesh->numberOfNodes() == mesh_v->numberOfNodes());
{
std::ostringstream os_v;
os_v << *mesh_v;
std::ostringstream os;
os << *mesh;
REQUIRE(os_v.str() == os.str());
}
}
SECTION("2D")
{
auto mesh_v = MeshDataBaseForTests::get().hybrid2DMesh();
auto mesh = mesh_v->get<Mesh<2>>();
const std::string error_msg =
R"(error: invalid mesh type type
- required Mesh<1ul>
- contains Mesh<2ul>)";
REQUIRE_THROWS_WITH(mesh_v->get<Mesh<1>>(), error_msg);
REQUIRE(mesh->id() == mesh_v->id());
REQUIRE(mesh->numberOfCells() == mesh_v->numberOfCells());
REQUIRE(mesh->numberOfFaces() == mesh_v->numberOfFaces());
REQUIRE(mesh->numberOfEdges() == mesh_v->numberOfEdges());
REQUIRE(mesh->numberOfNodes() == mesh_v->numberOfNodes());
{
std::ostringstream os_v;
os_v << *mesh_v;
std::ostringstream os;
os << *mesh;
REQUIRE(os_v.str() == os.str());
}
}
SECTION("3D")
{
auto mesh_v = MeshDataBaseForTests::get().hybrid3DMesh();
auto mesh = mesh_v->get<Mesh<3>>();
const std::string error_msg =
R"(error: invalid mesh type type
- required Mesh<2ul>
- contains Mesh<3ul>)";
REQUIRE_THROWS_WITH(mesh_v->get<Mesh<2>>(), error_msg);
REQUIRE(mesh->id() == mesh_v->id());
REQUIRE(mesh->numberOfCells() == mesh_v->numberOfCells());
REQUIRE(mesh->numberOfFaces() == mesh_v->numberOfFaces());
REQUIRE(mesh->numberOfEdges() == mesh_v->numberOfEdges());
REQUIRE(mesh->numberOfNodes() == mesh_v->numberOfNodes());
{
std::ostringstream os_v;
os_v << *mesh_v;
std::ostringstream os;
os << *mesh;
REQUIRE(os_v.str() == os.str());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment