diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-08-29 18:17:27 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-08-29 18:17:27 +0200 |
commit | 7b546bea2e374a20c52ffd71de51f91eba07256d (patch) | |
tree | e743d06f609ab755d688d5b0cef80be14ac66b67 /tests/unit/core | |
parent | ddd829a1c707deb2ff1d4dfe2a5bd4ab09d048ba (diff) | |
download | weechat-7b546bea2e374a20c52ffd71de51f91eba07256d.zip |
api: use microseconds instead of milliseconds in functions util_timeval_diff and util_timeval_add
Diffstat (limited to 'tests/unit/core')
-rw-r--r-- | tests/unit/core/test-util.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/unit/core/test-util.cpp b/tests/unit/core/test-util.cpp index 84f5a2df2..eb2174e1e 100644 --- a/tests/unit/core/test-util.cpp +++ b/tests/unit/core/test-util.cpp @@ -43,9 +43,11 @@ TEST_GROUP(Util) TEST(Util, Timeval) { + struct timeval tv_zero = { 0, 0 }; struct timeval tv1 = { 123456, 12000 }; struct timeval tv2 = { 123456, 15000 }; struct timeval tv3 = { 123457, 15000 }; + struct timeval tv4 = { 1409288400, 0 }; /* 2014-08-29 05:00:00 GMT */ struct timeval tv; /* comparison */ @@ -60,17 +62,18 @@ TEST(Util, Timeval) LONGS_EQUAL(0, util_timeval_diff (NULL, NULL)); LONGS_EQUAL(0, util_timeval_diff (NULL, &tv1)); LONGS_EQUAL(0, util_timeval_diff (&tv1, NULL)); - LONGS_EQUAL(3, util_timeval_diff (&tv1, &tv2)); - LONGS_EQUAL(1003, util_timeval_diff (&tv1, &tv3)); + LONGS_EQUAL(3000, util_timeval_diff (&tv1, &tv2)); + LONGS_EQUAL(1003000, util_timeval_diff (&tv1, &tv3)); + CHECK(1409288400 * 1000000LL == util_timeval_diff (&tv_zero, &tv4)); /* add interval */ util_timeval_add (NULL, 0); tv.tv_sec = 123456; tv.tv_usec = 12000; - util_timeval_add (&tv, 10); + util_timeval_add (&tv, 10000); LONGS_EQUAL(123456, tv.tv_sec); LONGS_EQUAL(22000, tv.tv_usec); - util_timeval_add (&tv, 4000); + util_timeval_add (&tv, 4000000); LONGS_EQUAL(123460, tv.tv_sec); LONGS_EQUAL(22000, tv.tv_usec); } |