CPP01 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
FileReplacerTest.cpp ファイル

This file contains the unit tests for the FileReplacer class. [詳解]

#include "FileReplacer.hpp"
#include "Test.hpp"
#include <cstdlib>
#include <fstream>
#include <sstream>
FileReplacerTest.cpp の依存先関係図:

[ソースコード]

関数

bool compareFiles (const std::string &file1, const std::string &file2)
 Helper function to compare the contents of two files.
 
void constructorsTest (Test &test)
 Test suite for the constructors of the FileReplacer class.
 
void assignmentOperatorTest (Test &test)
 Test suite for the assignment operator of the FileReplacer class.
 
void processFileBasicTest (Test &test)
 Test suite for the basic functionality of the processFile() method.
 
void processFileEmptyS1Test (Test &test)
 Test suite for the processFile() method when the string to find (s1) is empty.
 
int main ()
 The main function for running the unit tests.
 

詳解

This file contains the unit tests for the FileReplacer class.

It uses a custom testing framework (Test.hpp) to verify the functionality of the FileReplacer class, including its constructors, assignment operator, and the processFile method.

FileReplacerTest.cpp に定義があります。

関数詳解

◆ assignmentOperatorTest()

void assignmentOperatorTest ( Test test)

Test suite for the assignment operator of the FileReplacer class.

Verifies that the assignment operator correctly copies the member variables from one FileReplacer object to another.

引数
testA reference to the custom Test framework object.

FileReplacerTest.cpp89 行目に定義があります。

◆ compareFiles()

bool compareFiles ( const std::string file1,
const std::string file2 
)

Helper function to compare the contents of two files.

Reads each line of the two files and returns true if they are identical, false otherwise.

引数
file1The path to the first file.
file2The path to the second file.
戻り値
true if the files are identical, false otherwise.

FileReplacerTest.cpp37 行目に定義があります。

◆ constructorsTest()

void constructorsTest ( Test test)

Test suite for the constructors of the FileReplacer class.

Verifies the behavior of the default constructor and the constructor that takes filename, string to find, and string to replace as parameters.

引数
testA reference to the custom Test framework object.

FileReplacerTest.cpp69 行目に定義があります。

◆ main()

int main ( void  )

The main function for running the unit tests.

Creates a Test framework object and runs the defined test suites.

戻り値
0 if all tests pass.

FileReplacerTest.cpp155 行目に定義があります。

◆ processFileBasicTest()

void processFileBasicTest ( Test test)

Test suite for the basic functionality of the processFile() method.

Creates a simple input file, defines an expected output file, runs the processFile() method, and then compares the generated output file with the expected output file.

引数
testA reference to the custom Test framework object.

FileReplacerTest.cpp107 行目に定義があります。

◆ processFileEmptyS1Test()

void processFileEmptyS1Test ( Test test)

Test suite for the processFile() method when the string to find (s1) is empty.

Verifies that the processFile() method throws a std::runtime_error exception when the string to find is empty.

引数
testA reference to the custom Test framework object.

FileReplacerTest.cpp132 行目に定義があります。