tanghai пре 15 година
родитељ
комит
124b5e4964
1 измењених фајлова са 25 додато и 0 уклоњено
  1. 25 0
      src/experimental/boost_function_test.cc

+ 25 - 0
src/experimental/boost_function_test.cc

@@ -2,14 +2,39 @@
 //      Author: tanghai
 //      Author: tanghai
 
 
 #include <boost/function.hpp>
 #include <boost/function.hpp>
+#include <boost/bind.hpp>
 #include <gtest/gtest.h>
 #include <gtest/gtest.h>
 #include <gflags/gflags.h>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 #include <glog/logging.h>
 
 
+class BoostTest: public testing::Test
+{
+	void SetUp()
+	{
+		a = 6;
+	}
+protected:
+	int a;
+	boost::function<int (int)> func;
+public:
+	int Max(int a, int b)
+	{
+		LOG(INFO) << a << " " << b;
+		return a > b? a : b;
+	}
+};
 
 
+TEST_F(BoostTest, Test1)
+{
+	int x = 5;
+	func = boost::bind(&BoostTest::Max, boost::ref(*this), _1, x);
+	int b = func(a);
+	LOG(INFO) << b;
+}
 
 
 int main(int argc, char* argv[])
 int main(int argc, char* argv[])
 {
 {
+	FLAGS_logtostderr = true;
 	google::ParseCommandLineFlags(&argc, &argv, true);
 	google::ParseCommandLineFlags(&argc, &argv, true);
 	google::InitGoogleLogging(argv[0]);
 	google::InitGoogleLogging(argv[0]);
 	testing::InitGoogleTest(&argc, argv);
 	testing::InitGoogleTest(&argc, argv);