testing some simple math examples

This commit is contained in:
Janosch
2022-10-10 17:40:57 +01:00
parent a6f275b742
commit 0e43f2bf8c
6 changed files with 46 additions and 13 deletions
+2
View File
@@ -5,6 +5,7 @@
#include "test_can.h"
#include "test_io.h"
#include "test_state.h"
#include "test_logic.h"
extern void Param::Change(Param::PARAM_NUM ParamNum){ };
@@ -18,6 +19,7 @@ int main() {
(TestCase){"test_is_evse_input", test_is_evse_input},
(TestCase){"test_check_unplugged", test_check_unplugged},
(TestCase){"test_disable_all", test_disable_all},
(TestCase){"test_calc_totals", test_calc_totals},
// Example:
//(TestCase){"Your tests name", function_name_without_brackets}
//...
BIN
View File
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
#ifndef TEST_LOGIC_H
#define TEST_LOGIC_H
#endif
#include <assert.h>
#include "test_common.h"
void test_calc_totals()
{
// simple idc addition test
Param::SetInt(Param::c1idc, 12);
Param::SetInt(Param::c2idc, 13);
Param::SetInt(Param::c3idc, 11);
CalcTotals();
s32fp idc = Param::Get(Param::idc);
assert(36 == FP_TOINT(idc));
// udcmax test
Param::SetInt(Param::c1udc, 365);
Param::SetInt(Param::c2udc, 364);
Param::SetInt(Param::c3udc, 366);
CalcTotals();
s32fp udcmax = Param::Get(Param::udc);
assert(366 == FP_TOINT(udcmax));
}