• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GPR_ARRAY_SIZE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GPR_ARRAY_SIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ GPR_ARRAY_SIZE函数的具体用法?C++ GPR_ARRAY_SIZE怎么用?C++ GPR_ARRAY_SIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GPR_ARRAY_SIZE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: run_all_benchmarks

static int run_all_benchmarks(size_t msg_size) {
  int error = 0;
  size_t i;
  for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) {
    test_strategy *strategy = &test_strategies[i];
    size_t j;
    for (j = 0; j < GPR_ARRAY_SIZE(socket_types); ++j) {
      thread_args *client_args = malloc(sizeof(thread_args));
      thread_args *server_args = malloc(sizeof(thread_args));
      char *socket_type = socket_types[j];

      client_args->read_bytes = strategy->read_strategy;
      client_args->write_bytes = blocking_write_bytes;
      client_args->setup = strategy->setup;
      client_args->msg_size = msg_size;
      client_args->strategy_name = strategy->name;
      server_args->read_bytes = strategy->read_strategy;
      server_args->write_bytes = blocking_write_bytes;
      server_args->setup = strategy->setup;
      server_args->msg_size = msg_size;
      server_args->strategy_name = strategy->name;
      error = run_benchmark(socket_type, client_args, server_args);
      if (error < 0) {
        return error;
      }
    }
  }
  return error;
}
开发者ID:github188,项目名称:grpc,代码行数:29,代码来源:low_level_ping_pong.c


示例2: test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context

static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
    void) {
  tsi_peer peer;
  grpc_auth_context *ctx;
  const char *expected_cn = "cn1";
  const char *expected_sans[] = {"san1", "san2", "san3"};
  size_t i;
  GPR_ASSERT(tsi_construct_peer(4 + GPR_ARRAY_SIZE(expected_sans), &peer) ==
             TSI_OK);
  GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
                 TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
                 &peer.properties[0]) == TSI_OK);
  GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
                 "foo", "bar", &peer.properties[1]) == TSI_OK);
  GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
                 TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, expected_cn,
                 &peer.properties[2]) == TSI_OK);
  GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
                 "chapi", "chapo", &peer.properties[3]) == TSI_OK);
  for (i = 0; i < GPR_ARRAY_SIZE(expected_sans); i++) {
    GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
                   TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY,
                   expected_sans[i], &peer.properties[4 + i]) == TSI_OK);
  }
  ctx = tsi_ssl_peer_to_auth_context(&peer);
  GPR_ASSERT(ctx != NULL);
  GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
  GPR_ASSERT(check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, expected_sans,
                            GPR_ARRAY_SIZE(expected_sans)));
  GPR_ASSERT(check_transport_security_type(ctx));
  GPR_ASSERT(check_x509_cn(ctx, expected_cn));

  tsi_peer_destruct(&peer);
  GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
开发者ID:larsonmpdx,项目名称:grpc,代码行数:35,代码来源:security_connector_test.c


示例3: main

int main(int argc, char **argv) {
    int four[4];
    int five[5];
    uint32_t bitset = 0;
    grpc_test_init(argc, argv);

    GPR_ASSERT(GPR_MIN(1, 2) == 1);
    GPR_ASSERT(GPR_MAX(1, 2) == 2);
    GPR_ASSERT(GPR_MIN(2, 1) == 1);
    GPR_ASSERT(GPR_MAX(2, 1) == 2);
    GPR_ASSERT(GPR_CLAMP(1, 0, 2) == 1);
    GPR_ASSERT(GPR_CLAMP(0, 0, 2) == 0);
    GPR_ASSERT(GPR_CLAMP(2, 0, 2) == 2);
    GPR_ASSERT(GPR_CLAMP(-1, 0, 2) == 0);
    GPR_ASSERT(GPR_CLAMP(3, 0, 2) == 2);
    GPR_ASSERT(GPR_ROTL((uint32_t)0x80000001, 1) == 3);
    GPR_ASSERT(GPR_ROTR((uint32_t)0x80000001, 1) == 0xc0000000);
    GPR_ASSERT(GPR_ARRAY_SIZE(four) == 4);
    GPR_ASSERT(GPR_ARRAY_SIZE(five) == 5);

    GPR_ASSERT(GPR_BITCOUNT((1u << 31) - 1) == 31);
    GPR_ASSERT(GPR_BITCOUNT(1u << 3) == 1);
    GPR_ASSERT(GPR_BITCOUNT(0) == 0);

    GPR_ASSERT(GPR_BITSET(&bitset, 3) == 8);
    GPR_ASSERT(GPR_BITCOUNT(bitset) == 1);
    GPR_ASSERT(GPR_BITGET(bitset, 3) == 1);
    GPR_ASSERT(GPR_BITSET(&bitset, 1) == 10);
    GPR_ASSERT(GPR_BITCOUNT(bitset) == 2);
    GPR_ASSERT(GPR_BITCLEAR(&bitset, 3) == 2);
    GPR_ASSERT(GPR_BITCOUNT(bitset) == 1);
    GPR_ASSERT(GPR_BITGET(bitset, 3) == 0);

    return 0;
}
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:35,代码来源:useful_test.c


示例4: test_compression_algorithm_parse

static void test_compression_algorithm_parse(void) {
  size_t i;
  const char *valid_names[] = {"identity", "gzip", "deflate"};
  const grpc_compression_algorithm valid_algorithms[] = {
      GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE};
  const char *invalid_names[] = {"gzip2", "foo", "", "2gzip"};

  gpr_log(GPR_DEBUG, "test_compression_algorithm_parse");

  for (i = 0; i < GPR_ARRAY_SIZE(valid_names); i++) {
    const char *valid_name = valid_names[i];
    grpc_compression_algorithm algorithm;
    const int success = grpc_compression_algorithm_parse(
        valid_name, strlen(valid_name), &algorithm);
    GPR_ASSERT(success != 0);
    GPR_ASSERT(algorithm == valid_algorithms[i]);
  }

  for (i = 0; i < GPR_ARRAY_SIZE(invalid_names); i++) {
    const char *invalid_name = invalid_names[i];
    grpc_compression_algorithm algorithm;
    int success;
    success = grpc_compression_algorithm_parse(
        invalid_name, strlen(invalid_name), &algorithm);
    GPR_ASSERT(success == 0);
    /* the value of "algorithm" is undefined upon failure */
  }
}
开发者ID:201528013359030,项目名称:grpc,代码行数:28,代码来源:compression_test.c


示例5: request_with_flags

void request_with_flags(grpc_end2end_test_config config) {
  size_t i;
  uint32_t flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1];

  {
    /* check that all grpc_op_types fail when their flag value is set to an
     * invalid value */
    int indices[] = {GRPC_OP_SEND_INITIAL_METADATA, GRPC_OP_SEND_MESSAGE,
                     GRPC_OP_SEND_CLOSE_FROM_CLIENT,
                     GRPC_OP_RECV_INITIAL_METADATA,
                     GRPC_OP_RECV_STATUS_ON_CLIENT};
    for (i = 0; i < GPR_ARRAY_SIZE(indices); ++i) {
      memset(flags_for_op, 0, sizeof(flags_for_op));
      flags_for_op[indices[i]] = 0xDEADBEEF;
      test_invoke_request_with_flags(config, flags_for_op,
                                     GRPC_CALL_ERROR_INVALID_FLAGS);
    }
  }
  {
    /* check valid operation with allowed flags for GRPC_OP_SEND_BUFFER */
    uint32_t flags[] = {GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS,
                        GRPC_WRITE_INTERNAL_COMPRESS};
    for (i = 0; i < GPR_ARRAY_SIZE(flags); ++i) {
      memset(flags_for_op, 0, sizeof(flags_for_op));
      flags_for_op[GRPC_OP_SEND_MESSAGE] = flags[i];
      test_invoke_request_with_flags(config, flags_for_op, GRPC_CALL_OK);
    }
  }
}
开发者ID:Saviio,项目名称:grpc,代码行数:29,代码来源:request_with_flags.c


示例6: grpc_slice_intern_init

void grpc_slice_intern_init(void) {
  if (!g_forced_hash_seed) {
    g_hash_seed = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
  }
  for (size_t i = 0; i < SHARD_COUNT; i++) {
    slice_shard *shard = &g_shards[i];
    gpr_mu_init(&shard->mu);
    shard->count = 0;
    shard->capacity = INITIAL_SHARD_CAPACITY;
    shard->strs = (interned_slice_refcount **)gpr_zalloc(sizeof(*shard->strs) *
                                                         shard->capacity);
  }
  for (size_t i = 0; i < GPR_ARRAY_SIZE(static_metadata_hash); i++) {
    static_metadata_hash[i].hash = 0;
    static_metadata_hash[i].idx = GRPC_STATIC_MDSTR_COUNT;
  }
  max_static_metadata_hash_probe = 0;
  for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) {
    static_metadata_hash_values[i] =
        grpc_slice_default_hash_impl(grpc_static_slice_table[i]);
    for (size_t j = 0; j < GPR_ARRAY_SIZE(static_metadata_hash); j++) {
      size_t slot = (static_metadata_hash_values[i] + j) %
                    GPR_ARRAY_SIZE(static_metadata_hash);
      if (static_metadata_hash[slot].idx == GRPC_STATIC_MDSTR_COUNT) {
        static_metadata_hash[slot].hash = static_metadata_hash_values[i];
        static_metadata_hash[slot].idx = (uint32_t)i;
        if (j > max_static_metadata_hash_probe) {
          max_static_metadata_hash_probe = (uint32_t)j;
        }
        break;
      }
    }
  }
}
开发者ID:endobson,项目名称:grpc,代码行数:34,代码来源:slice_intern.c


示例7: hpack_size

void hpack_size(grpc_end2end_test_config config) {
  static const int interesting_sizes[] = {4096, 0,     100,
                                          1000, 32768, 4 * 1024 * 1024};
  size_t i, j;

  for (i = 0; i < GPR_ARRAY_SIZE(interesting_sizes); i++) {
    for (j = 0; j < GPR_ARRAY_SIZE(interesting_sizes); j++) {
      test_size(config, interesting_sizes[i], interesting_sizes[j]);
    }
  }
}
开发者ID:aaronjheng,项目名称:grpc,代码行数:11,代码来源:hpack_size.c


示例8: on_secure_handshake_done

static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *statep,
                                     grpc_security_status status,
                                     grpc_endpoint *secure_endpoint,
                                     grpc_auth_context *auth_context) {
  server_secure_connect *state = statep;
  if (status == GRPC_SECURITY_OK) {
    if (secure_endpoint) {
      gpr_mu_lock(&state->state->mu);
      if (!state->state->is_shutdown) {
        grpc_transport *transport = grpc_create_chttp2_transport(
            exec_ctx, grpc_server_get_channel_args(state->state->server),
            secure_endpoint, 0);
        grpc_arg args_to_add[2];
        args_to_add[0] = grpc_server_credentials_to_arg(state->state->creds);
        args_to_add[1] = grpc_auth_context_to_arg(auth_context);
        grpc_channel_args *args_copy = grpc_channel_args_copy_and_add(
            state->args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
        grpc_server_setup_transport(exec_ctx, state->state->server, transport,
                                    state->accepting_pollset, args_copy);
        grpc_channel_args_destroy(args_copy);
        grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL);
      } else {
        /* We need to consume this here, because the server may already have
         * gone away. */
        grpc_endpoint_destroy(exec_ctx, secure_endpoint);
      }
      gpr_mu_unlock(&state->state->mu);
    }
  } else {
    gpr_log(GPR_ERROR, "Secure transport failed with error %d", status);
  }
  grpc_channel_args_destroy(state->args);
  state_unref(state->state);
  gpr_free(state);
}
开发者ID:ambasta,项目名称:grpc,代码行数:35,代码来源:server_secure_chttp2.c


示例9: grpc_end2end_tests

void grpc_end2end_tests(grpc_end2end_test_config config) {
  unsigned i;

  for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) {
    test_cancel_after_accept_and_writes_closed(config, cancellation_modes[i]);
  }
}
开发者ID:Abioy,项目名称:kythe,代码行数:7,代码来源:cancel_after_accept_and_writes_closed_legacy.c


示例10: gpr_strjoin_sep

static grpc_channel *create_client(const servers_fixture *f) {
  grpc_channel *client;
  char *client_hostport;
  char *servers_hostports_str;
  grpc_arg arg_array[3];
  grpc_channel_args args;

  servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports,
                                          f->num_servers, ",", NULL);
  gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);

  arg_array[0].type = GRPC_ARG_INTEGER;
  arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
  arg_array[0].value.integer = RETRY_TIMEOUT;
  arg_array[1].type = GRPC_ARG_STRING;
  arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
  arg_array[1].value.string = "ROUND_ROBIN";
  arg_array[2].type = GRPC_ARG_INTEGER;
  arg_array[2].key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS;
  arg_array[2].value.integer = 0;
  args.num_args = GPR_ARRAY_SIZE(arg_array);
  args.args = arg_array;

  client = grpc_insecure_channel_create(client_hostport, &args, NULL);
  gpr_free(client_hostport);
  gpr_free(servers_hostports_str);

  return client;
}
开发者ID:aaronjheng,项目名称:grpc,代码行数:29,代码来源:lb_policies_test.c


示例11: grpc_end2end_tests

void grpc_end2end_tests(grpc_end2end_test_config config) {
  unsigned i;

  for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) {
    test_cancel_in_a_vacuum(config, cancellation_modes[i]);
  }
}
开发者ID:Infixz,项目名称:grpc,代码行数:7,代码来源:cancel_in_a_vacuum.c


示例12: destroy_call

static void destroy_call(void *call, int ignored_success) {
  size_t i;
  grpc_call *c = call;
  grpc_call_stack_destroy(CALL_STACK_FROM_CALL(c));
  grpc_channel_internal_unref(c->channel);
  gpr_mu_destroy(&c->mu);
  for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
    if (c->status[i].details) {
      grpc_mdstr_unref(c->status[i].details);
    }
  }
  for (i = 0; i < c->owned_metadata_count; i++) {
    grpc_mdelem_unref(c->owned_metadata[i]);
  }
  gpr_free(c->owned_metadata);
  for (i = 0; i < GPR_ARRAY_SIZE(c->buffered_metadata); i++) {
    gpr_free(c->buffered_metadata[i].metadata);
  }
  for (i = 0; i < c->send_initial_metadata_count; i++) {
    grpc_mdelem_unref(c->send_initial_metadata[i].md);
  }
  for (i = 0; i < GRPC_CONTEXT_COUNT; i++) {
    if (c->destroy_context[i]) {
      c->destroy_context[i](c->context[i]);
    }
  }
  grpc_sopb_destroy(&c->send_ops);
  grpc_sopb_destroy(&c->recv_ops);
  grpc_bbq_destroy(&c->incoming_queue);
  gpr_slice_buffer_destroy(&c->incoming_message);
  gpr_free(c);
}
开发者ID:caojiguang,项目名称:grpc,代码行数:32,代码来源:call.c


示例13: retry_named_port_failure

static int retry_named_port_failure(int status, request *r,
                                    uv_getaddrinfo_cb getaddrinfo_cb) {
  if (status != 0) {
    // This loop is copied from resolve_address_posix.c
    char *svc[][2] = {{"http", "80"}, {"https", "443"}};
    for (size_t i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
      if (strcmp(r->port, svc[i][0]) == 0) {
        int retry_status;
        uv_getaddrinfo_t *req = gpr_malloc(sizeof(uv_getaddrinfo_t));
        req->data = r;
        retry_status = uv_getaddrinfo(uv_default_loop(), req, getaddrinfo_cb,
                                      r->host, svc[i][1], r->hints);
        if (retry_status < 0 || getaddrinfo_cb == NULL) {
          // The callback will not be called
          gpr_free(req);
        }
        return retry_status;
      }
    }
  }
  /* If this function calls uv_getaddrinfo, it will return that function's
     return value. That function only returns numbers <=0, so we can safely
     return 1 to indicate that we never retried */
  return 1;
}
开发者ID:royalharsh,项目名称:grpc,代码行数:25,代码来源:resolve_address_uv.c


示例14: defined

char *gpr_getenv(const char *name) {
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
  typedef char *(*getenv_type)(const char *);
  static getenv_type getenv_func = NULL;
  /* Check to see which getenv variant is supported (go from most
   * to least secure) */
  const char *names[] = {"secure_getenv", "__secure_getenv", "getenv"};
  for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) {
    getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]);
    if (getenv_func != NULL && strstr(names[i], "secure") == NULL) {
      gpr_log(GPR_DEBUG,
              "Warning: insecure environment read function '%s' used",
              names[i]);
    }
  }
  char *result = getenv_func(name);
  return result == NULL ? result : gpr_strdup(result);
#elif __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17)
  char *result = secure_getenv(name);
  return result == NULL ? result : gpr_strdup(result);
#else
  gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
          "getenv");
  char *result = getenv(name);
  return result == NULL ? result : gpr_strdup(result);
#endif
}
开发者ID:aaronjheng,项目名称:grpc,代码行数:27,代码来源:env_linux.c


示例15: test_size

static void test_size(grpc_end2end_test_config config, int encode_size,
                      int decode_size) {
  size_t i;
  grpc_end2end_test_fixture f;
  grpc_arg server_arg;
  grpc_channel_args server_args;
  grpc_arg client_arg;
  grpc_channel_args client_args;
  char *name;

  server_arg.type = GRPC_ARG_INTEGER;
  server_arg.key = GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER;
  server_arg.value.integer = decode_size;
  server_args.num_args = 1;
  server_args.args = &server_arg;

  client_arg.type = GRPC_ARG_INTEGER;
  client_arg.key = GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER;
  client_arg.value.integer = encode_size;
  client_args.num_args = 1;
  client_args.args = &client_arg;

  gpr_asprintf(&name, "test_size:e=%d:d=%d", encode_size, decode_size);
  f = begin_test(config, name, encode_size != 4096 ? &client_args : NULL,
                 decode_size != 4096 ? &server_args : NULL);
  for (i = 0; i < 4 * GPR_ARRAY_SIZE(hobbits); i++) {
    simple_request_body(config, f, i);
  }
  end_test(&f);
  config.tear_down_data(&f);
  gpr_free(name);
}
开发者ID:aaronjheng,项目名称:grpc,代码行数:32,代码来源:hpack_size.c


示例16: basic_do_promote

static void basic_do_promote(grpc_exec_ctx *exec_ctx, void *args, int success) {
  grpc_unary_promote_args *up_args = args;
  const grpc_pollset_vtable *original_vtable = up_args->original_vtable;
  grpc_pollset *pollset = up_args->pollset;
  grpc_fd *fd = up_args->fd;

  /*
   * This is quite tricky. There are a number of cases to keep in mind here:
   * 1. fd may have been orphaned
   * 2. The pollset may no longer be a unary poller (and we can't let case #1
   * leak to other pollset types!)
   * 3. pollset's fd (which may have changed) may have been orphaned
   * 4. The pollset may be shutting down.
   */

  gpr_mu_lock(&pollset->mu);
  /* First we need to ensure that nobody is polling concurrently */
  GPR_ASSERT(!grpc_pollset_has_workers(pollset));

  gpr_free(up_args);
  /* At this point the pollset may no longer be a unary poller. In that case
   * we should just call the right add function and be done. */
  /* TODO(klempner): If we're not careful this could cause infinite recursion.
   * That's not a problem for now because empty_pollset has a trivial poller
   * and we don't have any mechanism to unbecome multipoller. */
  pollset->in_flight_cbs--;
  if (pollset->shutting_down) {
    /* We don't care about this pollset anymore. */
    if (pollset->in_flight_cbs == 0 && !pollset->called_shutdown) {
      finish_shutdown(exec_ctx, pollset);
    }
  } else if (grpc_fd_is_orphaned(fd)) {
    /* Don't try to add it to anything, we'll drop our ref on it below */
  } else if (pollset->vtable != original_vtable) {
    pollset->vtable->add_fd(exec_ctx, pollset, fd, 0);
  } else if (fd != pollset->data.ptr) {
    grpc_fd *fds[2];
    fds[0] = pollset->data.ptr;
    fds[1] = fd;

    if (fds[0] && !grpc_fd_is_orphaned(fds[0])) {
      grpc_platform_become_multipoller(exec_ctx, pollset, fds,
                                       GPR_ARRAY_SIZE(fds));
      GRPC_FD_UNREF(fds[0], "basicpoll");
    } else {
      /* old fd is orphaned and we haven't cleaned it up until now, so remain a
       * unary poller */
      /* Note that it is possible that fds[1] is also orphaned at this point.
       * That's okay, we'll correct it at the next add or poll. */
      if (fds[0]) GRPC_FD_UNREF(fds[0], "basicpoll");
      pollset->data.ptr = fd;
      GRPC_FD_REF(fd, "basicpoll");
    }
  }

  gpr_mu_unlock(&pollset->mu);

  /* Matching ref in basic_pollset_add_fd */
  GRPC_FD_UNREF(fd, "basicpoll_add");
}
开发者ID:spietz-handy,项目名称:grpc,代码行数:60,代码来源:pollset_posix.c


示例17: decode_suite

void decode_suite(char ext, gpr_timespec (*answer)(long x)) {
    long test_vals[] = {1,       12,       123,       1234,     12345,   123456,
                        1234567, 12345678, 123456789, 98765432, 9876543, 987654,
                        98765,   9876,     987,       98,       9
                       };
    unsigned i;
    char *input;
    for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) {
        gpr_asprintf(&input, "%ld%c", test_vals[i], ext);
        assert_decodes_as(input, answer(test_vals[i]));
        gpr_free(input);

        gpr_asprintf(&input, "   %ld%c", test_vals[i], ext);
        assert_decodes_as(input, answer(test_vals[i]));
        gpr_free(input);

        gpr_asprintf(&input, "%ld %c", test_vals[i], ext);
        assert_decodes_as(input, answer(test_vals[i]));
        gpr_free(input);

        gpr_asprintf(&input, "%ld %c  ", test_vals[i], ext);
        assert_decodes_as(input, answer(test_vals[i]));
        gpr_free(input);
    }
}
开发者ID:jwatt,项目名称:kythe,代码行数:25,代码来源:timeout_encoding_test.c


示例18: test_pairs

static void test_pairs() {
  unsigned i;

  for (i = 0; i < GPR_ARRAY_SIZE(testing_pairs); i++) {
    testing_pair *pair = testing_pairs + i;
    char *scratchpad = gpr_strdup(pair->input);
    grpc_json *json;

    gpr_log(GPR_INFO, "parsing string %i - should %s", i,
            pair->output ? "succeed" : "fail");
    json = grpc_json_parse_string(scratchpad);

    if (pair->output) {
      char *output;

      GPR_ASSERT(json);
      output = grpc_json_dump_to_string(json, 0);
      GPR_ASSERT(output);
      gpr_log(GPR_INFO, "succeeded with output = %s", output);
      GPR_ASSERT(strcmp(output, pair->output) == 0);

      grpc_json_destroy(json);
      gpr_free(output);
    } else {
      gpr_log(GPR_INFO, "failed");
      GPR_ASSERT(!json);
    }

    gpr_free(scratchpad);
  }
}
开发者ID:aaronjheng,项目名称:grpc,代码行数:31,代码来源:json_test.c


示例19: setup_transport

static void setup_transport(grpc_exec_ctx *exec_ctx, void *server,
                            grpc_transport *transport) {
  static grpc_channel_filter const *extra_filters[] = {
      &grpc_http_server_filter};
  grpc_server_setup_transport(exec_ctx, server, transport, extra_filters,
                              GPR_ARRAY_SIZE(extra_filters),
                              grpc_server_get_channel_args(server));
}
开发者ID:madongfly,项目名称:grpc,代码行数:8,代码来源:server_chttp2.c


示例20: setup_transport

static void setup_transport(grpc_exec_ctx *exec_ctx, void *statep,
                            grpc_transport *transport,
                            grpc_auth_context *auth_context) {
  static grpc_channel_filter const *extra_filters[] = {
      &grpc_server_auth_filter, &grpc_http_server_filter};
  grpc_server_secure_state *state = statep;
  grpc_channel_args *args_copy;
  grpc_arg args_to_add[2];
  args_to_add[0] = grpc_server_credentials_to_arg(state->creds);
  args_to_add[1] = grpc_auth_context_to_arg(auth_context);
  args_copy = grpc_channel_args_copy_and_add(
      grpc_server_get_channel_args(state->server), args_to_add,
      GPR_ARRAY_SIZE(args_to_add));
  grpc_server_setup_transport(exec_ctx, state->server, transport, extra_filters,
                              GPR_ARRAY_SIZE(extra_filters), args_copy);
  grpc_channel_args_destroy(args_copy);
}
开发者ID:izouxv,项目名称:gRPC_FMWK,代码行数:17,代码来源:server_secure_chttp2.c



注:本文中的GPR_ARRAY_SIZE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GPR_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ GPOINTER_TO_UINT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap