Skip to content

replace std::shared_future with boost::shared_future #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 24, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
new test to cover the ready() wrapper
it does not compile now
  • Loading branch information
dvd0101 committed Sep 18, 2016
commit d5df753e415b954c92092145bd89c97a09d6a58d
1 change: 1 addition & 0 deletions libs/network/test/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ if (Boost_FOUND)
client_get_test
client_get_different_port_test
# client_get_timeout_test
client_get_ready_test
client_get_streaming_test)
foreach ( test ${TESTS} )
add_executable(cpp-netlib-http-${test} ${test}.cpp)
Expand Down
34 changes: 34 additions & 0 deletions libs/network/test/http/client_get_ready_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2010 Dean Michael Berris.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <gtest/gtest.h>
#include <boost/network/include/http/client.hpp>
#include "client_types.hpp"

namespace net = boost::network;
namespace http = boost::network::http;
using tclock = std::chrono::high_resolution_clock;

TYPED_TEST_CASE(HTTPClientTest, ClientTypes);

TYPED_TEST(HTTPClientTest, GetTest) {
using client = TypeParam;
typename client::request request("http://cpp-netlib.org/");
client client_;
auto response = client_.get(request);
while (!http::ready(response)) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
auto t0 = tclock::now();
auto data = body(response);
auto t1 = tclock::now();
EXPECT_TRUE(response.status() == 200u ||
(response.status() >= 300 && response.status() < 400));
EXPECT_TRUE(data.size() > 0);

// XXX we should find a better way to check if `ready()` has done his job
namespace c = std::chrono;
EXPECT_TRUE(c::duration_cast<c::milliseconds>(t1-t0).count() < 1);
}