171 lines
4.4 KiB
C
171 lines
4.4 KiB
C
#include "ut_force.h"
|
|
#include "..\..\src\logic\force.h"
|
|
|
|
static int ut_force_cycle_bmode(fbrake_mode_t bmode, fbrake_mode_t exp_out)
|
|
{
|
|
fbrake_mode_t out = force_cycle_bmode(bmode);
|
|
|
|
printf("Brake mode:%d\n", bmode);
|
|
printf("Output:%d Expected:%d\n", out, exp_out);
|
|
|
|
if(out==exp_out)
|
|
{
|
|
printf("PASS\n\n");
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
printf("FAIL\n\n");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int ut_force_cycle_bmode_test(void)
|
|
{
|
|
printf("******************************************************\n");
|
|
printf("fbrake_mode_t force_cycle_bmode(fbrake_mode_t bmode)\n");
|
|
|
|
int test_res;
|
|
int pass = 1;
|
|
|
|
fbrake_mode_t bmode;
|
|
|
|
fbrake_mode_t exp_out;
|
|
|
|
bmode = FORCE_BMODE_OPEN;
|
|
exp_out = FORCE_BMODE_KEEP;
|
|
test_res = ut_force_cycle_bmode(bmode,exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
bmode = FORCE_BMODE_KEEP;
|
|
exp_out = FORCE_BMODE_LOCK;
|
|
test_res = ut_force_cycle_bmode(bmode,exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
bmode = FORCE_BMODE_LOCK;
|
|
exp_out = FORCE_BMODE_OPEN;
|
|
test_res = ut_force_cycle_bmode(bmode,exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
return pass;
|
|
}
|
|
|
|
static int ut_force_next(uint8_t handbrake, uint8_t brakes, fbrake_mode_t bmode, uint8_t user_force, uint16_t hbarke_act_time, uint8_t exp_out)
|
|
{
|
|
uint8_t out = force_next(handbrake, brakes, bmode, user_force, hbarke_act_time);
|
|
|
|
printf("Handbrake:%d Brakes:%d Brake-Mode:%d User-Force:%d Handbrake-time:%d\n", handbrake, brakes, bmode, user_force, hbarke_act_time);
|
|
printf("Output:%d Expected:%d\n", out, exp_out);
|
|
|
|
if(out==exp_out)
|
|
{
|
|
printf("PASS\n\n");
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
printf("FAIL\n\n");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int ut_force_next_test(void)
|
|
{
|
|
printf("******************************************************\n");
|
|
printf("uint8_t force_next(uint8_t handbrake, uint8_t brakes, fbrake_mode_t bmode, uint8_t user_force, uint16_t hbarke_act_time)\n");
|
|
|
|
int test_res;
|
|
int pass = 1;
|
|
|
|
uint8_t handbrake;
|
|
uint8_t brakes;
|
|
fbrake_mode_t bmode;
|
|
uint8_t user_force;
|
|
uint16_t hbarke_act_time;
|
|
|
|
uint8_t exp_out;
|
|
|
|
handbrake = 0;
|
|
brakes = 0;
|
|
bmode = FORCE_BMODE_OPEN;
|
|
user_force = 0;
|
|
hbarke_act_time = 0;
|
|
exp_out = 0;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 0;
|
|
brakes = 0;
|
|
bmode = FORCE_BMODE_OPEN;
|
|
user_force = 99;
|
|
hbarke_act_time = 0;
|
|
exp_out = 99;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 0;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_OPEN;
|
|
user_force = 99;
|
|
hbarke_act_time = 0;
|
|
exp_out = 0;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 0;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_KEEP;
|
|
user_force = 99;
|
|
hbarke_act_time = 0;
|
|
exp_out = 99;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 0;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_LOCK;
|
|
user_force = 99;
|
|
hbarke_act_time = 0;
|
|
exp_out = 100;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 1;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_LOCK;
|
|
user_force = 99;
|
|
hbarke_act_time = 0;
|
|
exp_out = 0;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 1;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_LOCK;
|
|
user_force = 99;
|
|
hbarke_act_time = FORCE_MAX_HBRAKE_HOLD_TIME-1;
|
|
exp_out = 0;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 1;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_LOCK;
|
|
user_force = 99;
|
|
hbarke_act_time = FORCE_MAX_HBRAKE_HOLD_TIME;
|
|
exp_out = 100;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
handbrake = 1;
|
|
brakes = 1;
|
|
bmode = FORCE_BMODE_LOCK;
|
|
user_force = 99;
|
|
hbarke_act_time = FORCE_MAX_HBRAKE_HOLD_TIME+1;
|
|
exp_out = 100;
|
|
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
|
if(!test_res) pass = 0;
|
|
|
|
return pass;
|
|
}
|