aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2017-03-30 00:03:44 -0700
committerGravatar GitHub <noreply@github.com>2017-03-30 00:03:44 -0700
commita232b52c4ac97272b9342e4609208439bf9a4eeb (patch)
tree280387b5c7d09d86e45a99bdce155d24d133f096 /test/core
parentb657f5e9df87b6878cbaddb8caff4aad36c88755 (diff)
parent07429fa9a6e0e705b8e297bd04ff41786b4f7f7a (diff)
Merge pull request #10352 from yang-g/time_conversion
Make convert clock_type consistent with add/sub when dealing with ext…
Diffstat (limited to 'test/core')
-rw-r--r--test/core/support/time_test.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c
index e9ca08d041..4cb36a788c 100644
--- a/test/core/support/time_test.c
+++ b/test/core/support/time_test.c
@@ -255,6 +255,22 @@ static void test_similar(void) {
gpr_time_from_micros(10, GPR_TIMESPAN)));
}
+static void test_convert_extreme(void) {
+ 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[]) {
grpc_test_init(argc, argv);
@@ -263,5 +279,7 @@ int main(int argc, char *argv[]) {
test_overflow();
test_sticky_infinities();
test_similar();
+ test_convert_extreme();
+ test_cmp_extreme();
return 0;
}