Add working unit tests

This commit is contained in:
Jaakko Haakana 2025-07-26 15:19:49 +03:00
parent f609d54a14
commit 995cc7784c
106 changed files with 589 additions and 582 deletions

24
test/safety_tests.cpp Normal file
View file

@ -0,0 +1,24 @@
#include <gtest/gtest.h>
#include "../Software/src/datalayer/datalayer.h"
#include "../Software/src/devboard/safety/safety.h"
#include "../Software/src/devboard/utils/events.h"
#include "../Software/src/inverter/ModbusInverterProtocol.h"
TEST(SafetyTests, ShouldSetEventWhenTemperatureTooHigh) {
init_events();
datalayer.system.info.CPU_temperature = 82;
update_machineryprotection();
auto event_pointer = get_event_pointer(EVENT_CPU_OVERHEATING);
EXPECT_EQ(event_pointer->occurences, 1);
}
TEST(SafetyTests, ShouldSetEventWhenTemperatureWayTooHigh) {
init_events();
datalayer.system.info.CPU_temperature = 200;
update_machineryprotection();
auto event_pointer = get_event_pointer(EVENT_CPU_OVERHEATED);
EXPECT_EQ(event_pointer->occurences, 1);
}