Commit 960773d4 authored by Tobias Meisel's avatar Tobias Meisel
Browse files

Add tests

parent 7773dabe
/*#include <memory>
#include "MeshLib/IO/XDMF/HdfData.h"
#include "MeshLib/IO/XDMF/HdfWriter.h"
#include "gtest/gtest.h"
#include "mpi.h"
using namespace MeshLib::IO;
TEST(MeshLib, HdfWriter_topology)
{
int mpi_size;
int mpi_rank;
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
std::vector<int> v1(3753, 1);
std::vector<int> v2(3591, 2);
std::vector<int> v3(3753, 3);
std::vector<int> v;
if (mpi_rank == 0)
{
v = v1;
}
if (mpi_rank == 1)
{
v = v2;
}
if (mpi_rank == 2)
{
v = v3;
}
auto partition_dim = v.size();
auto size_tuple = 1;
auto datatype = MeshPropertyDataType::int32;
auto a = HdfData(v.data(), partition_dim, size_tuple, "test1", datatype);
auto b = HdfData(v.data(), partition_dim, size_tuple, "test2", datatype);
std::vector<HdfData> va = {a};
std::vector<HdfData> vb = {b};
auto hdf_writer =
std::make_unique<HdfWriter>(va, vb, 0, "HDFWriter_topology.h5");
// hdf_writer->writeStep(0);
ASSERT_EQ(1, 1);
}
TEST(MeshLib, HdfWriter_int_equal)
{
int mpi_size;
int mpi_rank;
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
std::vector<int> v1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> v2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> v3 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> v;
if (mpi_rank == 0)
{
v = v1;
}
if (mpi_rank == 1)
{
v = v2;
}
if (mpi_rank == 2)
{
v = v3;
}
auto partition_dim = v.size();
auto size_tuple = 1;
std::string name = "test";
auto datatype = MeshPropertyDataType::int32;
auto a = HdfData(v.data(), partition_dim, size_tuple, "test1", datatype);
auto b = HdfData(v.data(), partition_dim, size_tuple, "test2", datatype);
std::vector<HdfData> va = {a};
std::vector<HdfData> vb = {b};
auto hdf_writer =
std::make_unique<HdfWriter>(va, vb, 0, "HDFWriter_topology.h5");
hdf_writer->writeStep(0);
ASSERT_EQ(1, 1);
}
TEST(MeshLib, HdfWriter_int)
{
int mpi_size;
int mpi_rank;
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
std::vector<int> v1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> v2 = {10, 11, 12, 13};
std::vector<int> v3 = {20, 21, 22, 23, 24, 25};
std::vector<int> v;
if (mpi_rank == 0)
{
v = v1;
}
if (mpi_rank == 1)
{
v = v2;
}
if (mpi_rank == 2)
{
v = v3;
}
auto partition_dim = v.size();
auto size_tuple = 1;
std::string name = "test";
auto datatype = MeshPropertyDataType::int32;
auto a =
HdfData(v.data(), partition_dim, size_tuple, name.c_str(), datatype);
std::string nameb = "test_b";
auto b =
HdfData(v.data(), partition_dim, size_tuple, nameb.c_str(), datatype);
std::vector<HdfData> va = {a};
std::vector<HdfData> vb = {b};
auto hdf_writer =
std::make_unique<HdfWriter>(va, vb, 0, "HDFWriter_int.h5");
hdf_writer->writeStep(0);
ASSERT_EQ(1, 1);
}
TEST(MeshLib, HdfWriter_float)
{
int mpi_size;
int mpi_rank;
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
std::vector<float> v1 = {0.1, 1.1, 2.2, 3.3, 4.4,
5.5, 6.6, 7.7, 8.8, 9.987654321};
std::vector<float> v2 = {-10, 1234567890123456789., 12, 13};
std::vector<float> v3 = {.20, .021, .0022, .00023, .000024, .0000025};
std::vector<float> v;
if (mpi_rank == 0)
{
v = v1;
}
if (mpi_rank == 1)
{
v = v2;
}
if (mpi_rank == 2)
{
v = v3;
}
auto partition_dim = v.size();
auto size_tuple = 1;
std::string name = "test";
auto datatype = MeshPropertyDataType::float32;
auto a = HdfData(v.data(), partition_dim, size_tuple, "test1", datatype);
auto b = HdfData(v.data(), partition_dim, size_tuple, "test2", datatype);
std::vector<HdfData> va = {a};
std::vector<HdfData> vb = {b};
auto hdf_writer =
std::make_unique<HdfWriter>(va, vb, 0, "HDFWriter_float.h5");
hdf_writer->writeStep(0);
ASSERT_EQ(1, 1);
}*/
\ No newline at end of file
This diff is collapsed.
Supports Markdown
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