Skip to content

Commit

Permalink
Merge pull request grpc#5311 from vjpai/qa
Browse files Browse the repository at this point in the history
Add a test for immediate and historic alarms
  • Loading branch information
dgquintas committed Feb 23, 2016
2 parents 914a2e7 + e32ef7a commit 27b3f77
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/cpp/common/alarm_cpp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 27b3f77

Please sign in to comment.