Unit tests for the CanBusManager class. More...
#include "CanBusManager.hpp"
#include "MockMCP2515Controller.hpp"
#include <QSignalSpy>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
Go to the source code of this file.
Data Structures | |
class | CanBusManagerTest |
Class to test the integration between the CanBusManager and the MCP2515 controller. More... | |
Functions | |
TEST_F (CanBusManagerTest, SpeedSignalEmitsCorrectly) | |
Ensures that the speed signal is emitted with the correct value. | |
TEST_F (CanBusManagerTest, RpmSignalEmitsCorrectly) | |
Ensures that the RPM signal emits the correct value. | |
TEST_F (CanBusManagerTest, InitializeFailsWhenControllerFails) | |
Ensures that initialize() fails when the controller fails to initialize. | |
TEST_F (CanBusManagerTest, InitializeSucceedsWhenControllerSucceeds) | |
Ensures that initialize() succeeds when the controller initializes successfully. | |
TEST_F (CanBusManagerTest, DestructorCallsStopReading) | |
Verifies that stopReading() is triggered in the destructor. | |
Unit tests for the CanBusManager class.
This file contains unit tests for the CanBusManager class, using Google Test and Google Mock frameworks.
Definition in file test_CanBusManager.cpp.
TEST_F | ( | CanBusManagerTest | , |
DestructorCallsStopReading | ) |
Verifies that stopReading()
is triggered in the destructor.
stopReading()
is called when CanBusManager
is destroyed. This test initializes CanBusManager
, then deletes it and confirms that stopReading()
was called exactly once.
Definition at line 152 of file test_CanBusManager.cpp.
TEST_F | ( | CanBusManagerTest | , |
InitializeFailsWhenControllerFails | ) |
Ensures that initialize()
fails when the controller fails to initialize.
CanBusManager::initialize()
when init()
fails. This test sets up a mock expectation that init()
will return false
, verifying that initialize()
correctly fails in this case.
Definition at line 115 of file test_CanBusManager.cpp.
TEST_F | ( | CanBusManagerTest | , |
InitializeSucceedsWhenControllerSucceeds | ) |
Ensures that initialize()
succeeds when the controller initializes successfully.
CanBusManager::initialize()
when init()
succeeds. This test sets up a mock expectation that init()
will return true
, verifying that initialize()
correctly returns true
.
Definition at line 132 of file test_CanBusManager.cpp.
TEST_F | ( | CanBusManagerTest | , |
RpmSignalEmitsCorrectly | ) |
Ensures that the RPM signal emits the correct value.
rpmUpdated
signal is emitted correctly. Similar to SpeedSignalEmitsCorrectly
, this test verifies that rpmUpdated
emits the expected RPM value.
Definition at line 95 of file test_CanBusManager.cpp.
TEST_F | ( | CanBusManagerTest | , |
SpeedSignalEmitsCorrectly | ) |
Ensures that the speed signal is emitted with the correct value.
speedUpdated
signal is emitted correctly. This test uses QSignalSpy
to verify that speedUpdated
emits the expected speed value when the mock controller triggers the signal.
Definition at line 76 of file test_CanBusManager.cpp.