preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VertexTest.cpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include <iosfwd>
3#include <string>
4#include "logging/Logger.hpp"
5#include "mesh/Vertex.hpp"
7#include "testing/Testing.hpp"
8
9using namespace precice;
10
11BOOST_AUTO_TEST_SUITE(MeshTests)
12BOOST_AUTO_TEST_SUITE(VertexTests)
13
16{
18 mesh::Vertex vertex(Eigen::Vector3d::Constant(1.0), 0);
19
20 Eigen::Vector3d coords = vertex.getCoords();
21 BOOST_TEST(testing::equals(coords, Eigen::Vector3d::Constant(1.0)));
22
23 int id = vertex.getID();
24 BOOST_TEST(id == 0);
25}
26
28BOOST_AUTO_TEST_CASE(VertexEquality)
29{
31 using namespace mesh;
32 using namespace Eigen;
33 Vertex v1(Vector3d::Constant(4.0), 0);
34 Vertex v2(Vector3d::Constant(4.0), 1);
35 Vertex v3(Vector3d::Constant(2.0), 0);
36 BOOST_TEST(v1 == v2);
37 BOOST_TEST(v1 != v3);
38 BOOST_TEST(v2 != v3);
39}
40
42BOOST_AUTO_TEST_CASE(VertexWKTPrint)
43{
45 using namespace mesh;
46 Vertex v1(Eigen::Vector2d(1., 2.), 0);
47 std::stringstream v1stream;
48 v1stream << v1;
49 std::string v1str("POINT (1 2)");
50 BOOST_TEST(v1str == v1stream.str());
51 Vertex v2(Eigen::Vector3d(1., 2., 3.), 0);
52 std::stringstream v2stream;
53 v2stream << v2;
54 std::string v2str("POINT (1 2 3)");
55 BOOST_TEST(v2str == v2stream.str());
56}
57
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#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(Vertices)
Vertex of a mesh.
Definition Vertex.hpp:16
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
Definition Vertex.hpp:109
Eigen::VectorXd getCoords() const
Returns the coordinates of the vertex.
Definition Vertex.hpp:114
boost::test_tools::predicate_result equals(const std::vector< float > &VectorA, const std::vector< float > &VectorB, float tolerance)
equals to be used in tests. Compares two std::vectors using a given tolerance. Prints both operands o...
Definition Testing.cpp:93
Main namespace of the precice library.
T str(T... args)