aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/json
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/json
parentc563b583cb9b7fecc33971581368796d2df4759d (diff)
rename all test core files to cc and a lot of C++ style conversions
Diffstat (limited to 'test/core/json')
-rw-r--r--test/core/json/fuzzer.cc (renamed from test/core/json/fuzzer.c)2
-rw-r--r--test/core/json/json_rewrite.cc (renamed from test/core/json/json_rewrite.c)34
-rw-r--r--test/core/json/json_rewrite_test.cc (renamed from test/core/json/json_rewrite_test.c)30
-rw-r--r--test/core/json/json_stream_error_test.cc (renamed from test/core/json/json_stream_error_test.c)0
-rw-r--r--test/core/json/json_test.cc (renamed from test/core/json/json_test.c)0
5 files changed, 35 insertions, 31 deletions
diff --git a/test/core/json/fuzzer.c b/test/core/json/fuzzer.cc
index b825904d41..a8b75f72a2 100644
--- a/test/core/json/fuzzer.c
+++ b/test/core/json/fuzzer.cc
@@ -33,7 +33,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
char *s;
struct grpc_memory_counters counters;
grpc_memory_counters_init();
- s = gpr_malloc(size);
+ s = static_cast<char *>(gpr_malloc(size));
memcpy(s, data, size);
grpc_json *x;
if ((x = grpc_json_parse_string_with_len(s, size))) {
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.cc
index dfe32f5adf..27443e3c49 100644
--- a/test/core/json/json_rewrite.c
+++ b/test/core/json/json_rewrite.cc
@@ -45,18 +45,18 @@ typedef struct json_reader_userdata {
} json_reader_userdata;
static void json_writer_output_char(void *userdata, char c) {
- json_writer_userdata *state = userdata;
+ json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata);
fputc(c, state->out);
}
static void json_writer_output_string(void *userdata, const char *str) {
- json_writer_userdata *state = userdata;
+ json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata);
fputs(str, state->out);
}
static void json_writer_output_string_with_len(void *userdata, const char *str,
size_t len) {
- json_writer_userdata *state = userdata;
+ json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata);
fwrite(str, len, 1, state->out);
}
@@ -68,19 +68,20 @@ static void check_string(json_reader_userdata *state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
needed = (needed + 0xffu) & ~0xffu;
- state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
+ state->scratchpad = static_cast<char *>(
+ gpr_realloc(state->scratchpad, state->allocated + needed));
state->free_space += needed;
state->allocated += needed;
}
static void json_reader_string_clear(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
state->free_space = state->allocated;
state->string_len = 0;
}
static void json_reader_string_add_char(void *userdata, uint32_t c) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
check_string(state, 1);
GPR_ASSERT(c < 256);
state->scratchpad[state->string_len++] = (char)c;
@@ -115,7 +116,7 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
static uint32_t json_reader_read_char(void *userdata) {
int r;
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
@@ -123,8 +124,9 @@ static uint32_t json_reader_read_char(void *userdata) {
}
static void json_reader_container_begins(void *userdata, grpc_json_type type) {
- json_reader_userdata *state = userdata;
- stacked_container *container = gpr_malloc(sizeof(stacked_container));
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
+ stacked_container *container =
+ static_cast<stacked_container *>(gpr_malloc(sizeof(stacked_container)));
container->type = type;
container->next = state->top;
@@ -134,7 +136,7 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) {
}
static grpc_json_type json_reader_container_ends(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
stacked_container *container = state->top;
grpc_json_writer_container_ends(state->writer, container->type);
@@ -144,21 +146,21 @@ static grpc_json_type json_reader_container_ends(void *userdata) {
}
static void json_reader_set_key(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_object_key(state->writer, state->scratchpad);
}
static void json_reader_set_string(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_value_string(state->writer, state->scratchpad);
}
static int json_reader_set_number(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, state->scratchpad,
state->string_len);
@@ -167,19 +169,19 @@ static int json_reader_set_number(void *userdata) {
}
static void json_reader_set_true(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "true", 4);
}
static void json_reader_set_false(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "false", 5);
}
static void json_reader_set_null(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "null", 4);
}
diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.cc
index a654971b34..ba22709a70 100644
--- a/test/core/json/json_rewrite_test.c
+++ b/test/core/json/json_rewrite_test.cc
@@ -47,7 +47,7 @@ typedef struct json_reader_userdata {
} json_reader_userdata;
static void json_writer_output_char(void *userdata, char c) {
- json_writer_userdata *state = userdata;
+ json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata);
int cmp = fgetc(state->cmp);
/* treat CRLF as LF */
@@ -79,19 +79,20 @@ static void check_string(json_reader_userdata *state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
needed = (needed + 0xffu) & ~0xffu;
- state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
+ state->scratchpad = static_cast<char *>(
+ gpr_realloc(state->scratchpad, state->allocated + needed));
state->free_space += needed;
state->allocated += needed;
}
static void json_reader_string_clear(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
state->free_space = state->allocated;
state->string_len = 0;
}
static void json_reader_string_add_char(void *userdata, uint32_t c) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
check_string(state, 1);
GPR_ASSERT(c <= 256);
state->scratchpad[state->string_len++] = (char)c;
@@ -126,7 +127,7 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
static uint32_t json_reader_read_char(void *userdata) {
int r;
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
if (!state->did_eagain) {
state->did_eagain = 1;
@@ -141,8 +142,9 @@ static uint32_t json_reader_read_char(void *userdata) {
}
static void json_reader_container_begins(void *userdata, grpc_json_type type) {
- json_reader_userdata *state = userdata;
- stacked_container *container = gpr_malloc(sizeof(stacked_container));
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
+ stacked_container *container =
+ static_cast<stacked_container *>(gpr_malloc(sizeof(stacked_container)));
container->type = type;
container->next = state->top;
@@ -152,7 +154,7 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) {
}
static grpc_json_type json_reader_container_ends(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
stacked_container *container = state->top;
grpc_json_writer_container_ends(state->writer, container->type);
@@ -162,21 +164,21 @@ static grpc_json_type json_reader_container_ends(void *userdata) {
}
static void json_reader_set_key(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_object_key(state->writer, state->scratchpad);
}
static void json_reader_set_string(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_value_string(state->writer, state->scratchpad);
}
static int json_reader_set_number(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, state->scratchpad,
state->string_len);
@@ -185,19 +187,19 @@ static int json_reader_set_number(void *userdata) {
}
static void json_reader_set_true(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "true", 4);
}
static void json_reader_set_false(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "false", 5);
}
static void json_reader_set_null(void *userdata) {
- json_reader_userdata *state = userdata;
+ json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "null", 4);
}
diff --git a/test/core/json/json_stream_error_test.c b/test/core/json/json_stream_error_test.cc
index 379cd5d078..379cd5d078 100644
--- a/test/core/json/json_stream_error_test.c
+++ b/test/core/json/json_stream_error_test.cc
diff --git a/test/core/json/json_test.c b/test/core/json/json_test.cc
index bbc6f7a4e6..bbc6f7a4e6 100644
--- a/test/core/json/json_test.c
+++ b/test/core/json/json_test.cc