aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2017-03-29 10:57:31 -0700
committerGravatar yang-g <yangg@google.com>2017-03-29 17:22:19 -0700
commit07429fa9a6e0e705b8e297bd04ff41786b4f7f7a (patch)
tree1981d8de836d137b3b52ccef925660ee8372fb30 /test/core
parent1aba869e9e3046766cab8744a028a20a8af62dd2 (diff)
Update time_cmp to ignore tv_nsec when tv_sec is INT64 MAX or MIN
Diffstat (limited to 'test/core')
-rw-r--r--test/core/support/time_test.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c
index 73e43caa69..4cb36a788c 100644
--- a/test/core/support/time_test.c
+++ b/test/core/support/time_test.c
@@ -256,11 +256,19 @@ static void test_similar(void) {
}
static void test_convert_extreme(void) {
- gpr_timespec realtime_t = {INT64_MAX, 1, GPR_CLOCK_REALTIME};
- gpr_timespec monotime_t =
- gpr_convert_clock_type(realtime_t, GPR_CLOCK_MONOTONIC);
- GPR_ASSERT(monotime_t.tv_sec == realtime_t.tv_sec);
- GPR_ASSERT(monotime_t.clock_type == GPR_CLOCK_MONOTONIC);
+ gpr_timespec realtime = {INT64_MAX, 1, GPR_CLOCK_REALTIME};
+ gpr_timespec monotime = gpr_convert_clock_type(realtime, GPR_CLOCK_MONOTONIC);
+ GPR_ASSERT(monotime.tv_sec == realtime.tv_sec);
+ GPR_ASSERT(monotime.clock_type == GPR_CLOCK_MONOTONIC);
+}
+
+static void test_cmp_extreme(void) {
+ gpr_timespec t1 = {INT64_MAX, 1, GPR_CLOCK_REALTIME};
+ gpr_timespec t2 = {INT64_MAX, 2, GPR_CLOCK_REALTIME};
+ GPR_ASSERT(gpr_time_cmp(t1, t2) == 0);
+ t1.tv_sec = INT64_MIN;
+ t2.tv_sec = INT64_MIN;
+ GPR_ASSERT(gpr_time_cmp(t1, t2) == 0);
}
int main(int argc, char *argv[]) {
@@ -272,5 +280,6 @@ int main(int argc, char *argv[]) {
test_sticky_infinities();
test_similar();
test_convert_extreme();
+ test_cmp_extreme();
return 0;
}