Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Functions
BrakeSystemControlTest.c File Reference
#include "../Inc/Systems/Controller/BrakeSystemControl.h"
Include dependency graph for BrakeSystemControlTest.c:

Go to the source code of this file.

Functions

int testBrakeSystemControlInit (int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, const char *testName)
 
int testFrontPressure (int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, float pressure, BrakeSystemStatus desiredStatus, const char *testName)
 
int testRearPressure (int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, float pressure, BrakeSystemStatus desiredStatus, const char *testName)
 
int testTemperature (int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, float temperature, BrakeSystemStatus desiredStatus, const char *testName)
 
int brake_main ()
 

Function Documentation

◆ brake_main()

int brake_main ( )

Definition at line 66 of file BrakeSystemControlTest.c.

66 {
67 int tests_failed = 0;
68
69 tests_failed += testBrakeSystemControlInit(0, 0, 0, "Initialization Test");
70 tests_failed += testFrontPressure(0, 0, 0, -1.0, PRESSURE_UNDER_LIMIT, "Front Pressure Below Limit Test");
71 tests_failed += testFrontPressure(0, 0, 0, 2001.0, PRESSURE_OVER_LIMIT, "Front Pressure Above Limit Test");
72 tests_failed += testFrontPressure(0, 0, 0, 1234.0, BRAKES_OK, "Front Pressure Within Limits Test");
73 tests_failed += testRearPressure(0, 0, 0, -1.0, PRESSURE_UNDER_LIMIT, "Rear Pressure Below Limit Test");
74 tests_failed += testRearPressure(0, 0, 0, 2001.0, PRESSURE_OVER_LIMIT, "Rear Pressure Above Limit Test");
75 tests_failed += testRearPressure(0, 0, 0, 1234.0, BRAKES_OK, "Rear Pressure Within Limits Test");
76 tests_failed += testTemperature(1000, 0, 0, 1001.0, TEMPERATURE_OVER_LIMIT, "Temperature Above Limit Test");
77 tests_failed += testTemperature(1000, 0, 0, 123.0, BRAKES_OK, "Temperature Within Limit Test");
78 tests_failed += testTemperature(1000, 0, 0, -1.0, TEMPERATURE_SENSOR_ERROR, "Temperature Negative Test");
79
80 if (tests_failed == 0) {
81 printf("All tests passed.\n");
82 } else {
83 printf("Some tests failed.\n");
84 }
85
86 return tests_failed;
87}
int testRearPressure(int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, float pressure, BrakeSystemStatus desiredStatus, const char *testName)
int testBrakeSystemControlInit(int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, const char *testName)
int testFrontPressure(int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, float pressure, BrakeSystemStatus desiredStatus, const char *testName)
int testTemperature(int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, float temperature, BrakeSystemStatus desiredStatus, const char *testName)
@ TEMPERATURE_OVER_LIMIT
@ PRESSURE_UNDER_LIMIT
@ TEMPERATURE_SENSOR_ERROR
@ BRAKES_OK
@ PRESSURE_OVER_LIMIT
Here is the call graph for this function:

◆ testBrakeSystemControlInit()

int testBrakeSystemControlInit ( int  maxTemp,
int  brakeLightActivationPoint,
int  heavyBrakingActivationPoint,
const char *  testName 
)

Definition at line 3 of file BrakeSystemControlTest.c.

3 {
5 initBrakeSystemControl(&bsc, 0, maxTemp, brakeLightActivationPoint, heavyBrakingActivationPoint, 0, 1, 2);
6
7 if (bsc.status != BRAKES_OK){
8 printf("%s Failed: Initial status is not OK.\n", testName);
9 return 1;
10 }
11 else{
12 printf("%s Failed: Initial status is OK.\n", testName);
13 return 0;
14 }
15}
void initBrakeSystemControl(BrakeSystemControl *bsc, int hz, int maxTemp, int brakeLightActivationPoint, int heavyBrakingActivationPoint, int fbp_channel, int rbp_channel, int temp_channel)
Initializes the Braking System with initial settings.
BrakeSystemStatus status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testFrontPressure()

int testFrontPressure ( int  maxTemp,
int  brakeLightActivationPoint,
int  heavyBrakingActivationPoint,
float  pressure,
BrakeSystemStatus  desiredStatus,
const char *  testName 
)

Definition at line 17 of file BrakeSystemControlTest.c.

17 {
19 initBrakeSystemControl(&bsc, 0, maxTemp, brakeLightActivationPoint, heavyBrakingActivationPoint, 0, 1, 2);
20 setFrontPressure(&bsc, pressure);
21
23 if (status != desiredStatus){
24 printf("%s Failed: Status after update is incorrect, actual status: %d.\n", testName, status);
25 return 1;
26 }
27 else{
28 printf("%s Passed: Status after update is correct.\n", testName);
29 return 0;
30 }
31}
void setFrontPressure(BrakeSystemControl *bsc, float pressure)
BrakeSystemStatus
BrakeSystemStatus checkSensorLimits(BrakeSystemControl *bsc)
Checks if the brake system is within the defined limits and desired ranges.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testRearPressure()

int testRearPressure ( int  maxTemp,
int  brakeLightActivationPoint,
int  heavyBrakingActivationPoint,
float  pressure,
BrakeSystemStatus  desiredStatus,
const char *  testName 
)

Definition at line 33 of file BrakeSystemControlTest.c.

33 {
35 initBrakeSystemControl(&bsc, 0, maxTemp, brakeLightActivationPoint, heavyBrakingActivationPoint, 0, 1, 2);
36 setRearPressure(&bsc, pressure);
37
39 if (status != desiredStatus){
40 printf("%s Failed: Status after update is incorrect, actual status: %d.\n", testName, status);
41 return 1;
42 }
43 else{
44 printf("%s Passed: Status after update is correct.\n", testName);
45 return 0;
46 }
47}
void setRearPressure(BrakeSystemControl *bsc, float pressure)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testTemperature()

int testTemperature ( int  maxTemp,
int  brakeLightActivationPoint,
int  heavyBrakingActivationPoint,
float  temperature,
BrakeSystemStatus  desiredStatus,
const char *  testName 
)

Definition at line 49 of file BrakeSystemControlTest.c.

49 {
51 initBrakeSystemControl(&bsc, 0, maxTemp, brakeLightActivationPoint, heavyBrakingActivationPoint, 0, 1, 2);
52 setTemperature(&bsc, temperature);
53
55 if (status != desiredStatus){
56 printf("%s Failed: Status after update is incorrect, actual status: %d.\n", testName, status);
57 return 1;
58 }
59 else{
60 printf("%s Passed: Status after update is correct.\n", testName);
61 return 0;
62 }
63}
void setTemperature(BrakeSystemControl *bsc, float temperature)
Here is the call graph for this function:
Here is the caller graph for this function: