preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
9BOOST_AUTO_TEST_CASE(LocateInvalidId)
10{
12 using namespace precice;
13 using namespace precice::mesh;
14 mesh::Mesh mesh("2D Testmesh", 2, testing::nextMeshID());
15 auto v1 = mesh.createVertex(Eigen::Vector2d::Zero()).getID();
16 auto v2 = mesh.createVertex(Eigen::Vector2d::Ones()).getID();
17
18 using VIDs = std::vector<VertexID>;
19
20 {
21 auto index = locateInvalidVertexID(mesh, VIDs{v1, v2, 99});
22 BOOST_TEST(index.has_value());
23 BOOST_TEST(index.value() == 2);
24 }
25 {
26 auto index = locateInvalidVertexID(mesh, VIDs{99, v1, v2});
27 BOOST_TEST(index.has_value());
28 BOOST_TEST(index.value() == 0);
29 }
30 {
31 auto index = locateInvalidVertexID(mesh, VIDs{99, v1, v2, 99});
32 BOOST_TEST(index.has_value());
33 BOOST_TEST(index.value() == 0);
34 }
35 {
36 auto index = locateInvalidVertexID(mesh, VIDs{v1, v2, 99, v1, v2});
37 BOOST_TEST(index.has_value());
38 BOOST_TEST(index.value() == 2);
39 }
40 {
41 auto index = locateInvalidVertexID(mesh, VIDs{99});
42 BOOST_TEST(index.has_value());
43 BOOST_TEST(index.value() == 0);
44 }
45 {
46 auto index = locateInvalidVertexID(mesh, VIDs{v1, v2});
47 BOOST_TEST(!index.has_value());
48 }
49 {
50 auto index = locateInvalidVertexID(mesh, VIDs{});
51 BOOST_TEST(!index.has_value());
52 }
53 {
54 auto index = locateInvalidVertexID(mesh, VIDs{99});
55 BOOST_TEST(index.has_value());
56 BOOST_TEST(index.value() == 0);
57 }
58}
59
BOOST_AUTO_TEST_SUITE(PreProcess)
unsigned int index
#define PRECICE_TEST()
Definition Testing.hpp:39
#define PRECICE_TEST_SETUP(...)
Creates and attaches a TestSetup to a Boost test case.
Definition Testing.hpp:29
BOOST_AUTO_TEST_CASE(LocateInvalidId)
Definition UtilsTest.cpp:9
BOOST_AUTO_TEST_SUITE_END()
Container and creator for meshes.
Definition Mesh.hpp:38
Vertex & createVertex(const Eigen::Ref< const Eigen::VectorXd > &coords)
Creates and initializes a Vertex object.
Definition Mesh.cpp:105
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
Definition Vertex.hpp:109
provides Mesh, Data and primitives.
Main namespace of the precice library.