mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Comments
This commit is contained in:
parent
4fa97a07b9
commit
6bc253ff6e
1 changed files with 7 additions and 0 deletions
|
@ -11,25 +11,32 @@ TEST(timer_test) {
|
|||
unsigned long test_interval = 10;
|
||||
bool result;
|
||||
|
||||
// Create a timer, assert that it hasn't elapsed immediately
|
||||
testlib_millis = 30;
|
||||
MyTimer timer(test_interval);
|
||||
result = timer.elapsed();
|
||||
ASSERT_EQ(result, false);
|
||||
|
||||
// Test interval - 1, shouldn't have elapsed
|
||||
testlib_millis += test_interval - 1;
|
||||
result = timer.elapsed();
|
||||
ASSERT_EQ(result, false);
|
||||
|
||||
// Add 1, so now it should have elapsed
|
||||
testlib_millis += 1;
|
||||
result = timer.elapsed();
|
||||
ASSERT_EQ(result, true);
|
||||
|
||||
// The timer should have reset when it elapsed
|
||||
result = timer.elapsed();
|
||||
ASSERT_EQ(result, false);
|
||||
|
||||
// Test close to the next interval
|
||||
testlib_millis += test_interval - 1;
|
||||
result = timer.elapsed();
|
||||
ASSERT_EQ(result, false);
|
||||
|
||||
// Add 1, ensure that the timer elapses but only once
|
||||
testlib_millis += 1;
|
||||
result = timer.elapsed();
|
||||
ASSERT_EQ(result, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue