Commit e33dbd62 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

implementing tests for SmapleCounter

parent 6c265c41
......@@ -27,3 +27,4 @@ add_mpp_test(pdesolver/TestPDESolver PDESOLVER)
add_mpi_test(TestMain MONTECARLO)
add_mpi_test(montecarlo/TestMonteCarlo MONTECARLO)
add_mpi_test(pdesolver/TestPDESolver PDESOLVER)
add_mpi_test(montecarlo/datastructure/TestSampleCounter MONTECARLO)
\ No newline at end of file
#include "TestSampleCounter.hpp"
int main(int argc, char **argv) {
return MppTest(
MppTestBuilder(argc, argv).
WithParallelListeners().
WithScreenLogging().
WithPPM()
).RUN_ALL_MPP_TESTS();
}
\ No newline at end of file
#ifndef TESTSAMPLECOUNTER_HPP
#define TESTSAMPLECOUNTER_HPP
#include "TestEnvironment.hpp"
#include "montecarlo/datastructure/SampleCounter.hpp"
class TestSampleCounter : public Test {
protected:
int commSplit;
int dM;
SampleCounter ctr;
TestSampleCounter() {
PPM->FullSplit();
}
void TearDown() {
PPM->Barrier(0);
PPM->ClearCommunicators(false);
}
};
TEST_F(TestSampleCounter, TestWith8Samples) {
ctr = SampleCounter(8);
if (PPM->Size(0) == 8) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 1);
EXPECT_EQ(ctr.commSplit, 3);
}
if (PPM->Size(0) == 4) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 2);
EXPECT_EQ(ctr.commSplit, 2);
}
if (PPM->Size(0) == 2) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 4);
EXPECT_EQ(ctr.commSplit, 1);
}
if (PPM->Size(0) == 1) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 8);
EXPECT_EQ(ctr.commSplit, 0);
}
}
TEST_F(TestSampleCounter, TestWith4Samples) {
ctr = SampleCounter(4);
if (PPM->Size(0) == 8) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 1);
EXPECT_EQ(ctr.commSplit, 2);
}
if (PPM->Size(0) == 4) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 1);
EXPECT_EQ(ctr.commSplit, 2);
}
if (PPM->Size(0) == 2) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 2);
EXPECT_EQ(ctr.commSplit, 1);
}
if (PPM->Size(0) == 1) {
pout << "dMComm " << ctr.dMComm << " commSplit " << ctr.commSplit << endl;
EXPECT_EQ(ctr.dMComm, 4);
EXPECT_EQ(ctr.commSplit, 0);
}
}
#endif //TESTSAMPLECOUNTER_HPP
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