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

Unit tests for the CANMessageProcessor class. More...

#include "CANMessageProcessor.hpp"
#include <gtest/gtest.h>
#include <stdexcept>
#include <vector>

Go to the source code of this file.

Data Structures

class  CANMessageProcessorTest
 Test fixture for testing the CANMessageProcessor class. More...
 

Functions

 TEST_F (CANMessageProcessorTest, RegisterHandlerSuccess)
 Ensures that registerHandler() does not throw an exception.
 
 TEST_F (CANMessageProcessorTest, RegisterHandlerNullThrowsException)
 Ensures that registerHandler() throws an invalid_argument exception.
 
 TEST_F (CANMessageProcessorTest, ProcessMessageWithRegisteredHandler)
 Ensures that the registered handler is called with the correct data.
 
 TEST_F (CANMessageProcessorTest, ProcessMessageWithUnregisteredHandlerThrowsException)
 Ensures that processMessage() throws a runtime_error exception.
 
 TEST_F (CANMessageProcessorTest, OverwriteHandlerForSameFrameID)
 Ensures that the new handler is called instead of the old handler.
 

Detailed Description

Unit tests for the CANMessageProcessor class.

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 CANMessageProcessor class, using Google Test framework.

Definition in file test_CANMessageProcessor.cpp.

Function Documentation

◆ TEST_F() [1/5]

TEST_F ( CANMessageProcessorTest ,
OverwriteHandlerForSameFrameID  )

Ensures that the new handler is called instead of the old handler.

Test
Tests if a handler can be overwritten for the same frame ID.

Verifies that registering a new handler for the same frame ID overwrites the old handler.

See also
CANMessageProcessor::registerHandler

Definition at line 99 of file test_CANMessageProcessor.cpp.

◆ TEST_F() [2/5]

TEST_F ( CANMessageProcessorTest ,
ProcessMessageWithRegisteredHandler  )

Ensures that the registered handler is called with the correct data.

Test
Tests if a message is processed with a registered handler.

Verifies that processMessage() calls the registered handler with the correct data.

See also
CANMessageProcessor::processMessage

Definition at line 63 of file test_CANMessageProcessor.cpp.

◆ TEST_F() [3/5]

TEST_F ( CANMessageProcessorTest ,
ProcessMessageWithUnregisteredHandlerThrowsException  )

Ensures that processMessage() throws a runtime_error exception.

Test
Tests if processing a message with an unregistered handler throws an exception.

Verifies that processMessage() throws a runtime_error exception when no handler is registered for the given frame ID.

See also
CANMessageProcessor::processMessage

Definition at line 85 of file test_CANMessageProcessor.cpp.

◆ TEST_F() [4/5]

TEST_F ( CANMessageProcessorTest ,
RegisterHandlerNullThrowsException  )

Ensures that registerHandler() throws an invalid_argument exception.

Test
Tests if registering a null handler throws an exception.

Verifies that registerHandler() throws an invalid_argument exception when a null handler is registered.

See also
CANMessageProcessor::registerHandler

Definition at line 51 of file test_CANMessageProcessor.cpp.

◆ TEST_F() [5/5]

TEST_F ( CANMessageProcessorTest ,
RegisterHandlerSuccess  )

Ensures that registerHandler() does not throw an exception.

Test
Tests if a handler can be registered successfully.

Verifies that registerHandler() does not throw an exception when a valid handler is registered.

See also
CANMessageProcessor::registerHandler

Definition at line 39 of file test_CANMessageProcessor.cpp.