[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Improve coverage on tv_udiff, and tv_mdiff.



commit f05a213fe1706ce3ba76e12dc8e6f36f74c92794
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jun 16 10:07:44 2016 -0400

    Improve coverage on tv_udiff, and tv_mdiff.
    
    I found some bugs in tv_mdiff; separate commit for that
---
 src/test/test_util.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/test/test_util.c b/src/test/test_util.c
index c643fea..dd600d9 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -261,7 +261,7 @@ test_util_time(void *arg)
   int i;
   struct timeval tv;
 
-  /* Test tv_udiff */
+  /* Test tv_udiff and tv_mdiff */
 
   (void)arg;
   start.tv_sec = 5;
@@ -271,22 +271,31 @@ test_util_time(void *arg)
   end.tv_usec = 5000;
 
   tt_int_op(0L,OP_EQ, tv_udiff(&start, &end));
+  tt_int_op(0L,OP_EQ, tv_mdiff(&start, &end));
 
   end.tv_usec = 7000;
 
   tt_int_op(2000L,OP_EQ, tv_udiff(&start, &end));
+  tt_int_op(2L,OP_EQ, tv_mdiff(&start, &end));
 
   end.tv_sec = 6;
 
   tt_int_op(1002000L,OP_EQ, tv_udiff(&start, &end));
+  tt_int_op(1002L,OP_EQ, tv_mdiff(&start, &end));
 
   end.tv_usec = 0;
 
   tt_int_op(995000L,OP_EQ, tv_udiff(&start, &end));
+  // tt_int_op(996L,OP_EQ, tv_mdiff(&start, &end)); // XXXX fails
 
   end.tv_sec = 4;
 
   tt_int_op(-1005000L,OP_EQ, tv_udiff(&start, &end));
+  // tt_int_op(-1005L,OP_EQ, tv_udiff(&start, &end)); // XXXX Fails
+
+  end.tv_sec = TIME_MAX;
+  tt_int_op(LONG_MAX, OP_EQ, tv_udiff(&start, &end));
+  tt_int_op(LONG_MAX, OP_EQ, tv_mdiff(&start, &end));
 
   /* Test tor_timegm & tor_gmtime_r */
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits