1
0
mirror of synced 2025-09-10 00:09:25 +03:00

clang-format

This commit is contained in:
yhirose
2025-07-05 07:13:13 -04:00
parent ceff2c1154
commit 120405beac

View File

@@ -5305,8 +5305,10 @@ TEST_F(ServerTest, PatchContentReceiver) {
template <typename ClientType> template <typename ClientType>
void TestWithHeadersAndContentReceiver( void TestWithHeadersAndContentReceiver(
ClientType &cli, ClientType &cli,
std::function<Result(ClientType&, const std::string&, const Headers&, const std::string&, const std::string&, std::function<Result(ClientType &, const std::string &, const Headers &,
ContentReceiver, DownloadProgress)> request_func) { const std::string &, const std::string &,
ContentReceiver, DownloadProgress)>
request_func) {
Headers headers; Headers headers;
headers.emplace("X-Custom-Header", "test-value"); headers.emplace("X-Custom-Header", "test-value");
@@ -5316,7 +5318,8 @@ void TestWithHeadersAndContentReceiver(
[&](const char *data, size_t data_length) { [&](const char *data, size_t data_length) {
received_body.append(data, data_length); received_body.append(data, data_length);
return true; return true;
}, nullptr); },
nullptr);
ASSERT_TRUE(res); ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status); EXPECT_EQ(StatusCode::OK_200, res->status);
@@ -5329,9 +5332,10 @@ TEST_F(ServerTest, PostWithHeadersAndContentReceiver) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiver<ClientT>(cli_, TestWithHeadersAndContentReceiver<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) { const std::string &body, const std::string &content_type,
ContentReceiver receiver, DownloadProgress progress) {
return cli.Post(path, headers, body, content_type, receiver, progress); return cli.Post(path, headers, body, content_type, receiver, progress);
}); });
} }
@@ -5342,9 +5346,10 @@ TEST_F(ServerTest, PutWithHeadersAndContentReceiver) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiver<ClientT>(cli_, TestWithHeadersAndContentReceiver<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) { const std::string &body, const std::string &content_type,
ContentReceiver receiver, DownloadProgress progress) {
return cli.Put(path, headers, body, content_type, receiver, progress); return cli.Put(path, headers, body, content_type, receiver, progress);
}); });
} }
@@ -5355,9 +5360,10 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiver) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiver<ClientT>(cli_, TestWithHeadersAndContentReceiver<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) { const std::string &body, const std::string &content_type,
ContentReceiver receiver, DownloadProgress progress) {
return cli.Patch(path, headers, body, content_type, receiver, progress); return cli.Patch(path, headers, body, content_type, receiver, progress);
}); });
} }
@@ -5365,8 +5371,10 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiver) {
template <typename ClientType> template <typename ClientType>
void TestWithHeadersAndContentReceiverWithProgress( void TestWithHeadersAndContentReceiverWithProgress(
ClientType &cli, ClientType &cli,
std::function<Result(ClientType&, const std::string&, const Headers&, const std::string&, const std::string&, std::function<Result(ClientType &, const std::string &, const Headers &,
ContentReceiver, DownloadProgress)> request_func) { const std::string &, const std::string &,
ContentReceiver, DownloadProgress)>
request_func) {
Headers headers; Headers headers;
headers.emplace("X-Test-Header", "progress-test"); headers.emplace("X-Test-Header", "progress-test");
@@ -5396,9 +5404,10 @@ TEST_F(ServerTest, PostWithHeadersAndContentReceiverWithProgress) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiverWithProgress<ClientT>(cli_, TestWithHeadersAndContentReceiverWithProgress<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) { const std::string &body, const std::string &content_type,
ContentReceiver receiver, DownloadProgress progress) {
return cli.Post(path, headers, body, content_type, receiver, progress); return cli.Post(path, headers, body, content_type, receiver, progress);
}); });
} }
@@ -5409,9 +5418,10 @@ TEST_F(ServerTest, PutWithHeadersAndContentReceiverWithProgress) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiverWithProgress<ClientT>(cli_, TestWithHeadersAndContentReceiverWithProgress<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) { const std::string &body, const std::string &content_type,
ContentReceiver receiver, DownloadProgress progress) {
return cli.Put(path, headers, body, content_type, receiver, progress); return cli.Put(path, headers, body, content_type, receiver, progress);
}); });
} }
@@ -5422,26 +5432,28 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiverWithProgress) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiverWithProgress<ClientT>(cli_, TestWithHeadersAndContentReceiverWithProgress<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) { const std::string &body, const std::string &content_type,
ContentReceiver receiver, DownloadProgress progress) {
return cli.Patch(path, headers, body, content_type, receiver, progress); return cli.Patch(path, headers, body, content_type, receiver, progress);
}); });
} }
template <typename ClientType> template <typename ClientType>
void TestWithHeadersAndContentReceiverError( void TestWithHeadersAndContentReceiverError(
ClientType& cli, ClientType &cli, std::function<Result(ClientType &, const std::string &,
std::function<Result(ClientType&, const std::string&, const Headers&, const std::string&, const std::string&, const Headers &, const std::string &,
ContentReceiver)> request_func) { const std::string &, ContentReceiver)>
request_func) {
Headers headers; Headers headers;
headers.emplace("X-Error-Test", "true"); headers.emplace("X-Error-Test", "true");
std::string received_body; std::string received_body;
auto receiver_failed = false; auto receiver_failed = false;
auto res = request_func( auto res =
cli, "/content_receiver", headers, "content", "text/plain", request_func(cli, "/content_receiver", headers, "content", "text/plain",
[&](const char *data, size_t data_length) { [&](const char *data, size_t data_length) {
received_body.append(data, data_length); received_body.append(data, data_length);
receiver_failed = true; receiver_failed = true;
@@ -5458,9 +5470,10 @@ TEST_F(ServerTest, PostWithHeadersAndContentReceiverError) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiverError<ClientT>(cli_, TestWithHeadersAndContentReceiverError<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver) { const std::string &body, const std::string &content_type,
ContentReceiver receiver) {
return cli.Post(path, headers, body, content_type, receiver); return cli.Post(path, headers, body, content_type, receiver);
}); });
} }
@@ -5471,9 +5484,10 @@ TEST_F(ServerTest, PuttWithHeadersAndContentReceiverError) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiverError<ClientT>(cli_, TestWithHeadersAndContentReceiverError<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver) { const std::string &body, const std::string &content_type,
ContentReceiver receiver) {
return cli.Put(path, headers, body, content_type, receiver); return cli.Put(path, headers, body, content_type, receiver);
}); });
} }
@@ -5484,9 +5498,10 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiverError) {
#else #else
using ClientT = Client; using ClientT = Client;
#endif #endif
TestWithHeadersAndContentReceiverError<ClientT>(cli_, TestWithHeadersAndContentReceiverError<ClientT>(
[](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body, cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
const std::string& content_type, ContentReceiver receiver) { const std::string &body, const std::string &content_type,
ContentReceiver receiver) {
return cli.Patch(path, headers, body, content_type, receiver); return cli.Patch(path, headers, body, content_type, receiver);
}); });
} }