CPP01 1.0
|
This file contains the unit tests for the FileReplacer class. [詳解]
#include "FileReplacer.hpp"
#include "Test.hpp"
#include <cstdlib>
#include <fstream>
#include <sstream>
関数 | |
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 に定義があります。
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.
test | A reference to the custom Test framework object. |
FileReplacerTest.cpp の 89 行目に定義があります。
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.
file1 | The path to the first file. |
file2 | The path to the second file. |
FileReplacerTest.cpp の 37 行目に定義があります。
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.
test | A reference to the custom Test framework object. |
FileReplacerTest.cpp の 69 行目に定義があります。
int main | ( | void | ) |
The main function for running the unit tests.
Creates a Test framework object and runs the defined test suites.
FileReplacerTest.cpp の 155 行目に定義があります。
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.
test | A reference to the custom Test framework object. |
FileReplacerTest.cpp の 107 行目に定義があります。
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.
test | A reference to the custom Test framework object. |
FileReplacerTest.cpp の 132 行目に定義があります。