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

Unit tests for the PeripheralController class. More...

#include "../mocks/MockPeripheralController.hpp"
#include <gmock/gmock.h>
#include <gtest/gtest.h>

Go to the source code of this file.

Functions

 TEST (PeripheralControllerTest, TestServoPWM)
 Ensures that set_servo_pwm() is called with the correct parameters.
 
 TEST (PeripheralControllerTest, TestMotorPWM)
 Ensures that set_motor_pwm() is called with the correct parameters.
 
 TEST (PeripheralControllerTest, TestInitServo)
 Ensures that init_servo() is called.
 
 TEST (PeripheralControllerTest, TestInitMotors)
 Ensures that init_motors() is called.
 
 TEST (PeripheralControllerTest, TestI2CWriteByteData)
 Ensures that i2c_smbus_write_byte_data() is called with the correct parameters.
 
 TEST (PeripheralControllerTest, TestI2CReadByteData)
 Ensures that i2c_smbus_read_byte_data() is called with the correct parameters.
 
 TEST (PeripheralControllerTest, TestWriteByteDataException)
 Ensures that write_byte_data() throws a runtime_error exception.
 
 TEST (PeripheralControllerTest, TestReadByteDataException)
 Ensures that read_byte_data() throws a runtime_error exception.
 

Detailed Description

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

Definition in file test_PeripheralController.cpp.

Function Documentation

◆ TEST() [1/8]

TEST ( PeripheralControllerTest ,
TestI2CReadByteData  )

Ensures that i2c_smbus_read_byte_data() is called with the correct parameters.

Test
Tests if I2C read byte data is called correctly.

This test verifies that i2c_smbus_read_byte_data() is called with the correct parameters and returns the expected result.

See also
PeripheralController::i2c_smbus_read_byte_data

Definition at line 125 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [2/8]

TEST ( PeripheralControllerTest ,
TestI2CWriteByteData  )

Ensures that i2c_smbus_write_byte_data() is called with the correct parameters.

Test
Tests if I2C write byte data is called correctly.

This test verifies that i2c_smbus_write_byte_data() is called with the correct parameters and returns the expected result.

See also
PeripheralController::i2c_smbus_write_byte_data

Definition at line 104 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [3/8]

TEST ( PeripheralControllerTest ,
TestInitMotors  )

Ensures that init_motors() is called.

Test
Tests if the motors are initialized correctly.

This test verifies that init_motors() is called.

See also
PeripheralController::init_motors

Definition at line 86 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [4/8]

TEST ( PeripheralControllerTest ,
TestInitServo  )

Ensures that init_servo() is called.

Test
Tests if the servo is initialized correctly.

This test verifies that init_servo() is called.

See also
PeripheralController::init_servo

Definition at line 70 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [5/8]

TEST ( PeripheralControllerTest ,
TestMotorPWM  )

Ensures that set_motor_pwm() is called with the correct parameters.

Test
Tests if the motor PWM is set correctly.

This test verifies that set_motor_pwm() is called with the correct parameters.

See also
PeripheralController::set_motor_pwm

Definition at line 52 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [6/8]

TEST ( PeripheralControllerTest ,
TestReadByteDataException  )

Ensures that read_byte_data() throws a runtime_error exception.

Test
Tests if read_byte_data() throws an exception on failure.

This test verifies that read_byte_data() throws a runtime_error exception when the I2C read fails.

See also
PeripheralController::read_byte_data

Definition at line 164 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [7/8]

TEST ( PeripheralControllerTest ,
TestServoPWM  )

Ensures that set_servo_pwm() is called with the correct parameters.

Test
Tests if the servo PWM is set correctly.

This test verifies that set_servo_pwm() is called with the correct parameters.

See also
PeripheralController::set_servo_pwm

Definition at line 33 of file test_PeripheralController.cpp.

Here is the call graph for this function:

◆ TEST() [8/8]

TEST ( PeripheralControllerTest ,
TestWriteByteDataException  )

Ensures that write_byte_data() throws a runtime_error exception.

Test
Tests if write_byte_data() throws an exception on failure.

This test verifies that write_byte_data() throws a runtime_error exception when the I2C write fails.

See also
PeripheralController::write_byte_data

Definition at line 145 of file test_PeripheralController.cpp.

Here is the call graph for this function: