diff --git a/test/TestUtils.hpp b/test/TestUtils.hpp index 867cc3f..e6375de 100644 --- a/test/TestUtils.hpp +++ b/test/TestUtils.hpp @@ -6,24 +6,21 @@ #include #include -using namespace std; -using namespace Eigen; +inline Eigen::MatrixXd CSV2Eigen(std::string file2Convert) { -inline MatrixXd CSV2Eigen(string file2Convert) { + std::vector matrixEntries; - vector matrixEntries; - - ifstream matrixDataFile(file2Convert); + std::ifstream matrixDataFile(file2Convert); if (matrixDataFile.fail()) { - throw invalid_argument("File probably non-existent!"); + throw std::invalid_argument("File probably non-existent!"); } - string matrixRowString; - string matrixEntry; + std::string matrixRowString; + std::string matrixEntry; int matrixRowNumber = 0; while (getline(matrixDataFile, matrixRowString)) { - stringstream matrixRowStringStream(matrixRowString); + std::stringstream matrixRowStringStream(matrixRowString); while (getline(matrixRowStringStream, matrixEntry, ' ')) { matrixEntries.push_back(stod(matrixEntry)); } @@ -32,18 +29,21 @@ inline MatrixXd CSV2Eigen(string file2Convert) { } } - return Map>( + return Eigen::Map< + Eigen::Matrix>( matrixEntries.data(), matrixRowNumber, matrixEntries.size() / matrixRowNumber); } -inline bool checkSimilarity(MatrixXd a, MatrixXd b, double precision = 1e-5) { +inline bool checkSimilarity(Eigen::MatrixXd a, Eigen::MatrixXd b, + double precision = 1e-5) { return a.isApprox(b, precision); } -inline bool checkSimilarityV2(MatrixXd a, MatrixXd b, double maxDiff) { +inline bool checkSimilarityV2(Eigen::MatrixXd a, Eigen::MatrixXd b, + double maxDiff) { - MatrixXd diff = a - b; + Eigen::MatrixXd diff = a - b; double maxCoeff = diff.maxCoeff(); return abs(maxCoeff) < maxDiff; } diff --git a/test/testBoundary.cpp b/test/testBoundary.cpp index 640c2d9..7d7fe46 100644 --- a/test/testBoundary.cpp +++ b/test/testBoundary.cpp @@ -5,6 +5,8 @@ #include #include +using namespace std; + TEST_CASE("BoundaryElement") { SUBCASE("Closed case") { @@ -71,4 +73,4 @@ TEST_CASE("Boundary Class") { CHECK_EQ(boundary2D.getBoundaryElement(BC_SIDE_LEFT, 0).getType(), boundary1DVector[0].getType()); } -} \ No newline at end of file +} diff --git a/test/testGrid.cpp b/test/testGrid.cpp index ea16f6f..a1f2886 100644 --- a/test/testGrid.cpp +++ b/test/testGrid.cpp @@ -2,6 +2,10 @@ #include #include +using namespace Eigen; +using namespace std; + + TEST_CASE("1D Grid, too small length") { int l = 2; CHECK_THROWS(Grid(l)); @@ -246,4 +250,4 @@ TEST_CASE("2D Grid non-quadratic") { dr = -2; CHECK_THROWS(grid.setDomain(dr, dc)); } -} \ No newline at end of file +} diff --git a/test/testSimulation.cpp b/test/testSimulation.cpp index 49a930d..004799a 100644 --- a/test/testSimulation.cpp +++ b/test/testSimulation.cpp @@ -8,6 +8,9 @@ // include the configured header file #include +using namespace Eigen; +using namespace std; + static Grid setupSimulation(APPROACH approach, double timestep, int iterations) { int row = 11;