diff options
author | Alexandros Frantzis <alexandros.frantzis@collabora.com> | 2017-11-27 10:54:49 +0200 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2017-11-27 11:18:25 +0200 |
commit | e2a5f9e02d22f2271f6f0d6be10ba3d1b320dca2 (patch) | |
tree | 25fac6cad8ad6f934e5d3bf2aa98a02f0ef7cfb7 /tests | |
parent | 0343c6ac69ac8bd88a625e2429e87a8db86a04dc (diff) |
shared: Add timespec_is_zero helper
Add a helper function to check if a struct timespec is zero. This helper
will be used in the upcoming commits to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/timespec-test.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/timespec-test.c b/tests/timespec-test.c index a5039110..4e83605d 100644 --- a/tests/timespec-test.c +++ b/tests/timespec-test.c @@ -164,3 +164,14 @@ ZUC_TEST(timespec_test, timespec_sub_to_msec) b.tv_nsec = 1000000L; ZUC_ASSERT_EQ((998 * 1000) + 1, timespec_sub_to_msec(&a, &b)); } + +ZUC_TEST(timespec_test, timespec_is_zero) +{ + struct timespec zero = { 0 }; + struct timespec non_zero_sec = { .tv_sec = 1, .tv_nsec = 0 }; + struct timespec non_zero_nsec = { .tv_sec = 0, .tv_nsec = 1 }; + + ZUC_ASSERT_TRUE(timespec_is_zero(&zero)); + ZUC_ASSERT_FALSE(timespec_is_zero(&non_zero_nsec)); + ZUC_ASSERT_FALSE(timespec_is_zero(&non_zero_sec)); +} |