OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
PythonExprTest.cpp
Go to the documentation of this file.
1 #include <set>
2 #include <string>
3 
4 #include "Util/Types.h"
9 
10 #include "gtest/gtest.h"
11 
12 #include "boost/smart_ptr.hpp"
13 #include "boost/tuple/tuple.hpp"
14 #include "boost/variant/get.hpp"
15 #include "boost/variant/variant.hpp"
16 
17 
18 namespace {
19 
20  // The fixture for testing class Foo.
21  class PythonExprTest : public ::testing::Test {
22  protected:
23 
24  PythonExprTest() {
25  // You can do set-up work for each test here.
26  }
27 
28  virtual ~PythonExprTest() {
29  // You can do clean-up work that doesn't throw exceptions here.
30  }
31 
32  // If the constructor and destructor are not enough for setting up
33  // and cleaning up each test, you can define the following methods:
34 
35  virtual void SetUp() {
36  // Code here will be called immediately after the constructor (right
37  // before each test).
38  }
39 
40  virtual void TearDown() {
41  // Code here will be called immediately after each test (right
42  // before the destructor).
43  }
44  };
45 
46 
47  TEST_F(PythonExprTest, EvaluatePythonExpr) {
48 
50  double expected = 1.0;
51  expected *= 2.0;
52 
55  python = PythonExpression();
56  funcs.insert(std::pair<std::string, client::function::type>
57  ("python", python));
58 
59  std::string testexpr = "python(\"resources/test.py\", 1.0)";
60  boost::scoped_ptr<Expression> e(new Expression(testexpr, funcs));
61  Expressions::Result_t result;
62  EXPECT_NO_THROW({
63  result = e->evaluate(vars);
64  });
65 
66  ASSERT_EQ(expected, boost::get<0>(result));
67  ASSERT_TRUE(boost::get<1>(result));
68  }
69 
70 }
71 
72 int main(int argc, char **argv) {
73  ::testing::InitGoogleTest(&argc, argv);
74  return RUN_ALL_TESTS();
75 }
constexpr double e
The value of .
Definition: Physics.h:40
Expression to be evaluated in the framework.
Definition: Expression.h:75
boost::tuple< double, bool > Result_t
Definition: Expression.h:37
int main(int argc, char *argv[])
Definition: Main.cpp:107
boost::function< boost::tuple< double, bool >arguments_t)> type
Definition: function.hpp:21
std::map< std::string, double > variableDictionary_t
Definition: Expression.h:26
std::map< std::string, client::function::type > functionDictionary_t
Definition: Expression.h:27