timer mocking
This commit is contained in:
@@ -20,6 +20,7 @@ int main() {
|
||||
(TestCase){"test_check_unplugged", test_check_unplugged},
|
||||
(TestCase){"test_disable_all", test_disable_all},
|
||||
(TestCase){"test_calc_totals", test_calc_totals},
|
||||
(TestCase){"test_check_timeout", test_check_timeout},
|
||||
// Example:
|
||||
//(TestCase){"Your tests name", function_name_without_brackets}
|
||||
//...
|
||||
|
||||
Binary file not shown.
+2
-3
@@ -1,7 +1,6 @@
|
||||
|
||||
#ifndef TEST_COMMON_H
|
||||
#define TEST_COMMON_H
|
||||
#include "charger.h"
|
||||
#include "timer_mock.h"
|
||||
#include "digio_mock.h"
|
||||
|
||||
#include "charger.h"
|
||||
#endif
|
||||
|
||||
@@ -27,3 +27,23 @@ void test_calc_totals()
|
||||
s32fp udcmax = Param::Get(Param::udc);
|
||||
assert(366 == FP_TOINT(udcmax));
|
||||
}
|
||||
|
||||
// TIMER NEEDED
|
||||
void test_check_timeout()
|
||||
{
|
||||
bool res;
|
||||
startTime = 11;
|
||||
Param::SetInt(Param::test_time, 14 * 60);
|
||||
Param::SetInt(Param::timelim, 13);
|
||||
|
||||
res = CheckTimeout();
|
||||
assert(res);
|
||||
|
||||
Param::SetInt(Param::test_time, 12 * 60);
|
||||
res = CheckTimeout();
|
||||
assert(!res);
|
||||
|
||||
startTime = 1100;
|
||||
res = CheckTimeout();
|
||||
assert(res);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "timer_mock.h"
|
||||
|
||||
uint32_t rtc_get_counter_val(){
|
||||
return Param::Get(Param::test_time) >> 5;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <stdint.h>
|
||||
#include "../libopeninv/include/params.h"
|
||||
uint32_t rtc_get_counter_val();
|
||||
Reference in New Issue
Block a user