OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
MPIHelperTest.cpp
Go to the documentation of this file.
1 #include "Util/MPIHelper.h"
2 #include "gtest/gtest.h"
3 
4 namespace {
5 
6  // The fixture for testing class Foo.
7  class MPIHelperTest : public ::testing::Test {
8  protected:
9 
10  MPIHelperTest() {
11  // You can do set-up work for each test here.
12  }
13 
14  virtual ~MPIHelperTest() {
15  // You can do clean-up work that doesn't throw exceptions here.
16  }
17 
18  // If the constructor and destructor are not enough for setting up
19  // and cleaning up each test, you can define the following methods:
20 
21  virtual void SetUp() {
22  // Code here will be called immediately after the constructor (right
23  // before each test).
24  }
25 
26  virtual void TearDown() {
27  // Code here will be called immediately after each test (right
28  // before the destructor).
29  }
30 
31  // Objects declared here can be used by all tests in the test case
32  };
33 
34  TEST_F(MPIHelperTest, ParamSerialization) {
35 
36  Param_t params;
37  params.insert(std::pair<std::string, double>("a", 5.5));
38  params.insert(std::pair<std::string, double>("b", -15.2));
39 
40  std::ostringstream serialized;
41  serialize(params, serialized);
42 
43  Param_t deserialized_params;
44  deserialize(const_cast<char*>(serialized.str().c_str()),
45  deserialized_params);
46 
47  EXPECT_EQ(5.5, deserialized_params["a"])
48  << "first param not serialized properly";
49  EXPECT_EQ(-15.2, deserialized_params["b"])
50  << "second param not serialized properly";
51  }
52 
53 }
54 
55 int main(int argc, char **argv) {
56  ::testing::InitGoogleTest(&argc, argv);
57  return RUN_ALL_TESTS();
58 }
void serialize(Param_t params, std::ostringstream &os)
serializes params using Boost archive
Definition: MPIHelper.cpp:11
namedVariableCollection_t Param_t
Definition: Types.h:33
void deserialize(char *buffer, Param_t &params)
deserializes params using Boost archive
Definition: MPIHelper.cpp:23
int main(int argc, char *argv[])
Definition: Main.cpp:107