diff options
author | Craig Tiller <ctiller@google.com> | 2015-12-11 17:59:03 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-12-11 17:59:03 -0800 |
commit | 82821ba778df5ed9793379da1f970bc0e3cd85e5 (patch) | |
tree | 2b89106f90af6466071ed0564455963df4618ae7 /src | |
parent | 3a977a49f642a087637ddb5cb72245b0485ac665 (diff) | |
parent | 11c320da083946e89c7c173e37156ec37af3e6ac (diff) |
Merge pull request #4438 from nicolasnoble/json-coverage-2
Increasing json code coverage.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/json/json_reader.c | 15 | ||||
-rw-r--r-- | src/core/json/json_string.c | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/core/json/json_reader.c b/src/core/json/json_reader.c index 8abad01252..358e0f6c1d 100644 --- a/src/core/json/json_reader.c +++ b/src/core/json/json_reader.c @@ -35,6 +35,8 @@ #include <grpc/support/port_platform.h> +#include <grpc/support/log.h> + #include "src/core/json/json_reader.h" static void json_reader_string_clear(grpc_json_reader *reader) { @@ -224,13 +226,13 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) { reader->in_array = 1; break; case GRPC_JSON_TOP_LEVEL: - if (reader->depth != 0) return GRPC_JSON_INTERNAL_ERROR; + GPR_ASSERT(reader->depth == 0); reader->in_object = 0; reader->in_array = 0; reader->state = GRPC_JSON_STATE_END; break; default: - return GRPC_JSON_INTERNAL_ERROR; + GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR); } } break; @@ -279,8 +281,7 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) { break; case GRPC_JSON_STATE_OBJECT_KEY_STRING: - if (reader->unicode_high_surrogate != 0) - return GRPC_JSON_PARSE_ERROR; + GPR_ASSERT(reader->unicode_high_surrogate == 0); if (c == '"') { reader->state = GRPC_JSON_STATE_OBJECT_KEY_END; json_reader_set_key(reader); @@ -461,7 +462,7 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) { } break; default: - return GRPC_JSON_INTERNAL_ERROR; + GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR); } break; @@ -641,7 +642,7 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) { case ',': case '}': case ']': - return GRPC_JSON_INTERNAL_ERROR; + GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR); break; default: @@ -655,5 +656,5 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) { } } - return GRPC_JSON_INTERNAL_ERROR; + GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR); } diff --git a/src/core/json/json_string.c b/src/core/json/json_string.c index 0461c2703f..06c157dc98 100644 --- a/src/core/json/json_string.c +++ b/src/core/json/json_string.c @@ -353,7 +353,7 @@ static void json_dump_recursive(grpc_json_writer *writer, grpc_json *json, grpc_json_writer_value_raw_with_len(writer, "null", 4); break; default: - abort(); + GPR_UNREACHABLE_CODE(abort()); } json = json->next; } |