Commit 30b3be1c authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Made all the tests pass

parent e12418cd
Pipeline #17943285 passed with stages
in 4 minutes and 49 seconds
......@@ -31,7 +31,7 @@ TEST_CASE("Fourier Transforms", "[fft]") {
REQUIRE(test[1].real() == 1.0);
REQUIRE(test[1].imag() == 1.0);
test[10] = std::complex<float>(5.0, 1.0);
test[1] = std::complex<float>(5.0, 1.0);
REQUIRE(test[1].real() == 5.0);
REQUIRE(test[1].imag() == 1.0);
}
......@@ -27,66 +27,68 @@ using namespace stemsalabim;
TEST_CASE("MPI operations that require MPI Environment", "[mpi]") {
mpi::Environment &env = mpi::Environment::getInstance();
REQUIRE(env.isMpi());
if(env.isMpi()) {
SECTION("testing float vector") {
SECTION("testing float vector") {
std::vector<float> bla(100, 0);
std::vector<float> bla(100, 0);
if(env.isMaster()) {
if(env.isMaster()) {
for(unsigned int i = 1; i < bla.size(); i++)
bla[i] = bla[i - 1] + (float) i;
for(unsigned int i = 1; i < bla.size(); i++)
bla[i] = bla[i - 1] + (float) i;
env.send(bla, 1, 0);
} else if(env.rank() == 1) {
env.recv(bla, 0, MPI_ANY_TAG);
REQUIRE(bla[1] == 1);
REQUIRE(bla[2] == 3);
env.send(bla, 1, 0);
} else if(env.rank() == 1) {
env.recv(bla, 0, MPI_ANY_TAG);
REQUIRE(bla[1] == 1);
REQUIRE(bla[2] == 3);
}
}
}
SECTION("testing double vector") {
SECTION("testing double vector") {
std::vector<double> bla(100, 0);
std::vector<double> bla(100, 0);
if(env.isMaster()) {
if(env.isMaster()) {
for(unsigned int i = 1; i < bla.size(); i++)
bla[i] = bla[i - 1] + (double) i;
for(unsigned int i = 1; i < bla.size(); i++)
bla[i] = bla[i - 1] + (double) i;
env.send(bla, 1, 0);
} else if(env.rank() == 1) {
env.recv(bla, 0, MPI_ANY_TAG);
REQUIRE(bla[1] == 1);
REQUIRE(bla[2] == 3);
env.send(bla, 1, 0);
} else if(env.rank() == 1) {
env.recv(bla, 0, MPI_ANY_TAG);
REQUIRE(bla[1] == 1);
REQUIRE(bla[2] == 3);
}
}
}
SECTION("testing string send/recv") {
std::string bla;
SECTION("testing string send/recv") {
std::string bla;
if(env.isMaster()) {
bla = "abc";
env.send(bla, 1, 0);
} else if(env.rank() == 1) {
env.recv(bla, 0, MPI_ANY_TAG);
REQUIRE(!bla.compare("abc"));
}
if(env.isMaster()) {
bla = "abc";
env.send(bla, 1, 0);
} else if(env.rank() == 1) {
env.recv(bla, 0, MPI_ANY_TAG);
REQUIRE(!bla.compare("abc"));
}
}
SECTION("Testing string broadcast") {
SECTION("Testing string broadcast") {
std::string bla;
std::string bla;
if(env.isMaster())
bla = "abc";
if(env.isMaster())
bla = "abc";
env.broadcast(bla, 0);
env.broadcast(bla, 0);
if(env.isSlave())
REQUIRE(!bla.compare("abc"));
}
if(env.isSlave())
REQUIRE(!bla.compare("abc"));
}
}
......
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