aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/http
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-23 15:33:21 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-25 16:23:01 -0700
commit34a57d0346afe95e11104462c30dc468b0cb0b89 (patch)
tree67db15f7b8b361e0618199dc55215f3b4d626201 /test/core/http
parentc563b583cb9b7fecc33971581368796d2df4759d (diff)
rename all test core files to cc and a lot of C++ style conversions
Diffstat (limited to 'test/core/http')
-rw-r--r--test/core/http/format_request_test.cc (renamed from test/core/http/format_request_test.c)33
-rw-r--r--test/core/http/httpcli_test.cc (renamed from test/core/http/httpcli_test.c)16
-rw-r--r--test/core/http/httpscli_test.cc (renamed from test/core/http/httpscli_test.c)22
-rw-r--r--test/core/http/parser_test.cc (renamed from test/core/http/parser_test.c)19
-rw-r--r--test/core/http/request_fuzzer.cc (renamed from test/core/http/request_fuzzer.c)0
-rw-r--r--test/core/http/response_fuzzer.cc (renamed from test/core/http/response_fuzzer.c)0
6 files changed, 51 insertions, 39 deletions
diff --git a/test/core/http/format_request_test.c b/test/core/http/format_request_test.cc
index 0279a1b5e3..b2d903458d 100644
--- a/test/core/http/format_request_test.c
+++ b/test/core/http/format_request_test.cc
@@ -24,13 +24,14 @@
#include "test/core/util/test_config.h"
static void test_format_get_request(void) {
- grpc_http_header hdr = {"x-yz", "abc"};
+ grpc_http_header hdr = {const_cast<char *>("x-yz"),
+ const_cast<char *>("abc")};
grpc_httpcli_request req;
grpc_slice slice;
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char *>("example.com");
+ req.http.path = const_cast<char *>("/index.html");
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
@@ -49,15 +50,16 @@ static void test_format_get_request(void) {
}
static void test_format_post_request(void) {
- grpc_http_header hdr = {"x-yz", "abc"};
+ grpc_http_header hdr = {const_cast<char *>("x-yz"),
+ const_cast<char *>("abc")};
grpc_httpcli_request req;
grpc_slice slice;
char body_bytes[] = "fake body";
size_t body_len = 9;
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char *>("example.com");
+ req.http.path = const_cast<char *>("/index.html");
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
@@ -79,13 +81,14 @@ static void test_format_post_request(void) {
}
static void test_format_post_request_no_body(void) {
- grpc_http_header hdr = {"x-yz", "abc"};
+ grpc_http_header hdr = {const_cast<char *>("x-yz"),
+ const_cast<char *>("abc")};
grpc_httpcli_request req;
grpc_slice slice;
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char *>("example.com");
+ req.http.path = const_cast<char *>("/index.html");
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
@@ -110,13 +113,13 @@ static void test_format_post_request_content_type_override(void) {
char body_bytes[] = "fake%20body";
size_t body_len = 11;
- hdrs[0].key = "x-yz";
- hdrs[0].value = "abc";
- hdrs[1].key = "Content-Type";
- hdrs[1].value = "application/x-www-form-urlencoded";
+ hdrs[0].key = const_cast<char *>("x-yz");
+ hdrs[0].value = const_cast<char *>("abc");
+ hdrs[1].key = const_cast<char *>("Content-Type");
+ hdrs[1].value = const_cast<char *>("application/x-www-form-urlencoded");
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char *>("example.com");
+ req.http.path = const_cast<char *>("/index.html");
req.http.hdr_count = 2;
req.http.hdrs = hdrs;
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.cc
index cc1c16d695..925f63decc 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.cc
@@ -44,7 +44,7 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
const char *expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
- grpc_http_response *response = arg;
+ grpc_http_response *response = static_cast<grpc_http_response *>(arg);
GPR_ASSERT(response);
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
@@ -70,7 +70,7 @@ static void test_get(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
- req.http.path = "/get";
+ req.http.path = const_cast<char *>("/get");
req.handshaker = &grpc_httpcli_plaintext;
grpc_http_response response;
@@ -110,7 +110,7 @@ static void test_post(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
- req.http.path = "/post";
+ req.http.path = const_cast<char *>("/post");
req.handshaker = &grpc_httpcli_plaintext;
grpc_http_response response;
@@ -139,7 +139,8 @@ static void test_post(int port) {
}
static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(p));
+ grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(
+ static_cast<grpc_polling_entity *>(p)));
}
int main(int argc, char **argv) {
@@ -154,7 +155,7 @@ int main(int argc, char **argv) {
/* figure out where we are */
char *root;
if (lslash) {
- root = gpr_malloc((size_t)(lslash - me + 1));
+ root = static_cast<char *>(gpr_malloc((size_t)(lslash - me + 1)));
memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
@@ -171,7 +172,7 @@ int main(int argc, char **argv) {
}
/* start the server */
- args[1 + arg_shift] = "--port";
+ args[1 + arg_shift] = const_cast<char *>("--port");
gpr_asprintf(&args[2 + arg_shift], "%d", port);
server = gpr_subprocess_create(3 + arg_shift, (const char **)args);
GPR_ASSERT(server);
@@ -186,7 +187,8 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
grpc_httpcli_context_init(&g_context);
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
+ grpc_pollset *pollset =
+ static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &g_mu);
g_pops = grpc_polling_entity_create_from_pollset(pollset);
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.cc
index f8a3cfdd76..179b3a720b 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.cc
@@ -44,7 +44,7 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
const char *expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
- grpc_http_response *response = arg;
+ grpc_http_response *response = static_cast<grpc_http_response *>(arg);
GPR_ASSERT(response);
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
@@ -70,8 +70,8 @@ static void test_get(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
- req.ssl_host_override = "foo.test.google.fr";
- req.http.path = "/get";
+ req.ssl_host_override = const_cast<char *>("foo.test.google.fr");
+ req.http.path = const_cast<char *>("/get");
req.handshaker = &grpc_httpcli_ssl;
grpc_http_response response;
@@ -111,8 +111,8 @@ static void test_post(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
- req.ssl_host_override = "foo.test.google.fr";
- req.http.path = "/post";
+ req.ssl_host_override = const_cast<char *>("foo.test.google.fr");
+ req.http.path = const_cast<char *>("/post");
req.handshaker = &grpc_httpcli_ssl;
grpc_http_response response;
@@ -141,7 +141,8 @@ static void test_post(int port) {
}
static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(p));
+ grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(
+ static_cast<grpc_polling_entity *>(p)));
}
int main(int argc, char **argv) {
@@ -156,7 +157,7 @@ int main(int argc, char **argv) {
/* figure out where we are */
char *root;
if (lslash) {
- root = gpr_malloc((size_t)(lslash - me + 1));
+ root = static_cast<char *>(gpr_malloc((size_t)(lslash - me + 1)));
memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
@@ -173,9 +174,9 @@ int main(int argc, char **argv) {
}
/* start the server */
- args[1 + arg_shift] = "--port";
+ args[1 + arg_shift] = const_cast<char *>("--port");
gpr_asprintf(&args[2 + arg_shift], "%d", port);
- args[3 + arg_shift] = "--ssl";
+ args[3 + arg_shift] = const_cast<char *>("--ssl");
server = gpr_subprocess_create(4 + arg_shift, (const char **)args);
GPR_ASSERT(server);
gpr_free(args[0]);
@@ -189,7 +190,8 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
grpc_httpcli_context_init(&g_context);
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
+ grpc_pollset *pollset =
+ static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &g_mu);
g_pops = grpc_polling_entity_create_from_pollset(pollset);
diff --git a/test/core/http/parser_test.c b/test/core/http/parser_test.cc
index a7044c03bc..9eff49122c 100644
--- a/test/core/http/parser_test.c
+++ b/test/core/http/parser_test.cc
@@ -29,9 +29,11 @@
#include "test/core/util/test_config.h"
static void test_request_succeeds(grpc_slice_split_mode split_mode,
- char *request_text, char *expect_method,
+ const char *request_text,
+ const char *expect_method,
grpc_http_version expect_version,
- char *expect_path, char *expect_body, ...) {
+ const char *expect_path,
+ const char *expect_body, ...) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(request_text);
size_t num_slices;
@@ -87,8 +89,9 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
gpr_free(slices);
}
-static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
- int expect_status, char *expect_body, ...) {
+static void test_succeeds(grpc_slice_split_mode split_mode,
+ const char *response_text, int expect_status,
+ const char *expect_body, ...) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(response_text);
size_t num_slices;
@@ -141,7 +144,8 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
gpr_free(slices);
}
-static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
+static void test_fails(grpc_slice_split_mode split_mode,
+ const char *response_text) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(response_text);
size_t num_slices;
@@ -174,7 +178,7 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
}
static void test_request_fails(grpc_slice_split_mode split_mode,
- char *request_text) {
+ const char *request_text) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(request_text);
size_t num_slices;
@@ -286,7 +290,8 @@ int main(int argc, char **argv) {
test_request_fails(split_modes[i], "GET / HTTP/1.2\r\n");
test_request_fails(split_modes[i], "GET / HTTP/1.0\n");
- tmp1 = gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
+ tmp1 =
+ static_cast<char *>(gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH));
memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1);
tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0;
gpr_asprintf(&tmp2, "HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1);
diff --git a/test/core/http/request_fuzzer.c b/test/core/http/request_fuzzer.cc
index aefe9eb0f9..aefe9eb0f9 100644
--- a/test/core/http/request_fuzzer.c
+++ b/test/core/http/request_fuzzer.cc
diff --git a/test/core/http/response_fuzzer.c b/test/core/http/response_fuzzer.cc
index d5bb67500d..d5bb67500d 100644
--- a/test/core/http/response_fuzzer.c
+++ b/test/core/http/response_fuzzer.cc