aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-06-07 21:25:53 -0700
committerGravatar ncteisen <ncteisen@gmail.com>2018-06-07 22:28:16 -0700
commiteb2aa9cb3b47eb3d7980952844b32082c3e5e651 (patch)
treeeefb62e14d2e43d0d308c539e1278d16fd2ceefe /test/core
parent2ce76b33e36827ea265ce86fb5688ba23a70021b (diff)
Tighten the bar and refactor and offender:
Diffstat (limited to 'test/core')
-rw-r--r--test/core/transport/status_conversion_test.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc
index 1ed6ccfba6..f7b3c62a40 100644
--- a/test/core/transport/status_conversion_test.cc
+++ b/test/core/transport/status_conversion_test.cc
@@ -33,12 +33,7 @@
#define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \
GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b))
-int main(int argc, char** argv) {
- int i;
-
- grpc_test_init(argc, argv);
- grpc_init();
-
+static void test_grpc_status_to_http2_error() {
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_HTTP2_INTERNAL_ERROR);
@@ -65,7 +60,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAVAILABLE,
GRPC_HTTP2_REFUSED_STREAM);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_HTTP2_INTERNAL_ERROR);
+}
+static void test_grpc_status_to_http2_status() {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_OK, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_CANCELLED, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNKNOWN, 200);
@@ -83,7 +80,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_INTERNAL, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200);
+}
+static void test_http2_error_to_grpc_status() {
const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE;
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline,
GRPC_STATUS_INTERNAL);
@@ -144,7 +143,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_RESOURCE_EXHAUSTED);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, after_deadline,
GRPC_STATUS_PERMISSION_DENIED);
+}
+static void test_http2_status_to_grpc_status() {
HTTP2_STATUS_TO_GRPC_STATUS(200, GRPC_STATUS_OK);
HTTP2_STATUS_TO_GRPC_STATUS(400, GRPC_STATUS_INVALID_ARGUMENT);
HTTP2_STATUS_TO_GRPC_STATUS(401, GRPC_STATUS_UNAUTHENTICATED);
@@ -157,6 +158,18 @@ int main(int argc, char** argv) {
HTTP2_STATUS_TO_GRPC_STATUS(500, GRPC_STATUS_UNKNOWN);
HTTP2_STATUS_TO_GRPC_STATUS(503, GRPC_STATUS_UNAVAILABLE);
HTTP2_STATUS_TO_GRPC_STATUS(504, GRPC_STATUS_DEADLINE_EXCEEDED);
+}
+
+int main(int argc, char** argv) {
+ int i;
+
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ test_grpc_status_to_http2_error();
+ test_grpc_status_to_http2_status();
+ test_http2_error_to_grpc_status();
+ test_http2_status_to_grpc_status();
/* check all status values can be converted */
for (i = 0; i <= 999; i++) {