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

Unit tests for the MCP2515Configurator class. More...

#include "MCP2515Configurator.hpp"
#include "MockSPIController.hpp"
#include <gmock/gmock.h>
#include <gtest/gtest.h>

Go to the source code of this file.

Data Structures

class  MCP2515ConfiguratorTest
 Test fixture for testing the MCP2515Configurator class. More...
 

Functions

 TEST_F (MCP2515ConfiguratorTest, ResetChipSuccess)
 Ensures that resetChip() returns true when the reset is successful.
 
 TEST_F (MCP2515ConfiguratorTest, ResetChipFailure)
 Ensures that resetChip() returns false when the reset fails.
 
 TEST_F (MCP2515ConfiguratorTest, ConfigureBaudRate)
 Ensures that configureBaudRate() writes the correct values to the registers.
 
 TEST_F (MCP2515ConfiguratorTest, ConfigureTXBuffer)
 Ensures that configureTXBuffer() writes the correct value to the TXB0CTRL register.
 
 TEST_F (MCP2515ConfiguratorTest, ConfigureRXBuffer)
 Ensures that configureRXBuffer() writes the correct value to the RXB0CTRL register.
 
 TEST_F (MCP2515ConfiguratorTest, ConfigureFiltersAndMasks)
 Ensures that configureFiltersAndMasks() writes the correct values to the registers.
 
 TEST_F (MCP2515ConfiguratorTest, ConfigureInterrupts)
 Ensures that configureInterrupts() writes the correct value to the CANINTE register.
 
 TEST_F (MCP2515ConfiguratorTest, SetMode)
 Ensures that setMode() writes the correct value to the CANCTRL register.
 
 TEST_F (MCP2515ConfiguratorTest, VerifyModeSuccess)
 Ensures that verifyMode() returns true when the mode is correct.
 
 TEST_F (MCP2515ConfiguratorTest, VerifyModeFailure)
 Ensures that verifyMode() returns false when the mode is incorrect.
 
 TEST_F (MCP2515ConfiguratorTest, ReadCANMessageWithData)
 Ensures that readCANMessage() reads the correct frame ID and data.
 
 TEST_F (MCP2515ConfiguratorTest, ReadCANMessageNoData)
 Ensures that readCANMessage() returns an empty data vector when no CAN message is available.
 

Detailed Description

Unit tests for the MCP2515Configurator 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 MCP2515Configurator class, using Google Test and Google Mock frameworks.

Definition in file test_MCP2515Configurator.cpp.

Function Documentation

◆ TEST_F() [1/12]

TEST_F ( MCP2515ConfiguratorTest ,
ConfigureBaudRate  )

Ensures that configureBaudRate() writes the correct values to the registers.

Test
Tests if the baud rate is configured correctly.

Verifies that configureBaudRate() writes the correct values to the CNF1, CNF2, and CNF3 registers.

See also
MCP2515Configurator::configureBaudRate

Definition at line 73 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [2/12]

TEST_F ( MCP2515ConfiguratorTest ,
ConfigureFiltersAndMasks  )

Ensures that configureFiltersAndMasks() writes the correct values to the registers.

Test
Tests if the filters and masks are configured correctly.

Verifies that configureFiltersAndMasks() writes the correct values to the registers.

See also
MCP2515Configurator::configureFiltersAndMasks

Definition at line 114 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [3/12]

TEST_F ( MCP2515ConfiguratorTest ,
ConfigureInterrupts  )

Ensures that configureInterrupts() writes the correct value to the CANINTE register.

Test
Tests if the interrupts are configured correctly.

Verifies that configureInterrupts() writes the correct value to the CANINTE register.

See also
MCP2515Configurator::configureInterrupts

Definition at line 128 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [4/12]

TEST_F ( MCP2515ConfiguratorTest ,
ConfigureRXBuffer  )

Ensures that configureRXBuffer() writes the correct value to the RXB0CTRL register.

Test
Tests if the RX buffer is configured correctly.

Verifies that configureRXBuffer() writes the correct value to the RXB0CTRL register.

See also
MCP2515Configurator::configureRXBuffer

Definition at line 101 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [5/12]

TEST_F ( MCP2515ConfiguratorTest ,
ConfigureTXBuffer  )

Ensures that configureTXBuffer() writes the correct value to the TXB0CTRL register.

Test
Tests if the TX buffer is configured correctly.

Verifies that configureTXBuffer() writes the correct value to the TXB0CTRL register.

See also
MCP2515Configurator::configureTXBuffer

Definition at line 88 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [6/12]

TEST_F ( MCP2515ConfiguratorTest ,
ReadCANMessageNoData  )

Ensures that readCANMessage() returns an empty data vector when no CAN message is available.

Test
Tests if a CAN message with no data is read correctly.

Verifies that readCANMessage() returns an empty data vector when no CAN message is available.

See also
MCP2515Configurator::readCANMessage

Definition at line 207 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [7/12]

TEST_F ( MCP2515ConfiguratorTest ,
ReadCANMessageWithData  )

Ensures that readCANMessage() reads the correct frame ID and data.

Test
Tests if a CAN message with data is read correctly.

Verifies that readCANMessage() reads the correct frame ID and data when a CAN message with data is available.

See also
MCP2515Configurator::readCANMessage

Definition at line 177 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [8/12]

TEST_F ( MCP2515ConfiguratorTest ,
ResetChipFailure  )

Ensures that resetChip() returns false when the reset fails.

Test
Tests if the chip reset fails.

Verifies that resetChip() returns false when the chip reset fails.

See also
MCP2515Configurator::resetChip

Definition at line 58 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [9/12]

TEST_F ( MCP2515ConfiguratorTest ,
ResetChipSuccess  )

Ensures that resetChip() returns true when the reset is successful.

Test
Tests if the chip reset is successful.

Verifies that resetChip() returns true when the chip reset is successful.

See also
MCP2515Configurator::resetChip

Definition at line 45 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [10/12]

TEST_F ( MCP2515ConfiguratorTest ,
SetMode  )

Ensures that setMode() writes the correct value to the CANCTRL register.

Test
Tests if the mode is set correctly.

Verifies that setMode() writes the correct value to the CANCTRL register.

See also
MCP2515Configurator::setMode

Definition at line 141 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [11/12]

TEST_F ( MCP2515ConfiguratorTest ,
VerifyModeFailure  )

Ensures that verifyMode() returns false when the mode is incorrect.

Test
Tests if the mode verification fails.

Verifies that verifyMode() returns false when the mode is incorrect.

See also
MCP2515Configurator::verifyMode

Definition at line 164 of file test_MCP2515Configurator.cpp.

◆ TEST_F() [12/12]

TEST_F ( MCP2515ConfiguratorTest ,
VerifyModeSuccess  )

Ensures that verifyMode() returns true when the mode is correct.

Test
Tests if the mode verification is successful.

Verifies that verifyMode() returns true when the mode is correct.

See also
MCP2515Configurator::verifyMode

Definition at line 152 of file test_MCP2515Configurator.cpp.