PythonInitTest.cc 794 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <gtest/gtest.h>
  2. #include <gflags/gflags.h>
  3. #include <glog/logging.h>
  4. #include "Python/PythonInit.h"
  5. namespace Egametang {
  6. class PythonInitTest: public testing::Test
  7. {
  8. public:
  9. PythonInitTest(): python_init()
  10. {}
  11. protected:
  12. PythonInit python_init;
  13. };
  14. TEST_F(PythonInitTest, Int)
  15. {
  16. boost::python::object i(10);
  17. i = 10 * i;
  18. ASSERT_EQ(100, boost::python::extract<int>(i));
  19. }
  20. TEST_F(PythonInitTest, String)
  21. {
  22. boost::python::object i("ab");
  23. std::string str = boost::python::extract<std::string>(i * 5);
  24. ASSERT_EQ("ababababab", str);
  25. }
  26. } // namespace Egametang
  27. int main(int argc, char* argv[])
  28. {
  29. FLAGS_logtostderr = true;
  30. testing::InitGoogleTest(&argc, argv);
  31. google::ParseCommandLineFlags(&argc, &argv, true);
  32. google::InitGoogleLogging(argv[0]);
  33. return RUN_ALL_TESTS();
  34. }