diff options
author | Ji Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96> | 2009-10-23 13:18:29 +0000 |
---|---|---|
committer | Ji Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96> | 2009-10-23 13:18:29 +0000 |
commit | ba1dc4b0d86aee20573ed6e5ac6e60864089d546 (patch) | |
tree | 312cb918fb50c0c882d2aa6992c4a35cccc2ea37 /src/util/test_time.c | |
parent | df6cfdf376e83edfd04e083c6feafa8577bc237c (diff) | |
download | gnunet-ba1dc4b0d86aee20573ed6e5ac6e60864089d546.tar.gz gnunet-ba1dc4b0d86aee20573ed6e5ac6e60864089d546.zip |
complete Test_time.c
Diffstat (limited to 'src/util/test_time.c')
-rw-r--r-- | src/util/test_time.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/test_time.c b/src/util/test_time.c index 2454efd32..cc7708946 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c | |||
@@ -35,9 +35,17 @@ check () | |||
35 | struct GNUNET_TIME_Absolute future; | 35 | struct GNUNET_TIME_Absolute future; |
36 | struct GNUNET_TIME_Absolute past; | 36 | struct GNUNET_TIME_Absolute past; |
37 | struct GNUNET_TIME_Absolute last; | 37 | struct GNUNET_TIME_Absolute last; |
38 | struct GNUNET_TIME_Absolute forever; | ||
39 | struct GNUNET_TIME_Absolute zero; | ||
38 | struct GNUNET_TIME_Relative rel; | 40 | struct GNUNET_TIME_Relative rel; |
41 | struct GNUNET_TIME_Relative relForever; | ||
42 | struct GNUNET_TIME_Relative relUnit; | ||
39 | struct GNUNET_TIME_RelativeNBO reln; | 43 | struct GNUNET_TIME_RelativeNBO reln; |
40 | unsigned int i; | 44 | unsigned int i; |
45 | forever = GNUNET_TIME_absolute_get_forever(); | ||
46 | relForever = GNUNET_TIME_relative_get_forever(); | ||
47 | relUnit = GNUNET_TIME_relative_get_unit (); | ||
48 | zero.value = 0; | ||
41 | 49 | ||
42 | last = now = GNUNET_TIME_absolute_get (); | 50 | last = now = GNUNET_TIME_absolute_get (); |
43 | while (now.value == last.value) | 51 | while (now.value == last.value) |
@@ -69,6 +77,9 @@ check () | |||
69 | GNUNET_log_skip (0, GNUNET_NO); | 77 | GNUNET_log_skip (0, GNUNET_NO); |
70 | GNUNET_assert (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value); | 78 | GNUNET_assert (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value); |
71 | 79 | ||
80 | GNUNET_assert (GNUNET_TIME_relative_add (relForever,relForever).value == relForever.value); | ||
81 | GNUNET_assert (GNUNET_TIME_relative_add (relUnit,relUnit).value == 2*relUnit.value); | ||
82 | |||
72 | /* check relation check in get_duration */ | 83 | /* check relation check in get_duration */ |
73 | future.value = now.value + 1000000; | 84 | future.value = now.value + 1000000; |
74 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).value == | 85 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).value == |
@@ -76,6 +87,8 @@ check () | |||
76 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).value == | 87 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).value == |
77 | 0); | 88 | 0); |
78 | 89 | ||
90 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).value == forever.value); | ||
91 | |||
79 | past.value = now.value - 1000000; | 92 | past.value = now.value - 1000000; |
80 | rel = GNUNET_TIME_absolute_get_duration (future); | 93 | rel = GNUNET_TIME_absolute_get_duration (future); |
81 | GNUNET_assert (rel.value == 0); | 94 | GNUNET_assert (rel.value == 0); |
@@ -101,6 +114,14 @@ check () | |||
101 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); | 114 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); |
102 | GNUNET_assert (future.value == now.value + 1000); | 115 | GNUNET_assert (future.value == now.value + 1000); |
103 | 116 | ||
117 | future = GNUNET_TIME_absolute_add (forever,GNUNET_TIME_UNIT_ZERO); | ||
118 | GNUNET_assert (future.value == forever.value); | ||
119 | |||
120 | rel.value = ((uint64_t) - 1LL) - 1024; | ||
121 | now.value = rel.value; | ||
122 | future = GNUNET_TIME_absolute_add (now,rel); | ||
123 | GNUNET_assert (future.value == forever.value); | ||
124 | |||
104 | /* check zero */ | 125 | /* check zero */ |
105 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO); | 126 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO); |
106 | GNUNET_assert (future.value == now.value); | 127 | GNUNET_assert (future.value == now.value); |