3 * Copyright 2015 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 #include <grpc/support/alloc.h>
23 #include <grpc/support/log.h>
24 #include "test/core/util/test_config.h"
26 #include "src/core/lib/json/json_reader.h"
27 #include "src/core/lib/json/json_writer.h"
29 static int g_string_clear_once = 0;
31 static void string_clear(void* /*userdata*/) {
32 GPR_ASSERT(!g_string_clear_once);
33 g_string_clear_once = 1;
36 static uint32_t read_char(void* /*userdata*/) {
37 return GRPC_JSON_READ_CHAR_ERROR;
40 static grpc_json_reader_vtable reader_vtable = {
41 string_clear, nullptr, nullptr, read_char, nullptr, nullptr,
42 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
44 static void read_error() {
45 grpc_json_reader reader;
46 grpc_json_reader_status status;
47 grpc_json_reader_init(&reader, &reader_vtable, nullptr);
49 status = grpc_json_reader_run(&reader);
50 GPR_ASSERT(status == GRPC_JSON_READ_ERROR);
53 int main(int argc, char** argv) {
54 grpc::testing::TestEnvironment env(argc, argv);
56 gpr_log(GPR_INFO, "json_stream_error success");