aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/httpcli
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-09-22 10:42:19 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-09-22 10:42:19 -0700
commit45724b35e411fef7c5da66a74c78428c11d56843 (patch)
tree9264034aca675c89444e02f72ef58e67d7043604 /test/core/httpcli
parent298751c1195523ef6228595043b583c3a6270e08 (diff)
indent pass to get logical source lines on one physical line
Diffstat (limited to 'test/core/httpcli')
-rw-r--r--test/core/httpcli/format_request_test.c110
-rw-r--r--test/core/httpcli/httpcli_test.c184
-rw-r--r--test/core/httpcli/parser_test.c167
3 files changed, 224 insertions, 237 deletions
diff --git a/test/core/httpcli/format_request_test.c b/test/core/httpcli/format_request_test.c
index 82b2ccb122..7aa7624f20 100644
--- a/test/core/httpcli/format_request_test.c
+++ b/test/core/httpcli/format_request_test.c
@@ -38,87 +38,71 @@
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
-static void test_format_get_request(void) {
- grpc_httpcli_header hdr = {"x-yz", "abc"};
+static void
+test_format_get_request (void)
+{
+ grpc_httpcli_header hdr = { "x-yz", "abc" };
grpc_httpcli_request req;
gpr_slice slice;
- memset(&req, 0, sizeof(req));
+ memset (&req, 0, sizeof (req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 1;
req.hdrs = &hdr;
- slice = grpc_httpcli_format_get_request(&req);
+ slice = grpc_httpcli_format_get_request (&req);
- GPR_ASSERT(0 == gpr_slice_str_cmp(slice,
- "GET /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT
- "\r\n"
- "x-yz: abc\r\n"
- "\r\n"));
+ GPR_ASSERT (0 == gpr_slice_str_cmp (slice, "GET /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" "User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n" "x-yz: abc\r\n" "\r\n"));
- gpr_slice_unref(slice);
+ gpr_slice_unref (slice);
}
-static void test_format_post_request(void) {
- grpc_httpcli_header hdr = {"x-yz", "abc"};
+static void
+test_format_post_request (void)
+{
+ grpc_httpcli_header hdr = { "x-yz", "abc" };
grpc_httpcli_request req;
gpr_slice slice;
char body_bytes[] = "fake body";
size_t body_len = 9;
- memset(&req, 0, sizeof(req));
+ memset (&req, 0, sizeof (req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 1;
req.hdrs = &hdr;
- slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len);
-
- GPR_ASSERT(0 == gpr_slice_str_cmp(slice,
- "POST /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT
- "\r\n"
- "x-yz: abc\r\n"
- "Content-Type: text/plain\r\n"
- "Content-Length: 9\r\n"
- "\r\n"
- "fake body"));
-
- gpr_slice_unref(slice);
+ slice = grpc_httpcli_format_post_request (&req, body_bytes, body_len);
+
+ GPR_ASSERT (0 == gpr_slice_str_cmp (slice, "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" "User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n" "x-yz: abc\r\n" "Content-Type: text/plain\r\n" "Content-Length: 9\r\n" "\r\n" "fake body"));
+
+ gpr_slice_unref (slice);
}
-static void test_format_post_request_no_body(void) {
- grpc_httpcli_header hdr = {"x-yz", "abc"};
+static void
+test_format_post_request_no_body (void)
+{
+ grpc_httpcli_header hdr = { "x-yz", "abc" };
grpc_httpcli_request req;
gpr_slice slice;
- memset(&req, 0, sizeof(req));
+ memset (&req, 0, sizeof (req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 1;
req.hdrs = &hdr;
- slice = grpc_httpcli_format_post_request(&req, NULL, 0);
+ slice = grpc_httpcli_format_post_request (&req, NULL, 0);
- GPR_ASSERT(0 == gpr_slice_str_cmp(slice,
- "POST /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT
- "\r\n"
- "x-yz: abc\r\n"
- "\r\n"));
+ GPR_ASSERT (0 == gpr_slice_str_cmp (slice, "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" "User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n" "x-yz: abc\r\n" "\r\n"));
- gpr_slice_unref(slice);
+ gpr_slice_unref (slice);
}
-static void test_format_post_request_content_type_override(void) {
+static void
+test_format_post_request_content_type_override (void)
+{
grpc_httpcli_header hdrs[2];
grpc_httpcli_request req;
gpr_slice slice;
@@ -129,36 +113,28 @@ static void test_format_post_request_content_type_override(void) {
hdrs[0].value = "abc";
hdrs[1].key = "Content-Type";
hdrs[1].value = "application/x-www-form-urlencoded";
- memset(&req, 0, sizeof(req));
+ memset (&req, 0, sizeof (req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 2;
req.hdrs = hdrs;
- slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len);
-
- GPR_ASSERT(0 == gpr_slice_str_cmp(
- slice,
- "POST /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n"
- "x-yz: abc\r\n"
- "Content-Type: application/x-www-form-urlencoded\r\n"
- "Content-Length: 11\r\n"
- "\r\n"
- "fake%20body"));
-
- gpr_slice_unref(slice);
+ slice = grpc_httpcli_format_post_request (&req, body_bytes, body_len);
+
+ GPR_ASSERT (0 == gpr_slice_str_cmp (slice, "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" "User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n" "x-yz: abc\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: 11\r\n" "\r\n" "fake%20body"));
+
+ gpr_slice_unref (slice);
}
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
+int
+main (int argc, char **argv)
+{
+ grpc_test_init (argc, argv);
- test_format_get_request();
- test_format_post_request();
- test_format_post_request_no_body();
- test_format_post_request_content_type_override();
+ test_format_get_request ();
+ test_format_post_request ();
+ test_format_post_request_no_body ();
+ test_format_post_request_content_type_override ();
return 0;
}
diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c
index 063565ecfc..1982b00cd1 100644
--- a/test/core/httpcli/httpcli_test.c
+++ b/test/core/httpcli/httpcli_test.c
@@ -49,138 +49,146 @@ static int g_done = 0;
static grpc_httpcli_context g_context;
static grpc_pollset g_pollset;
-static gpr_timespec n_seconds_time(int seconds) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds);
+static gpr_timespec
+n_seconds_time (int seconds)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (seconds);
}
-static void on_finish(void *arg, const grpc_httpcli_response *response,
- grpc_closure_list *closure_list) {
- const char *expect =
- "<html><head><title>Hello world!</title></head>"
- "<body><p>This is a test</p></body></html>";
- GPR_ASSERT(arg == (void *)42);
- GPR_ASSERT(response);
- GPR_ASSERT(response->status == 200);
- GPR_ASSERT(response->body_length == strlen(expect));
- GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+static void
+on_finish (void *arg, const grpc_httpcli_response * response, grpc_closure_list * closure_list)
+{
+ const char *expect = "<html><head><title>Hello world!</title></head>" "<body><p>This is a test</p></body></html>";
+ GPR_ASSERT (arg == (void *) 42);
+ GPR_ASSERT (response);
+ GPR_ASSERT (response->status == 200);
+ GPR_ASSERT (response->body_length == strlen (expect));
+ GPR_ASSERT (0 == memcmp (expect, response->body, response->body_length));
+ gpr_mu_lock (GRPC_POLLSET_MU (&g_pollset));
g_done = 1;
- grpc_pollset_kick(&g_pollset, NULL);
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+ grpc_pollset_kick (&g_pollset, NULL);
+ gpr_mu_unlock (GRPC_POLLSET_MU (&g_pollset));
}
-static void test_get(int use_ssl, int port) {
+static void
+test_get (int use_ssl, int port)
+{
grpc_httpcli_request req;
char *host;
grpc_closure_list closure_list = GRPC_CLOSURE_LIST_INIT;
g_done = 0;
- gpr_log(GPR_INFO, "running %s with use_ssl=%d.", "test_get", use_ssl);
+ gpr_log (GPR_INFO, "running %s with use_ssl=%d.", "test_get", use_ssl);
- gpr_asprintf(&host, "localhost:%d", port);
- gpr_log(GPR_INFO, "requesting from %s", host);
+ gpr_asprintf (&host, "localhost:%d", port);
+ gpr_log (GPR_INFO, "requesting from %s", host);
- memset(&req, 0, sizeof(req));
+ memset (&req, 0, sizeof (req));
req.host = host;
req.path = "/get";
req.handshaker = use_ssl ? &grpc_httpcli_ssl : &grpc_httpcli_plaintext;
- grpc_httpcli_get(&g_context, &g_pollset, &req, n_seconds_time(15), on_finish,
- (void *)42, &closure_list);
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
- while (!g_done) {
- grpc_pollset_worker worker;
- grpc_pollset_work(&g_pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(20), &closure_list);
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- grpc_closure_list_run(&closure_list);
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
- }
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- gpr_free(host);
+ grpc_httpcli_get (&g_context, &g_pollset, &req, n_seconds_time (15), on_finish, (void *) 42, &closure_list);
+ gpr_mu_lock (GRPC_POLLSET_MU (&g_pollset));
+ while (!g_done)
+ {
+ grpc_pollset_worker worker;
+ grpc_pollset_work (&g_pollset, &worker, gpr_now (GPR_CLOCK_MONOTONIC), n_seconds_time (20), &closure_list);
+ gpr_mu_unlock (GRPC_POLLSET_MU (&g_pollset));
+ grpc_closure_list_run (&closure_list);
+ gpr_mu_lock (GRPC_POLLSET_MU (&g_pollset));
+ }
+ gpr_mu_unlock (GRPC_POLLSET_MU (&g_pollset));
+ gpr_free (host);
}
-static void test_post(int use_ssl, int port) {
+static void
+test_post (int use_ssl, int port)
+{
grpc_httpcli_request req;
char *host;
grpc_closure_list closure_list = GRPC_CLOSURE_LIST_INIT;
g_done = 0;
- gpr_log(GPR_INFO, "running %s with use_ssl=%d.", "test_post", (int)use_ssl);
+ gpr_log (GPR_INFO, "running %s with use_ssl=%d.", "test_post", (int) use_ssl);
- gpr_asprintf(&host, "localhost:%d", port);
- gpr_log(GPR_INFO, "posting to %s", host);
+ gpr_asprintf (&host, "localhost:%d", port);
+ gpr_log (GPR_INFO, "posting to %s", host);
- memset(&req, 0, sizeof(req));
+ memset (&req, 0, sizeof (req));
req.host = host;
req.path = "/post";
req.handshaker = use_ssl ? &grpc_httpcli_ssl : &grpc_httpcli_plaintext;
- grpc_httpcli_post(&g_context, &g_pollset, &req, "hello", 5,
- n_seconds_time(15), on_finish, (void *)42, &closure_list);
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
- while (!g_done) {
- grpc_pollset_worker worker;
- grpc_pollset_work(&g_pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(20), &closure_list);
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- grpc_closure_list_run(&closure_list);
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
- }
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- gpr_free(host);
+ grpc_httpcli_post (&g_context, &g_pollset, &req, "hello", 5, n_seconds_time (15), on_finish, (void *) 42, &closure_list);
+ gpr_mu_lock (GRPC_POLLSET_MU (&g_pollset));
+ while (!g_done)
+ {
+ grpc_pollset_worker worker;
+ grpc_pollset_work (&g_pollset, &worker, gpr_now (GPR_CLOCK_MONOTONIC), n_seconds_time (20), &closure_list);
+ gpr_mu_unlock (GRPC_POLLSET_MU (&g_pollset));
+ grpc_closure_list_run (&closure_list);
+ gpr_mu_lock (GRPC_POLLSET_MU (&g_pollset));
+ }
+ gpr_mu_unlock (GRPC_POLLSET_MU (&g_pollset));
+ gpr_free (host);
}
-static void destroy_pollset(void *p, int success,
- grpc_closure_list *closure_list) {
- grpc_pollset_destroy(p);
+static void
+destroy_pollset (void *p, int success, grpc_closure_list * closure_list)
+{
+ grpc_pollset_destroy (p);
}
-int main(int argc, char **argv) {
+int
+main (int argc, char **argv)
+{
grpc_closure destroyed;
grpc_closure_list closure_list = GRPC_CLOSURE_LIST_INIT;
gpr_subprocess *server;
char *me = argv[0];
- char *lslash = strrchr(me, '/');
+ char *lslash = strrchr (me, '/');
char *args[4];
char root[1024];
- int port = grpc_pick_unused_port_or_die();
+ int port = grpc_pick_unused_port_or_die ();
/* figure out where we are */
- if (lslash) {
- memcpy(root, me, (size_t)(lslash - me));
- root[lslash - me] = 0;
- } else {
- strcpy(root, ".");
- }
+ if (lslash)
+ {
+ memcpy (root, me, (size_t) (lslash - me));
+ root[lslash - me] = 0;
+ }
+ else
+ {
+ strcpy (root, ".");
+ }
/* start the server */
- gpr_asprintf(&args[0], "%s/../../test/core/httpcli/test_server.py", root);
+ gpr_asprintf (&args[0], "%s/../../test/core/httpcli/test_server.py", root);
args[1] = "--port";
- gpr_asprintf(&args[2], "%d", port);
- server = gpr_subprocess_create(3, (const char **)args);
- GPR_ASSERT(server);
- gpr_free(args[0]);
- gpr_free(args[2]);
-
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(5, GPR_TIMESPAN)));
-
- grpc_test_init(argc, argv);
- grpc_init();
- grpc_httpcli_context_init(&g_context);
- grpc_pollset_init(&g_pollset);
-
- test_get(0, port);
- test_post(0, port);
-
- grpc_httpcli_context_destroy(&g_context);
- grpc_closure_init(&destroyed, destroy_pollset, &g_pollset);
- grpc_pollset_shutdown(&g_pollset, &destroyed, &closure_list);
- grpc_closure_list_run(&closure_list);
- grpc_shutdown();
-
- gpr_subprocess_destroy(server);
+ gpr_asprintf (&args[2], "%d", port);
+ server = gpr_subprocess_create (3, (const char **) args);
+ GPR_ASSERT (server);
+ gpr_free (args[0]);
+ gpr_free (args[2]);
+
+ gpr_sleep_until (gpr_time_add (gpr_now (GPR_CLOCK_REALTIME), gpr_time_from_seconds (5, GPR_TIMESPAN)));
+
+ grpc_test_init (argc, argv);
+ grpc_init ();
+ grpc_httpcli_context_init (&g_context);
+ grpc_pollset_init (&g_pollset);
+
+ test_get (0, port);
+ test_post (0, port);
+
+ grpc_httpcli_context_destroy (&g_context);
+ grpc_closure_init (&destroyed, destroy_pollset, &g_pollset);
+ grpc_pollset_shutdown (&g_pollset, &destroyed, &closure_list);
+ grpc_closure_list_run (&closure_list);
+ grpc_shutdown ();
+
+ gpr_subprocess_destroy (server);
return 0;
}
diff --git a/test/core/httpcli/parser_test.c b/test/core/httpcli/parser_test.c
index dacec0f72f..227cbbf4ec 100644
--- a/test/core/httpcli/parser_test.c
+++ b/test/core/httpcli/parser_test.c
@@ -42,114 +42,117 @@
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
-static void test_succeeds(grpc_slice_split_mode split_mode, char *response,
- int expect_status, char *expect_body, ...) {
+static void
+test_succeeds (grpc_slice_split_mode split_mode, char *response, int expect_status, char *expect_body, ...)
+{
grpc_httpcli_parser parser;
- gpr_slice input_slice = gpr_slice_from_copied_string(response);
+ gpr_slice input_slice = gpr_slice_from_copied_string (response);
size_t num_slices;
size_t i;
gpr_slice *slices;
va_list args;
- grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
- gpr_slice_unref(input_slice);
+ grpc_split_slices (split_mode, &input_slice, 1, &slices, &num_slices);
+ gpr_slice_unref (input_slice);
- grpc_httpcli_parser_init(&parser);
+ grpc_httpcli_parser_init (&parser);
- for (i = 0; i < num_slices; i++) {
- GPR_ASSERT(grpc_httpcli_parser_parse(&parser, slices[i]));
- gpr_slice_unref(slices[i]);
- }
- GPR_ASSERT(grpc_httpcli_parser_eof(&parser));
+ for (i = 0; i < num_slices; i++)
+ {
+ GPR_ASSERT (grpc_httpcli_parser_parse (&parser, slices[i]));
+ gpr_slice_unref (slices[i]);
+ }
+ GPR_ASSERT (grpc_httpcli_parser_eof (&parser));
- GPR_ASSERT(expect_status == parser.r.status);
- if (expect_body != NULL) {
- GPR_ASSERT(strlen(expect_body) == parser.r.body_length);
- GPR_ASSERT(0 == memcmp(expect_body, parser.r.body, parser.r.body_length));
- } else {
- GPR_ASSERT(parser.r.body_length == 0);
- }
+ GPR_ASSERT (expect_status == parser.r.status);
+ if (expect_body != NULL)
+ {
+ GPR_ASSERT (strlen (expect_body) == parser.r.body_length);
+ GPR_ASSERT (0 == memcmp (expect_body, parser.r.body, parser.r.body_length));
+ }
+ else
+ {
+ GPR_ASSERT (parser.r.body_length == 0);
+ }
- va_start(args, expect_body);
+ va_start (args, expect_body);
i = 0;
- for (;;) {
- char *expect_key;
- char *expect_value;
- expect_key = va_arg(args, char *);
- if (!expect_key) break;
- GPR_ASSERT(i < parser.r.hdr_count);
- expect_value = va_arg(args, char *);
- GPR_ASSERT(expect_value);
- GPR_ASSERT(0 == strcmp(expect_key, parser.r.hdrs[i].key));
- GPR_ASSERT(0 == strcmp(expect_value, parser.r.hdrs[i].value));
- i++;
- }
- va_end(args);
- GPR_ASSERT(i == parser.r.hdr_count);
-
- grpc_httpcli_parser_destroy(&parser);
- gpr_free(slices);
+ for (;;)
+ {
+ char *expect_key;
+ char *expect_value;
+ expect_key = va_arg (args, char *);
+ if (!expect_key)
+ break;
+ GPR_ASSERT (i < parser.r.hdr_count);
+ expect_value = va_arg (args, char *);
+ GPR_ASSERT (expect_value);
+ GPR_ASSERT (0 == strcmp (expect_key, parser.r.hdrs[i].key));
+ GPR_ASSERT (0 == strcmp (expect_value, parser.r.hdrs[i].value));
+ i++;
+ }
+ va_end (args);
+ GPR_ASSERT (i == parser.r.hdr_count);
+
+ grpc_httpcli_parser_destroy (&parser);
+ gpr_free (slices);
}
-static void test_fails(grpc_slice_split_mode split_mode, char *response) {
+static void
+test_fails (grpc_slice_split_mode split_mode, char *response)
+{
grpc_httpcli_parser parser;
- gpr_slice input_slice = gpr_slice_from_copied_string(response);
+ gpr_slice input_slice = gpr_slice_from_copied_string (response);
size_t num_slices;
size_t i;
gpr_slice *slices;
int done = 0;
- grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
- gpr_slice_unref(input_slice);
+ grpc_split_slices (split_mode, &input_slice, 1, &slices, &num_slices);
+ gpr_slice_unref (input_slice);
- grpc_httpcli_parser_init(&parser);
+ grpc_httpcli_parser_init (&parser);
- for (i = 0; i < num_slices; i++) {
- if (!done && !grpc_httpcli_parser_parse(&parser, slices[i])) {
+ for (i = 0; i < num_slices; i++)
+ {
+ if (!done && !grpc_httpcli_parser_parse (&parser, slices[i]))
+ {
+ done = 1;
+ }
+ gpr_slice_unref (slices[i]);
+ }
+ if (!done && !grpc_httpcli_parser_eof (&parser))
+ {
done = 1;
}
- gpr_slice_unref(slices[i]);
- }
- if (!done && !grpc_httpcli_parser_eof(&parser)) {
- done = 1;
- }
- GPR_ASSERT(done);
-
- grpc_httpcli_parser_destroy(&parser);
- gpr_free(slices);
+ GPR_ASSERT (done);
+
+ grpc_httpcli_parser_destroy (&parser);
+ gpr_free (slices);
}
-int main(int argc, char **argv) {
+int
+main (int argc, char **argv)
+{
size_t i;
- const grpc_slice_split_mode split_modes[] = {GRPC_SLICE_SPLIT_IDENTITY,
- GRPC_SLICE_SPLIT_ONE_BYTE};
-
- grpc_test_init(argc, argv);
-
- for (i = 0; i < GPR_ARRAY_SIZE(split_modes); i++) {
- test_succeeds(split_modes[i],
- "HTTP/1.0 200 OK\r\n"
- "xyz: abc\r\n"
- "\r\n"
- "hello world!",
- 200, "hello world!", "xyz", "abc", NULL);
- test_succeeds(split_modes[i],
- "HTTP/1.0 404 Not Found\r\n"
- "\r\n",
- 404, NULL, NULL);
- test_succeeds(split_modes[i],
- "HTTP/1.1 200 OK\r\n"
- "xyz: abc\r\n"
- "\r\n"
- "hello world!",
- 200, "hello world!", "xyz", "abc", NULL);
- test_fails(split_modes[i], "HTTP/1.0\r\n");
- test_fails(split_modes[i], "HTTP/1.2\r\n");
- test_fails(split_modes[i], "HTTP/1.0 000 XYX\r\n");
- test_fails(split_modes[i], "HTTP/1.0 200 OK\n");
- test_fails(split_modes[i], "HTTP/1.0 200 OK\r\n");
- test_fails(split_modes[i], "HTTP/1.0 200 OK\r\nFoo x\r\n");
- }
+ const grpc_slice_split_mode split_modes[] = { GRPC_SLICE_SPLIT_IDENTITY,
+ GRPC_SLICE_SPLIT_ONE_BYTE
+ };
+
+ grpc_test_init (argc, argv);
+
+ for (i = 0; i < GPR_ARRAY_SIZE (split_modes); i++)
+ {
+ test_succeeds (split_modes[i], "HTTP/1.0 200 OK\r\n" "xyz: abc\r\n" "\r\n" "hello world!", 200, "hello world!", "xyz", "abc", NULL);
+ test_succeeds (split_modes[i], "HTTP/1.0 404 Not Found\r\n" "\r\n", 404, NULL, NULL);
+ test_succeeds (split_modes[i], "HTTP/1.1 200 OK\r\n" "xyz: abc\r\n" "\r\n" "hello world!", 200, "hello world!", "xyz", "abc", NULL);
+ test_fails (split_modes[i], "HTTP/1.0\r\n");
+ test_fails (split_modes[i], "HTTP/1.2\r\n");
+ test_fails (split_modes[i], "HTTP/1.0 000 XYX\r\n");
+ test_fails (split_modes[i], "HTTP/1.0 200 OK\n");
+ test_fails (split_modes[i], "HTTP/1.0 200 OK\r\n");
+ test_fails (split_modes[i], "HTTP/1.0 200 OK\r\nFoo x\r\n");
+ }
return 0;
}