Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5df753

Browse files
committed
new test to cover theready() wrapper
it does not compile now
1 parenta97ab01 commitd5df753

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

‎libs/network/test/http/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ if (Boost_FOUND)
3838
client_get_test
3939
client_get_different_port_test
4040
# client_get_timeout_test
41+
client_get_ready_test
4142
client_get_streaming_test)
4243
foreach (test${TESTS} )
4344
add_executable(cpp-netlib-http-${test}${test}.cpp)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2010 Dean Michael Berris.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#include<gtest/gtest.h>
7+
#include<boost/network/include/http/client.hpp>
8+
#include"client_types.hpp"
9+
10+
namespacenet= boost::network;
11+
namespacehttp= boost::network::http;
12+
using tclock = std::chrono::high_resolution_clock;
13+
14+
TYPED_TEST_CASE(HTTPClientTest, ClientTypes);
15+
16+
TYPED_TEST(HTTPClientTest, GetTest) {
17+
using client = TypeParam;
18+
typename client::requestrequest("http://cpp-netlib.org/");
19+
client client_;
20+
auto response = client_.get(request);
21+
while (!http::ready(response)) {
22+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
23+
}
24+
auto t0 =tclock::now();
25+
auto data =body(response);
26+
auto t1 =tclock::now();
27+
EXPECT_TRUE(response.status() ==200u ||
28+
(response.status() >=300 && response.status() <400));
29+
EXPECT_TRUE(data.size() >0);
30+
31+
// XXX we should find a better way to check if `ready()` has done his job
32+
namespacec= std::chrono;
33+
EXPECT_TRUE(c::duration_cast<c::milliseconds>(t1-t0).count() <1);
34+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp