Converted backoff_test to use gunit

reviewable/pr13494/r5
David Garcia Quintas 7 years ago
parent d3f6eae669
commit 2258cd7ddc
  1. 7
      test/core/backoff/BUILD
  2. 28
      test/core/backoff/backoff_test.cc

@ -26,11 +26,14 @@ package(
grpc_cc_test(
name = "backoff_test",
srcs = ["backoff_test.cc"],
external_deps = [
"gtest",
],
language = "C++",
deps = [
"//:grpc",
"//test/core/util:grpc_test_util",
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
)

@ -21,12 +21,16 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
#include <gtest/gtest.h>
#include "test/core/util/test_config.h"
namespace grpc_core {
namespace grpc {
namespace testing {
namespace {
static void test_constant_backoff(void) {
using grpc_core::Backoff;
TEST(BackOffTest, ConstantBackOff) {
const grpc_millis initial_backoff = 200;
const double multiplier = 1.0;
const double jitter = 0.0;
@ -59,7 +63,7 @@ static void test_constant_backoff(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_min_connect(void) {
TEST(BackOffTest, MinConnect) {
const grpc_millis initial_backoff = 100;
const double multiplier = 1.0;
const double jitter = 0.0;
@ -85,7 +89,7 @@ static void test_min_connect(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_jitter_backoff(void) {
TEST(BackOffTest, NoJitterBackOff) {
const grpc_millis initial_backoff = 2;
const double multiplier = 2.0;
const double jitter = 0.0;
@ -145,7 +149,7 @@ static void test_no_jitter_backoff(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_jitter_backoff(void) {
TEST(BackOffTest, JitterBackOff) {
const grpc_millis initial_backoff = 500;
grpc_millis current_backoff = initial_backoff;
const grpc_millis max_backoff = 1000;
@ -193,17 +197,13 @@ static void test_jitter_backoff(void) {
}
grpc_exec_ctx_finish(&exec_ctx);
}
} // namespace
} // namespace grpc_core
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
gpr_time_init();
grpc_core::test_constant_backoff();
grpc_core::test_min_connect();
grpc_core::test_no_jitter_backoff();
grpc_core::test_jitter_backoff();
return 0;
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

Loading…
Cancel
Save