Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ jobs:
src/Interfaces/IControllable.st \
src/FunctionBlocks/TrafficLight.st \
--test tests/test_interface.st

- name: Run safety validation tests
run: |
strucpp \
src/DataTypes/TrafficTypes.st \
--test tests/test_safety_validation.st
2 changes: 1 addition & 1 deletion src/DataTypes/TrafficTypes.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TYPE
PhaseTiming :
STRUCT
greenDuration : TIME := T#30s;
yellowDuration : TIME := T#5s;
yellowDuration : TIME := T#2s;
redDuration : TIME := T#35s;
END_STRUCT;

Expand Down
38 changes: 38 additions & 0 deletions tests/test_safety_validation.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(* Safety validation tests — ensure timing parameters meet minimum requirements *)

TEST 'Default yellow duration meets minimum safety threshold'
VAR timing : PhaseTiming; END_VAR

(* Federal Highway Administration recommends minimum 3s yellow for
intersections with speed limits up to 25 mph. This test enforces
that the default yellow duration is at least 3 seconds. *)
ASSERT_TRUE(timing.yellowDuration >= T#3s,
'Yellow duration must be at least 3s for safety');
END_TEST

TEST 'Default green duration is reasonable'
VAR timing : PhaseTiming; END_VAR

ASSERT_TRUE(timing.greenDuration >= T#10s,
'Green duration should be at least 10s');
ASSERT_TRUE(timing.greenDuration <= T#120s,
'Green duration should not exceed 120s');
END_TEST

TEST 'Default red duration is reasonable'
VAR timing : PhaseTiming; END_VAR

ASSERT_TRUE(timing.redDuration >= T#10s,
'Red duration should be at least 10s');
END_TEST

TEST 'Total cycle time is within bounds'
VAR timing : PhaseTiming; END_VAR

ASSERT_TRUE(
timing.greenDuration + timing.yellowDuration + timing.redDuration >= T#30s,
'Total cycle should be at least 30s');
ASSERT_TRUE(
timing.greenDuration + timing.yellowDuration + timing.redDuration <= T#300s,
'Total cycle should not exceed 300s');
END_TEST
Loading