preCICE v3.1.1
Loading...
Searching...
No Matches
UtilsTest.cpp
Go to the documentation of this file.
1#include "mesh/Utils.hpp"
2#include "testing/Testing.hpp"
3
5
6BOOST_AUTO_TEST_SUITE(UtilsTests)
7
8BOOST_AUTO_TEST_CASE(LocateInvalidId)
9{
10 using namespace precice;
11 using namespace precice::mesh;
12 mesh::Mesh mesh("2D Testmesh", 2, testing::nextMeshID());
13 auto v1 = mesh.createVertex(Eigen::Vector2d::Zero()).getID();
14 auto v2 = mesh.createVertex(Eigen::Vector2d::Ones()).getID();
15
16 using VIDs = std::vector<VertexID>;
17
18 {
19 auto index = locateInvalidVertexID(mesh, VIDs{v1, v2, 99});
20 BOOST_TEST(index.has_value());
21 BOOST_TEST(index.value() == 2);
22 }
23 {
24 auto index = locateInvalidVertexID(mesh, VIDs{99, v1, v2});
25 BOOST_TEST(index.has_value());
26 BOOST_TEST(index.value() == 0);
27 }
28 {
29 auto index = locateInvalidVertexID(mesh, VIDs{99, v1, v2, 99});
30 BOOST_TEST(index.has_value());
31 BOOST_TEST(index.value() == 0);
32 }
33 {
34 auto index = locateInvalidVertexID(mesh, VIDs{v1, v2, 99, v1, v2});
35 BOOST_TEST(index.has_value());
36 BOOST_TEST(index.value() == 2);
37 }
38 {
39 auto index = locateInvalidVertexID(mesh, VIDs{99});
40 BOOST_TEST(index.has_value());
41 BOOST_TEST(index.value() == 0);
42 }
43 {
44 auto index = locateInvalidVertexID(mesh, VIDs{v1, v2});
45 BOOST_TEST(!index.has_value());
46 }
47 {
48 auto index = locateInvalidVertexID(mesh, VIDs{});
49 BOOST_TEST(!index.has_value());
50 }
51 {
52 auto index = locateInvalidVertexID(mesh, VIDs{99});
53 BOOST_TEST(index.has_value());
54 BOOST_TEST(index.value() == 0);
55 }
56}
57
BOOST_AUTO_TEST_SUITE(PreProcess)
unsigned int index
BOOST_AUTO_TEST_CASE(LocateInvalidId)
Definition UtilsTest.cpp:8
BOOST_AUTO_TEST_SUITE_END()
Container and creator for meshes.
Definition Mesh.hpp:39
Vertex & createVertex(const Eigen::VectorXd &coords)
Creates and initializes a Vertex object.
Definition Mesh.cpp:103
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
Definition Vertex.hpp:111
provides Mesh, Data and primitives.
Main namespace of the precice library.