mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Added a test, new structure
This commit is contained in:
parent
1d09dacccb
commit
aca520c506
10 changed files with 66 additions and 23 deletions
31
test/utils/timer_test.cpp
Normal file
31
test/utils/timer_test.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
// The test library must be included first!
|
||||
#include "timer.cpp"
|
||||
#include "../test_lib.h"
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
/* Test functions */
|
||||
|
||||
TEST(timer_test) {
|
||||
unsigned long test_interval = 10;
|
||||
|
||||
testlib_millis = 0;
|
||||
MyTimer timer(test_interval);
|
||||
ASSERT_EQ(timer.elapsed(), false);
|
||||
|
||||
testlib_millis = test_interval - 1;
|
||||
ASSERT_EQ(timer.elapsed(), false);
|
||||
|
||||
testlib_millis = test_interval;
|
||||
ASSERT_EQ(timer.elapsed(), true);
|
||||
ASSERT_EQ(timer.elapsed(), false);
|
||||
|
||||
testlib_millis = 2 * test_interval - 1;
|
||||
ASSERT_EQ(timer.elapsed(), false);
|
||||
|
||||
testlib_millis = 2 * test_interval;
|
||||
ASSERT_EQ(timer.elapsed(), true);
|
||||
ASSERT_EQ(timer.elapsed(), false);
|
||||
}
|
||||
|
||||
TEST_MAIN();
|
Loading…
Add table
Add a link
Reference in a new issue