Commit 7271536f authored by niklas.baumgarten's avatar niklas.baumgarten

test adaption

parent dbcceb94
Pipeline #121054 failed with stages
in 7 minutes and 7 seconds
......@@ -7,18 +7,13 @@ TEST(TestParallel, TestIsInitialized) {
}
TEST(TestParallel, TestBroadcastDouble) {
if (PPM->master()) PPM->BroadcastDouble(1.0);
if (!PPM->master()) EXPECT_DOUBLE_EQ(PPM->BroadcastDouble(), 1.0);
if (PPM->Master()) PPM->BroadcastDouble(1.0);
if (!PPM->Master()) EXPECT_DOUBLE_EQ(PPM->BroadcastDouble(), 1.0);
}
TEST(TestParallel, TestBroadcastInt) {
if (PPM->master()) PPM->BroadcastInt(1);
if (!PPM->master()) EXPECT_EQ(PPM->BroadcastInt(), 1);
}
TEST(TestParallel, TestBroadcastInt2) {
if (PPM->master()) PPM->Broadcast(1);
if (!PPM->master()) EXPECT_EQ(1, PPM->Broadcast<int>());
if (PPM->Master()) PPM->BroadcastInt(1);
if (!PPM->Master()) EXPECT_EQ(PPM->BroadcastInt(), 1);
}
struct BroadcastStruct {
......@@ -34,121 +29,128 @@ struct BroadcastStruct {
TEST(TestParallel, TestBroadcast) {
const BroadcastStruct structToBroadcast(0);
BroadcastStruct structFromBroadcast(1);
if (PPM->master())
if (PPM->Master())
PPM->Broadcast(structToBroadcast);
if (!PPM->master()) {
if (!PPM->Master()) {
PPM->Broadcast(structFromBroadcast);
EXPECT_TRUE(structFromBroadcast == structToBroadcast);
}
}
TEST(TestParallel, TestProc) {
if (PPM->master()) EXPECT_EQ(PPM->proc(), 0);
if (!PPM->master()) EXPECT_NE(PPM->proc(), 0);
if (PPM->Master()) EXPECT_EQ(PPM->Proc(), 0);
if (!PPM->Master()) EXPECT_NE(PPM->Proc(), 0);
}
TEST(TestParallel, TestSize) {
int testSize;
MPI_Comm_size(MPI_COMM_WORLD, &testSize);
EXPECT_EQ(PPM->size(), testSize);
EXPECT_EQ(PPM->Size(), testSize);
}
TEST(TestParallel, TestIntegerSum) {
int a = 1;
EXPECT_EQ(PPM->Sum(a), PPM->size());
EXPECT_EQ(PPM->Sum(a), PPM->Size());
}
TEST(TestParallel, TestDoubleSum) {
double a = 1.0;
EXPECT_DOUBLE_EQ(PPM->Sum(a), (double) PPM->size());
EXPECT_DOUBLE_EQ(PPM->Sum(a), (double) PPM->Size());
}
TEST(TestParallel, TestSizeTypeSum) {
size_t a = sizeof(int);
EXPECT_EQ(PPM->Sum(a), (size_t) a * PPM->size());
EXPECT_EQ(PPM->Sum(a), (size_t) a * PPM->Size());
}
TEST(TestParallel, TestComplexSum) {
std::complex<double> a{1.0, 1.0};
std::complex<double> b{std::real(a) * PPM->size(), std::imag(a) * PPM->size()};
std::complex<double> b{std::real(a) * PPM->Size(), std::imag(a) * PPM->Size()};
EXPECT_EQ(PPM->Sum(a), b);
}
TEST(TestParallel, TestIntegerMin) {
int a;
if (PPM->master()) a = 1;
if (!PPM->master()) a = 0;
if (PPM->Master()) a = 1;
if (!PPM->Master()) a = 0;
EXPECT_EQ(PPM->Min(a), 0);
if (PPM->master()) a = 0;
if (!PPM->master()) a = 1;
if (PPM->Master()) a = 0;
if (!PPM->Master()) a = 1;
EXPECT_EQ(PPM->Min(a), 0);
}
TEST(TestParallel, TestDoubleMin) {
double a;
if (PPM->master()) a = 1.0;
if (!PPM->master()) a = 0.0;
if (PPM->Master()) a = 1.0;
if (!PPM->Master()) a = 0.0;
EXPECT_DOUBLE_EQ(PPM->Min(a), 0.0);
if (PPM->master()) a = 0.0;
if (!PPM->master()) a = 1.0;
if (PPM->Master()) a = 0.0;
if (!PPM->Master()) a = 1.0;
EXPECT_DOUBLE_EQ(PPM->Min(a), 0.0);
}
TEST(TestParallel, TestUnsignedIntegerMin) {
long unsigned int a;
if (PPM->master()) a = 1;
if (!PPM->master()) a = 0;
if (PPM->Master()) a = 1;
if (!PPM->Master()) a = 0;
EXPECT_EQ(PPM->Min(a), 0);
if (PPM->master()) a = 0;
if (!PPM->master()) a = 1;
if (PPM->Master()) a = 0;
if (!PPM->Master()) a = 1;
EXPECT_EQ(PPM->Min(a), 0);
}
TEST(TestParallel, TestIntegerMax) {
int a;
if (PPM->master()) a = 1;
if (!PPM->master()) a = 0;
if (PPM->Master()) a = 1;
if (!PPM->Master()) a = 0;
EXPECT_EQ(PPM->Max(a), 1);
if (PPM->master()) a = 0;
if (!PPM->master()) a = 1;
if (PPM->Master()) a = 0;
if (!PPM->Master()) a = 1;
EXPECT_EQ(PPM->Max(a), 1);
}
TEST(TestParallel, TestDoubleMax) {
double a;
if (PPM->master()) a = 1.0;
if (!PPM->master()) a = 0.0;
if (PPM->Master()) a = 1.0;
if (!PPM->Master()) a = 0.0;
EXPECT_DOUBLE_EQ(PPM->Max(a), 1.0);
if (PPM->master()) a = 0.0;
if (!PPM->master()) a = 1.0;
if (PPM->Master()) a = 0.0;
if (!PPM->Master()) a = 1.0;
EXPECT_DOUBLE_EQ(PPM->Max(a), 1.0);
}
TEST(TestParallel, TestUnsignedIntMax) {
long unsigned int a;
if (PPM->master()) a = 1;
if (!PPM->master()) a = 0;
if (PPM->Master()) a = 1;
if (!PPM->Master()) a = 0;
EXPECT_EQ(PPM->Max(a), 1);
if (PPM->master()) a = 0;
if (!PPM->master()) a = 1;
if (PPM->Master()) a = 0;
if (!PPM->Master()) a = 1;
EXPECT_EQ(PPM->Max(a), 1);
}
TEST(TestParallel, TestSplitCommunicators) {
TEST(TestParallel, TestSplit) {
PPM->SplitCommunicators();
EXPECT_EQ(PPM->size(1), PPM->size(0) / 2);
EXPECT_EQ(PPM->proc(1) + PPM->Color(1) * 2, PPM->proc(0));
EXPECT_EQ(PPM->Size(1), PPM->Size(0) / 2);
EXPECT_EQ(PPM->Proc(1) + PPM->Color(1) * PPM->Size(1), PPM->Proc(0));
PPM->GetComm(0)->PrintInfo();
PPM->GetComm(1)->PrintInfo();
PPM->PrintInfo(0);
PPM->PrintInfo(1);
}
// PPM->SplitCommunicators();
// EXPECT_EQ(PPM->size(2), PPM->size(0) / 4);
// EXPECT_EQ(PPM->size(2), PPM->size(1) / 2);
// EXPECT_EQ(PPM->proc(2) + PPM->Color(2) * 4, PPM->proc(0));
// EXPECT_EQ(PPM->proc(2) + PPM->Color(2) * 2, PPM->proc(1));
TEST(TestParallel, TestDoubleSplit) {
PPM->SplitCommunicators();
PPM->SplitCommunicators();
EXPECT_EQ(PPM->Size(2), PPM->Size(0) / 4);
EXPECT_EQ(PPM->Size(2), PPM->Size(1) / 2);
EXPECT_EQ(PPM->Proc(2) + PPM->Color(2) * PPM->Size(2), PPM->Proc(1));
PPM->PrintInfo(0);
PPM->PrintInfo(1);
PPM->PrintInfo(2);
}
int main(int argc, char **argv) {
return MppTest(
MppTestBuilder(argc, argv).
......
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