Skip to content

Commit 47ab32a

Browse files
committed
extras:tests:unitTes: size() and empty() unit tests
1 parent 0f6b23c commit 47ab32a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

extras/tests/unitTest/unitTest.ino

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,49 @@ test(timer_ticks) {
360360
assertEqual(big, timer.ticks()); // big pending again
361361
}
362362

363+
test(timer_size) {
364+
pre_test();
365+
366+
Timer<0x2, CLOCK::millis, Task *> timer;
367+
368+
assertEqual(timer.size(), 0UL);
369+
370+
auto t = make_task();
371+
372+
auto r = timer.in(0UL, handler, &t);
373+
374+
assertNotEqual((unsigned long)r, 0UL);
375+
assertEqual(timer.size(), 1UL);
376+
377+
r = timer.in(0UL, handler, &t);
378+
379+
assertNotEqual((unsigned long)r, 0UL);
380+
assertEqual(timer.size(), 2UL);
381+
382+
timer.cancel();
383+
384+
assertEqual(timer.size(), 0UL);
385+
}
386+
387+
test(timer_empty) {
388+
pre_test();
389+
390+
Timer<0x1, CLOCK::millis, Task *> timer;
391+
392+
assertEqual(timer.empty(), true);
393+
394+
auto t = make_task();
395+
396+
auto r = timer.in(0UL, handler, &t);
397+
398+
assertNotEqual((unsigned long)r, 0UL);
399+
assertEqual(timer.empty(), false);
400+
401+
timer.cancel();
402+
403+
assertEqual(timer.empty(), true);
404+
}
405+
363406
test(timer_rollover_every) {
364407
pre_test();
365408

0 commit comments

Comments
 (0)