Commit 077f8e77 authored by Max Lyon's avatar Max Lyon

add more file tests

parent 7ac1c33b
Pipeline #11533 passed with stage
in 7 minutes and 3 seconds
......@@ -27,7 +27,7 @@
bool HexEx::writeToFile(std::string fileName, TetrahedralMesh& mesh, PerCellVertexProperty<Parameter>& parameters)
{
std::ofstream filestream(fileName, std::ofstream::binary);
std::ofstream filestream(fileName, std::ofstream::out);
return writeToStream(filestream, mesh, parameters);
// return writeToStreamBinary(filestream, mesh, parameters);
}
......@@ -35,7 +35,7 @@ bool HexEx::writeToFile(std::string fileName, TetrahedralMesh& mesh, PerCellVert
bool HexEx::readFromFile(std::string fileName, TetrahedralMesh& mesh, PerCellVertexProperty<Parameter>& parameters)
{
std::ifstream filestream(fileName, std::ifstream::binary);
std::ifstream filestream(fileName, std::ifstream::in);
if (!filestream.is_open())
{
std::cout << "could not open " << fileName << std::endl;
......
......@@ -22,6 +22,8 @@
#include "common.hh"
#include <HexExtractor.hh>
#include <OpenVolumeMesh/FileManager/FileManager.hh>
using namespace HexEx;
TEST(CellExtraction, CellExtractionTest)
......@@ -50,6 +52,9 @@ TEST(CellExtraction, CellExtractionTest)
EXPECT_EQ(expectedNumberOfCells, hexMesh.n_cells()) << "Size: " << size;
OpenVolumeMesh::IO::FileManager fileManager;
fileManager.writeFile(std::string("Results/Cube_") + std::to_string(size) + ".ovm", hexMesh);
}
}
......@@ -72,6 +77,9 @@ TEST(CellExtraction, CellExtractionMasterVertexTest)
EXPECT_EQ(expectedNumberOfCells, hexMesh.n_cells());
OpenVolumeMesh::IO::FileManager fileManager;
fileManager.writeFile("Results/MasterVertex.ovm", hexMesh);
}
TEST(CellExtraction, CellExtractionPrismTest)
......@@ -91,36 +99,46 @@ TEST(CellExtraction, CellExtractionPrismTest)
EXPECT_EQ(expectedNumberOfCells, hexMesh.n_cells());
OpenVolumeMesh::IO::FileManager fileManager;
fileManager.writeFile("Results/prism.ovm", hexMesh);
}
TEST(CellExtraction, CellExtractionFiveAdvancedTest)
void test_file(const std::string& _filename, size_t _n_expected_cells)
{
std::string filename = "testdata/fiveadvanced.hexex";
std::string filename = "testdata/" + _filename + ".hexex";
HexExtractor hexExtractor(filename);
ASSERT_GE(hexExtractor.getInputMesh().n_cells(), 0) << "could not load mesh";
ASSERT_GT(hexExtractor.getInputMesh().n_cells(), 0) << "could not load mesh";
hexExtractor.extract();
HexahedralMesh hexMesh;
hexExtractor.getHexMesh(hexMesh);
EXPECT_GE(hexMesh.n_cells(), 0) << "nothing extracted";
EXPECT_EQ(hexMesh.n_cells(), _n_expected_cells) << "Not correctly extracted";
OpenVolumeMesh::IO::FileManager fileManager;
fileManager.writeFile("Results/" + _filename + ".ovm", hexMesh);
}
TEST(CellExtraction, CellExtractionFiveAdvancedTest)
{
test_file("fiveadvanced", 96);
}
TEST(CellExtraction, CellExtractionFiveFineTest)
{
std::string filename = "testdata/fiveFine.hexex";
HexExtractor hexExtractor(filename);
ASSERT_GE(hexExtractor.getInputMesh().n_cells(), 0) << "could not load mesh";
hexExtractor.extract();
test_file("fiveFine", 4416);
}
HexahedralMesh hexMesh;
hexExtractor.getHexMesh(hexMesh);
TEST(CellExtraction, CellExtractionSphereTest)
{
test_file("sphere", 216);
}
EXPECT_GE(hexMesh.n_cells(), 0) << "nothing extracted";
TEST(CellExtraction, CellExtractionCylinderTest)
{
test_file("cylinderadvanced", 140);
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment