1#include "externals/unity.h"
5#define MAXVAL 0xFFFFFFFF
11void test_millisec_timer_not_wrap_once(
void) {
115void test_millisec_timer_do_wrap_once(
void) {
121 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
123 "Checking the test is what it should be, not an error with millisec "
124 "timer but with the test");
125 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
126 0, timer.expire_time,
127 "Checking the test is what it should be, not an error with millisec "
128 "timer but with the test");
138 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
140 "Checking the test is what it should be, not an error with millisec "
141 "timer but with the test");
142 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
143 1, timer.expire_time,
144 "Checking the test is what it should be, not an error with millisec "
145 "timer but with the test");
156 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
157 MAXVAL - 1, timer.set_time,
158 "Checking the test is what it should be, not an error with millisec "
159 "timer but with the test");
160 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
161 0, timer.expire_time,
162 "Checking the test is what it should be, not an error with millisec "
163 "timer but with the test");
178 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
179 MAXVAL, timer.set_time,
180 "Checking the test is what it should be, not an error with millisec "
181 "timer but with the test");
182 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
183 0, timer.expire_time,
184 "Checking the test is what it should be, not an error with millisec "
185 "timer but with the test");
199 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
200 MAXVAL, timer.set_time,
201 "Checking the test is what it should be, not an error with millisec "
202 "timer but with the test");
203 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
204 1, timer.expire_time,
205 "Checking the test is what it should be, not an error with millisec "
206 "timer but with the test");
219void test_millisec_timer_not_wrap_repeat(
void) {
303 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
304 MAXVAL, timer.set_time,
305 "Checking the test is what it should be, not an error with millisec "
306 "timer but with the test");
307 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
308 MAXVAL - 1, timer.expire_time,
309 "Checking the test is what it should be, not an error with millisec "
310 "timer but with the test");
315 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
316 MAXVAL - 1, timer.set_time,
317 "Checking the test is what it should be, not an error with millisec "
318 "timer but with the test");
319 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
320 MAXVAL - 2, timer.expire_time,
321 "Checking the test is what it should be, not an error with millisec "
322 "timer but with the test");
358 TEST_ASSERT_EQUAL_HEX32_MESSAGE(
359 MAXVAL, timer.set_time,
360 "Checking the test is what it should be, not an error with millisec "
361 "timer but with the test");
362 TEST_ASSERT_EQUAL_HEX32_MESSAGE(
363 2 * MAXVAL - 5000, timer.expire_time,
364 "Checking the test is what it should be, not an error with millisec "
365 "timer but with the test");
372void test_millisec_timer_do_wrap_repeat(
void) {
378 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
380 "Checking the test is what it should be, not an error with millisec "
381 "timer but with the test");
382 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
383 0, timer.expire_time,
384 "Checking the test is what it should be, not an error with millisec "
385 "timer but with the test");
390 TEST_ASSERT_EQUAL_HEX32_MESSAGE(
392 "Checking the test is what it should be, not an error with millisec "
393 "timer but with the test");
394 TEST_ASSERT_EQUAL_HEX32_MESSAGE(
395 MAXVAL, timer.expire_time,
396 "Checking the test is what it should be, not an error with millisec "
397 "timer but with the test");
406 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
408 "Checking the test is what it should be, not an error with millisec "
409 "timer but with the test");
410 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
411 1, timer.expire_time,
412 "Checking the test is what it should be, not an error with millisec "
413 "timer but with the test");
419 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
421 "Checking the test is what it should be, not an error with millisec "
422 "timer but with the test");
423 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
424 0, timer.expire_time,
425 "Checking the test is what it should be, not an error with millisec "
426 "timer but with the test");
436 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
437 MAXVAL - 1, timer.set_time,
438 "Checking the test is what it should be, not an error with millisec "
439 "timer but with the test");
440 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
441 0, timer.expire_time,
442 "Checking the test is what it should be, not an error with millisec "
443 "timer but with the test");
447 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
449 "Checking the test is what it should be, not an error with millisec "
450 "timer but with the test");
451 TEST_ASSERT_EQUAL_UINT32_MESSAGE(
452 2, timer.expire_time,
453 "Checking the test is what it should be, not an error with millisec "
454 "timer but with the test");
468 RUN_TEST(test_millisec_timer_not_wrap_once);
469 RUN_TEST(test_millisec_timer_do_wrap_once);
470 RUN_TEST(test_millisec_timer_not_wrap_repeat);
471 RUN_TEST(test_millisec_timer_do_wrap_repeat);
void millisec_timer_set_rel(millisec_timer *timer, const millisec_timer_unit_t now, const millisec_timer_unit_t rel)
Set timer to expire in the future.
bool millisec_timer_is_expired_repeat(millisec_timer *timer, const millisec_timer_unit_t now)
Check if timer has expired & if so, re-enable for the same interval.
bool millisec_timer_is_expired(millisec_timer *timer, const millisec_timer_unit_t now)
Check if timer has expired & if so, disable it.
Portable millisecond timer.
portable millisecond timer