Commit 1130d6b6 authored by niklas.baumgarten's avatar niklas.baumgarten

updated test

parent 083bdb08
......@@ -142,8 +142,8 @@ TEST(TestParallel, TestSplit) {
EXPECT_EQ(PPM->Size(1), PPM->Size(0) / 2);
EXPECT_EQ(PPM->Proc(1) + PPM->Color(1) * PPM->Size(1), PPM->Proc(0));
PPM->PrintInfo(0);
PPM->PrintInfo(1);
// PPM->PrintInfo(0);
// PPM->PrintInfo(1);
}
TEST(TestParallel, TestDoubleSplit) {
......@@ -153,28 +153,71 @@ TEST(TestParallel, TestDoubleSplit) {
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);
// PPM->PrintInfo(0);
// PPM->PrintInfo(1);
// PPM->PrintInfo(2);
}
TEST(TestParallel, TestIntegerMinSplit) {
int a;
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;
EXPECT_EQ(PPM->Min(a), 0);
PPM->SplitCommunicators();
if (PPM->Master(1)) a = 2;
if (!PPM->Master(1)) a = 1;
EXPECT_EQ(PPM->Min(a), 1);
if (PPM->Master(1)) a = 1;
if (!PPM->Master(1)) a = 2;
EXPECT_EQ(PPM->Min(a), 1);
}
TEST(TestParallel, TestExchangeBuffer) {
ExchangeBuffer exBuffer;
std::string mSend = "message";
std::string mRecv;
const char *mSendA = "A";
const char *mSendB = "B";
const char *mSendC = "C";
const char *mSendD = "D";
/*
* p = 0: ABC
* p = 1: AB
* p = 2: A
* p = 3: D
*/
int q = 0;
if (PPM->Proc() == q) {
exBuffer.Send(0) << mSendA << mSendB;
exBuffer.Send(1) << mSendA;
exBuffer.Send(2) << mSendA;
exBuffer.Send(1) << mSendB;
exBuffer.Send(0) << mSendC;
exBuffer.Send(3) << mSendD;
}
exBuffer.Communicate();
for (int q = 0; q < PPM->Size(); q++) {
exBuffer.Send(q) << mSend;
exBuffer.Communicate();
char *mRecv;
std::string mRecvStr = "";
if (q+1 != PPM->Size())
exBuffer.Receive(q) >> mRecv;
else
exBuffer.Receive(q) >> mRecv;
// for(int p = 0; p < PPM->Size(); p++) {}
int p = 0;
if (PPM->Proc() == p) {
while (exBuffer.Receive(p).size() < exBuffer.ReceiveSize((p))) {
exBuffer.Receive(p) >> mRecv;
mRecvStr += mRecv;
}
}
EXPECT_EQ(mSend, mRecv);
std::cout << mRecvStr << endl;
}
......
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