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/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
index 7bd8aa0..c056a5d 100644
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -33,6 +33,7 @@
#include <boost/random.hpp>
#include <boost/type_traits.hpp>
#include <boost/test/unit_test.hpp>
+#include <boost/version.hpp>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/TFDTransport.h>
@@ -919,6 +920,12 @@
rand4k);
}
+#if (BOOST_VERSION >= 105900)
+#define MAKE_TEST_CASE(_FUNC, _NAME) boost::unit_test::make_test_case(_FUNC, _NAME, __FILE__, __LINE__)
+#else
+#define MAKE_TEST_CASE(_FUNC, _NAME) boost::unit_test::make_test_case(_FUNC, _NAME)
+#endif
+
private:
template <class CoupledTransports>
void addTestRW(const char* transport_name,
@@ -937,7 +944,11 @@
<< rSizeGen.describe() << ", " << wChunkSizeGen.describe() << ", "
<< rChunkSizeGen.describe() << ", " << maxOutstanding << ")";
+#if (BOOST_VERSION >= 105900)
+ boost::function<void ()> test_func
+#else
boost::unit_test::callback0<> test_func
+#endif
= apache::thrift::stdcxx::bind(test_rw<CoupledTransports>,
totalSize,
wSizeGen,
@@ -945,39 +956,30 @@
wChunkSizeGen,
rChunkSizeGen,
maxOutstanding);
- boost::unit_test::test_case* tc = boost::unit_test::make_test_case(test_func, name.str());
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_func, name.str()), expectedFailures);
}
template <class CoupledTransports>
void addTestBlocking(const char* transportName, uint32_t expectedFailures = 0) {
char name[1024];
- boost::unit_test::test_case* tc;
THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available()", transportName);
- tc = boost::unit_test::make_test_case(test_read_part_available<CoupledTransports>, name);
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_read_part_available<CoupledTransports>, name), expectedFailures);
THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available_in_chunks()", transportName);
- tc = boost::unit_test::make_test_case(test_read_part_available_in_chunks<CoupledTransports>,
- name);
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_read_part_available_in_chunks<CoupledTransports>, name), expectedFailures);
THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_partial_midframe()", transportName);
- tc = boost::unit_test::make_test_case(test_read_partial_midframe<CoupledTransports>, name);
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_read_partial_midframe<CoupledTransports>, name), expectedFailures);
THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_none_available()", transportName);
- tc = boost::unit_test::make_test_case(test_read_none_available<CoupledTransports>, name);
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_read_none_available<CoupledTransports>, name), expectedFailures);
THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_part_available()", transportName);
- tc = boost::unit_test::make_test_case(test_borrow_part_available<CoupledTransports>, name);
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_borrow_part_available<CoupledTransports>, name), expectedFailures);
THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_none_available()", transportName);
- tc = boost::unit_test::make_test_case(test_borrow_none_available<CoupledTransports>, name);
- suite_->add(tc, expectedFailures);
+ suite_->add(MAKE_TEST_CASE(test_borrow_none_available<CoupledTransports>, name), expectedFailures);
}
boost::unit_test::test_suite* suite_;
@@ -1016,7 +1018,11 @@
}
};
+#if (BOOST_VERSION >= 105900)
+BOOST_GLOBAL_FIXTURE(global_fixture);
+#else
BOOST_GLOBAL_FIXTURE(global_fixture)
+#endif
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
THRIFT_UNUSED_VARIABLE(argc);