aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar David G. Quintas <dgq@google.com>2016-02-22 23:05:15 -0800
committerGravatar David G. Quintas <dgq@google.com>2016-02-22 23:05:15 -0800
commit27b3f776da80da9d74e9c6a43d6794c86ba0cfb3 (patch)
treed18e5390a168d31c8ec012c63204d95d0166bd73 /test
parent914a2e7217e3376dfbd69fa37008d6d60f797689 (diff)
parente32ef7acde174bcf1ffca4f46a3e59b768c9a2ca (diff)
Merge pull request #5311 from vjpai/qa
Add a test for immediate and historic alarms
Diffstat (limited to 'test')
-rw-r--r--test/cpp/common/alarm_cpp_test.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_cpp_test.cc
index 4745ef14ec..5d7344046c 100644
--- a/test/cpp/common/alarm_cpp_test.cc
+++ b/test/cpp/common/alarm_cpp_test.cc
@@ -55,6 +55,36 @@ TEST(AlarmTest, RegularExpiry) {
EXPECT_EQ(junk, output_tag);
}
+TEST(AlarmTest, ZeroExpiry) {
+ CompletionQueue cq;
+ void* junk = reinterpret_cast<void*>(1618033);
+ Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(0), junk);
+
+ void* output_tag;
+ bool ok;
+ const CompletionQueue::NextStatus status = cq.AsyncNext(
+ (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(0));
+
+ EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
+ EXPECT_TRUE(ok);
+ EXPECT_EQ(junk, output_tag);
+}
+
+TEST(AlarmTest, NegativeExpiry) {
+ CompletionQueue cq;
+ void* junk = reinterpret_cast<void*>(1618033);
+ Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(-1), junk);
+
+ void* output_tag;
+ bool ok;
+ const CompletionQueue::NextStatus status = cq.AsyncNext(
+ (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(0));
+
+ EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
+ EXPECT_TRUE(ok);
+ EXPECT_EQ(junk, output_tag);
+}
+
TEST(AlarmTest, Cancellation) {
CompletionQueue cq;
void* junk = reinterpret_cast<void*>(1618033);