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

Unit tests for the MileageFileHandler class. More...

#include "MileageFileHandler.hpp"
#include "MockFileController.hpp"
#include <gmock/gmock.h>
#include <gtest/gtest.h>

Go to the source code of this file.

Data Structures

class  MileageFileHandlerTest
 Test fixture for testing the MileageFileHandler class. More...
 

Functions

 TEST_F (MileageFileHandlerTest, EnsureFileExists_FileDoesNotExist_CreatesFileWithZeroMileage)
 Ensures that the mileage file handler creates the file if it does not exist.
 
 TEST_F (MileageFileHandlerTest, ReadMileage_ValidNumber_ReturnsParsedValue)
 Ensures that the mileage file handler does not create the file if it already exists.
 
 TEST_F (MileageFileHandlerTest, ReadMileage_InvalidNumber_ReturnsZero)
 Ensures that the mileage file handler reads zero mileage if the file is empty.
 
 TEST_F (MileageFileHandlerTest, WriteMileage_ValidNumber_WritesToFile)
 Ensures that the mileage file handler writes the mileage to the file.
 

Detailed Description

Unit tests for the MileageFileHandler class.

Version
0.1
Date
2025-02-12

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

Author
Félix LE BIHAN (@Fle-bihh)
Tiago Pereira (@t-pereira06)
Ricardo Melo (@reomelo)
Michel Batista (@MicchelFAB)

Definition in file test_MileageFileHandler.cpp.

Function Documentation

◆ TEST_F() [1/4]

TEST_F ( MileageFileHandlerTest ,
EnsureFileExists_FileDoesNotExist_CreatesFileWithZeroMileage  )

Ensures that the mileage file handler creates the file if it does not exist.

Test
Tests if the mileage file handler creates the file if it does not exist.

This test verifies that the mileage file handler creates the file if it does not exist.

See also
MileageFileHandler::ensureFileExists

Definition at line 65 of file test_MileageFileHandler.cpp.

◆ TEST_F() [2/4]

TEST_F ( MileageFileHandlerTest ,
ReadMileage_InvalidNumber_ReturnsZero  )

Ensures that the mileage file handler reads zero mileage if the file is empty.

Test
Tests if the mileage file handler reads zero mileage if the file is empty.

This test verifies that the mileage file handler reads zero mileage if the file is empty.

See also
MileageFileHandler::readMileage

Definition at line 116 of file test_MileageFileHandler.cpp.

◆ TEST_F() [3/4]

TEST_F ( MileageFileHandlerTest ,
ReadMileage_ValidNumber_ReturnsParsedValue  )

Ensures that the mileage file handler does not create the file if it already exists.

Test
Tests if the mileage file handler does not create the file if it already exists.

This test verifies that the mileage file handler does not create the file if it already exists.

See also
MileageFileHandler::ensureFileExists

Definition at line 97 of file test_MileageFileHandler.cpp.

Here is the call graph for this function:

◆ TEST_F() [4/4]

TEST_F ( MileageFileHandlerTest ,
WriteMileage_ValidNumber_WritesToFile  )

Ensures that the mileage file handler writes the mileage to the file.

Test
Tests if the mileage file handler writes the mileage to the file.

This test verifies that the mileage file handler writes the mileage to the file.

See also
MileageFileHandler::writeMileage

Definition at line 135 of file test_MileageFileHandler.cpp.