timer mocking

This commit is contained in:
Janosch
2022-10-10 22:34:56 +01:00
parent 5c8f5694f0
commit d7673cd292
11 changed files with 53 additions and 15 deletions
+1
View File
@@ -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}
//...
BIN
View File
Binary file not shown.
+2 -3
View File
@@ -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
+20
View File
@@ -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);
}
+5
View File
@@ -0,0 +1,5 @@
#include "timer_mock.h"
uint32_t rtc_get_counter_val(){
return Param::Get(Param::test_time) >> 5;
}
+3
View File
@@ -0,0 +1,3 @@
#include <stdint.h>
#include "../libopeninv/include/params.h"
uint32_t rtc_get_counter_val();