preCICE v3.2.0
Loading...
Searching...
No Matches
TXTWriterReaderTest.cpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include "io/TXTReader.hpp"
3#include "io/TXTWriter.hpp"
4#include "logging/Logger.hpp"
6#include "testing/Testing.hpp"
7
9
10using namespace precice;
11using namespace precice::io;
12
14BOOST_AUTO_TEST_CASE(TXTWriterReaderTest)
15{
17 {
18 Eigen::Matrix<double, 1, 2> output(1, 2);
19 {
20 TXTWriter txtWriter("io-TXTWriterReaderTest-matrix-1by2.log");
21 txtWriter.write(output);
22 }
23 Eigen::Matrix<double, 1, 2> input(1, 2);
24 TXTReader txtReader("io-TXTWriterReaderTest-matrix-1by2.log");
25 txtReader.read(input);
26 BOOST_TEST(testing::equals(output, input));
27 }
28
29 {
30 Eigen::Matrix<double, 2, 1> output(1, 2);
31 {
32 TXTWriter txtWriter("io-TXTWriterReaderTest-matrix-2by1.log");
33 txtWriter.write(output);
34 }
35 Eigen::Matrix<double, 2, 1> input(1, 2);
36 TXTReader txtReader("io-TXTWriterReaderTest-matrix-2by1.log");
37 txtReader.read(input);
38 BOOST_TEST(testing::equals(output, input));
39 }
40
41 {
42 Eigen::Matrix<double, 3, 3> matOutput;
43 matOutput << 1, 2, 3, 4, 5, 6, 7, 8, 9;
44 Eigen::VectorXd vecOutput = Eigen::VectorXd::Constant(1, 1);
45
46 {
47 TXTWriter txtWriter("io-TXTWriterReaderTest-matrix-3by3.log");
48 txtWriter.write(matOutput);
49 txtWriter.write(vecOutput);
50 }
51
52 Eigen::Matrix<double, 3, 3> matInput;
53 TXTReader txtReader("io-TXTWriterReaderTest-matrix-3by3.log");
54 txtReader.read(matInput);
55 BOOST_TEST(testing::equals(matOutput, matInput));
56
57 Eigen::VectorXd vecInput(1);
58 txtReader.read(vecInput);
59 BOOST_TEST(testing::equals(vecOutput, vecInput));
60 }
61
62 {
63 Eigen::Vector3d output(1, 2, 3);
64 {
65 TXTWriter txtWriter("io-TXTWriterReaderTest-vector-3.log");
66 txtWriter.write(output);
67 }
68
69 Eigen::Vector3d input;
70 TXTReader txtReader("io-TXTWriterReaderTest-vector-3.log");
71 txtReader.read(input);
72 BOOST_TEST(testing::equals(output, input));
73 }
74}
75
BOOST_AUTO_TEST_CASE(testIQNIMVJPPWithSubsteps)
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
File reader for matrix/vector in Matlab V7 ASCII format.
Definition TXTReader.hpp:15
void read(Eigen::Matrix< Scalar, Rows, Cols > &matrix)
Reads the Eigen::Matrix from the file.
Definition TXTReader.hpp:22
File writer for matrix in Matlab V7 ASCII format.
Definition TXTWriter.hpp:13
void write(const Eigen::MatrixXd &matrix)
Writes (appends) the matrix to the file.
Definition TXTWriter.cpp:24
provides Import and Export of the coupling mesh and data.
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.