THRIFT-3329: fix C++ tests incompatibility with boost-1.59
Client: C++
Patch: James E. King, III <jim.king@simplivity.com>
This closes #620
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index cf628ed..fa237a2 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -32,9 +32,11 @@
#include <iostream>
#include <thrift/cxxfunctional.h>
+#include <boost/function.hpp>
#include <boost/random.hpp>
#include <boost/shared_array.hpp>
#include <boost/test/unit_test.hpp>
+#include <boost/version.hpp>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/TZlibTransport.h>
@@ -328,16 +330,28 @@
* Initialization
*/
-#define ADD_TEST_CASE(suite, name, function, ...) \
+#if (BOOST_VERSION >= 105900)
+#define ADD_TEST_CASE(suite, name, _FUNC, ...) \
do { \
::std::ostringstream name_ss; \
- name_ss << name << "-" << BOOST_STRINGIZE(function); \
+ name_ss << name << "-" << BOOST_STRINGIZE(_FUNC); \
+ boost::function<void ()> test_func = ::apache::thrift::stdcxx::bind(_FUNC, ##__VA_ARGS__); \
::boost::unit_test::test_case* tc \
- = ::boost::unit_test::make_test_case(::apache::thrift::stdcxx::bind(function, \
+ = ::boost::unit_test::make_test_case(test_func, name_ss.str(), __FILE__, __LINE__); \
+ (suite)->add(tc); \
+ } while (0)
+#else
+#define ADD_TEST_CASE(suite, name, _FUNC, ...) \
+ do { \
+ ::std::ostringstream name_ss; \
+ name_ss << name << "-" << BOOST_STRINGIZE(_FUNC); \
+ ::boost::unit_test::test_case* tc \
+ = ::boost::unit_test::make_test_case(::apache::thrift::stdcxx::bind(_FUNC, \
##__VA_ARGS__), \
name_ss.str()); \
(suite)->add(tc); \
} while (0)
+#endif
void add_tests(boost::unit_test::test_suite* suite,
const boost::shared_array<uint8_t>& buf,