fix format string to be msvc compatible and work-around issue with boost.asio beeing header-only and instantiating multiple error_category objects when linking shared

This commit is contained in:
arvidn 2015-11-22 22:58:01 -05:00 committed by arvidn
parent e3dad98fbe
commit 710e510c4b
2 changed files with 12 additions and 4 deletions

@ -1 +1 @@
Subproject commit 99d708a8a9048cf154d961f3017279278d80af36
Subproject commit 280ceb21803add122b31fd0a4ab950547817bf87

View File

@ -89,7 +89,7 @@ std::string chunk_string(std::string s)
{
i = std::min(i, s.size());
char header[50];
snprintf(header, sizeof(header), "%zx\r\n", i);
snprintf(header, sizeof(header), "%x\r\n", int(i));
ret += header;
ret += s.substr(0, i);
s.erase(s.begin(), s.begin() + i);
@ -121,7 +121,15 @@ boost::shared_ptr<http_connection> test_request(io_service& ios
printf("RESPONSE: %s\n", url.c_str());
++*handler_called;
if (ec != expected_error)
// this is pretty gross. Since boost.asio is a header-only library, when this test is
// build against shared libraries of libtorrent and simulator, there will be multiple
// (distinct) error categories in boost.asio. The traditional comparison of error_code
// and error_condition may hence fail.
const bool error_ok = ec == expected_error
|| (strcmp(ec.category().name(), expected_error.category().name()) == 0
&& ec.value() == expected_error.value());
if (!error_ok)
{
printf("ERROR: %s (expected: %s)\n"
, ec.message().c_str()
@ -133,7 +141,7 @@ boost::shared_ptr<http_connection> test_request(io_service& ios
{
TEST_EQUAL(size, expected_size);
}
TEST_EQUAL(ec, expected_error);
TEST_CHECK(error_ok);
if (expected_status != -1)
{
TEST_EQUAL(http_status, expected_status);