Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
test_MCP2515Controller.cpp File Reference

File containing integration tests for the MCP2515 controller. More...

#include "MCP2515Controller.hpp"
#include "MockSPIController.hpp"
#include <QObject>
#include <QSignalSpy>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <thread>

Go to the source code of this file.

Data Structures

class  MCP2515ControllerTest
 Test fixture for testing the MCP2515Controller class. More...
 

Functions

 TEST_F (MCP2515ControllerTest, InitializationSuccess)
 Ensures that init() does not throw an exception.
 
 TEST_F (MCP2515ControllerTest, InitializationFailure)
 Ensures that init() throws an exception when the initialization fails.
 
 TEST_F (MCP2515ControllerTest, SetupHandlersTest)
 Ensures that registerHandler() does not throw an exception.
 
 TEST_F (MCP2515ControllerTest, SpeedUpdatedSignal)
 Ensures that the speed signal is emitted with the correct value.
 
 TEST_F (MCP2515ControllerTest, RpmUpdatedSignal)
 Ensures that the RPM signal emits the correct value.
 
 TEST_F (MCP2515ControllerTest, ProcessReadingCallsHandlers)
 Ensures that processReading() calls the registered handlers.
 
 TEST_F (MCP2515ControllerTest, StopReadingStopsProcessing)
 Ensures that stopReading() sets the stop flag.
 

Detailed Description

File containing integration tests for the MCP2515 controller.

Unit tests for the MCP2515Controller class.

Version
0.1
Date
2025-01-31
Author
Michel Batista (@MicchelFAB)
Félix LE BIHAN (@Fle-bihh)
Ricardo Melo (@reomelo)
Tiago Pereira (@t-pereira06)
Version
0.1
Date
2025-01-30
Author
Félix LE BIHAN (@Fle-bihh)
Ricardo Melo (@reomelo)
Tiago Pereira (@t-pereira06)
Michel Batista (@MicchelFAB)

This file contains unit tests for the MCP2515Controller class, using Google Test and Google Mock frameworks.

Definition in file test_MCP2515Controller.cpp.

Function Documentation

◆ TEST_F() [1/7]

TEST_F ( MCP2515ControllerTest ,
InitializationFailure  )

Ensures that init() throws an exception when the initialization fails.

Test
Tests if the initialization fails.

Verifies that init() throws a runtime_error when the initialization fails.

See also
MCP2515Controller::init

Definition at line 71 of file test_MCP2515Controller.cpp.

◆ TEST_F() [2/7]

TEST_F ( MCP2515ControllerTest ,
InitializationSuccess  )

Ensures that init() does not throw an exception.

Test
Tests if the initialization is successful.

Verifies that init() does not throw an exception when the initialization is successful.

See also
MCP2515Controller::init

Definition at line 53 of file test_MCP2515Controller.cpp.

Here is the call graph for this function:

◆ TEST_F() [3/7]

TEST_F ( MCP2515ControllerTest ,
ProcessReadingCallsHandlers  )

Ensures that processReading() calls the registered handlers.

Test
Tests if processReading() calls handlers correctly.

Verifies that processReading() calls the registered handlers when data is available.

See also
MCP2515Controller::processReading

Definition at line 149 of file test_MCP2515Controller.cpp.

Here is the call graph for this function:

◆ TEST_F() [4/7]

TEST_F ( MCP2515ControllerTest ,
RpmUpdatedSignal  )

Ensures that the RPM signal emits the correct value.

Test
Tests if the rpmUpdated signal is emitted correctly.

Uses QSignalSpy to verify that rpmUpdated emits the expected RPM value.

See also
MCP2515Controller::rpmUpdated

Definition at line 126 of file test_MCP2515Controller.cpp.

Here is the call graph for this function:

◆ TEST_F() [5/7]

TEST_F ( MCP2515ControllerTest ,
SetupHandlersTest  )

Ensures that registerHandler() does not throw an exception.

Test
Tests if handlers are set up correctly.

Verifies that registerHandler() does not throw an exception when setting up handlers.

See also
CANMessageProcessor::registerHandler

Definition at line 84 of file test_MCP2515Controller.cpp.

Here is the call graph for this function:

◆ TEST_F() [6/7]

TEST_F ( MCP2515ControllerTest ,
SpeedUpdatedSignal  )

Ensures that the speed signal is emitted with the correct value.

Test
Tests if the speedUpdated signal is emitted correctly.

Uses QSignalSpy to verify that speedUpdated emits the expected speed value.

See also
MCP2515Controller::speedUpdated

Definition at line 103 of file test_MCP2515Controller.cpp.

Here is the call graph for this function:

◆ TEST_F() [7/7]

TEST_F ( MCP2515ControllerTest ,
StopReadingStopsProcessing  )

Ensures that stopReading() sets the stop flag.

Test
Tests if stopReading() stops the processing.

Verifies that stopReading() sets the stop flag to true.

See also
MCP2515Controller::stopReading

Definition at line 182 of file test_MCP2515Controller.cpp.

Here is the call graph for this function: