diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-12-06 09:47:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 09:47:54 -0800 |
commit | 8cf1470a51ea276ca84825e7495d4ee24743540d (patch) | |
tree | 72385cc865094115bc08cb813201d48cb09840bb /test/core/client_channel/uri_parser_test.cc | |
parent | 1d4e99508409be052bd129ba507bae1fbe7eb7fa (diff) |
Revert "Revert "All instances of exec_ctx being passed around in src/core removed""
Diffstat (limited to 'test/core/client_channel/uri_parser_test.cc')
-rw-r--r-- | test/core/client_channel/uri_parser_test.cc | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/test/core/client_channel/uri_parser_test.cc b/test/core/client_channel/uri_parser_test.cc index 30183f9f57..254bfddfb3 100644 --- a/test/core/client_channel/uri_parser_test.cc +++ b/test/core/client_channel/uri_parser_test.cc @@ -20,6 +20,7 @@ #include <string.h> +#include <grpc/grpc.h> #include <grpc/support/log.h> #include "src/core/lib/iomgr/exec_ctx.h" @@ -28,29 +29,28 @@ static void test_succeeds(const char* uri_text, const char* scheme, const char* authority, const char* path, const char* query, const char* fragment) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_core::ExecCtx exec_ctx; + grpc_uri* uri = grpc_uri_parse(uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp(scheme, uri->scheme)); GPR_ASSERT(0 == strcmp(authority, uri->authority)); GPR_ASSERT(0 == strcmp(path, uri->path)); GPR_ASSERT(0 == strcmp(query, uri->query)); GPR_ASSERT(0 == strcmp(fragment, uri->fragment)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_uri_destroy(uri); } static void test_fails(const char* uri_text) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(nullptr == grpc_uri_parse(&exec_ctx, uri_text, 0)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_core::ExecCtx exec_ctx; + GPR_ASSERT(nullptr == grpc_uri_parse(uri_text, 0)); } static void test_query_parts() { { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; const char* uri_text = "http://foo/path?a&b=B&c=&#frag"; - grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp("http", uri->scheme)); @@ -77,14 +77,14 @@ static void test_query_parts() { GPR_ASSERT(nullptr == grpc_uri_get_query_arg(uri, "")); GPR_ASSERT(0 == strcmp("frag", uri->fragment)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_uri_destroy(uri); } { /* test the current behavior of multiple query part values */ - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; const char* uri_text = "http://auth/path?foo=bar=baz&foobar=="; - grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp("http", uri->scheme)); @@ -96,14 +96,13 @@ static void test_query_parts() { GPR_ASSERT(0 == strcmp("bar", grpc_uri_get_query_arg(uri, "foo"))); GPR_ASSERT(0 == strcmp("", grpc_uri_get_query_arg(uri, "foobar"))); - grpc_exec_ctx_finish(&exec_ctx); grpc_uri_destroy(uri); } { /* empty query */ - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; const char* uri_text = "http://foo/path"; - grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp("http", uri->scheme)); @@ -114,13 +113,14 @@ static void test_query_parts() { GPR_ASSERT(nullptr == uri->query_parts); GPR_ASSERT(nullptr == uri->query_parts_values); GPR_ASSERT(0 == strcmp("", uri->fragment)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_uri_destroy(uri); } } int main(int argc, char** argv) { grpc_test_init(argc, argv); + grpc_init(); test_succeeds("http://www.google.com", "http", "www.google.com", "", "", ""); test_succeeds("dns:///foo", "dns", "", "/foo", "", ""); test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "", "", @@ -148,5 +148,6 @@ int main(int argc, char** argv) { test_fails("http://foo?bar#lol#"); test_query_parts(); + grpc_shutdown(); return 0; } |