|
|
void | SetUp () override |
| |
|
void | TearDown () override |
| |
|
std::string | GenerateUniqueTempFilePath () const |
| | Generates a unique temporary filepath that works across platforms.
|
| |
|
std::string | GenerateUniqueTempFilePathWithSuffix (const std::string &suffix) |
| | Create a temporary filepath with the specified suffix/extension.
|
| |
|
std::string | GenerateRandomString (size_t length) const |
| | Helper to generate a random alphanumeric string for unique filenames.
|
| |
|
std::string | TestInfo () const |
| | Get the test name for inclusion in the filename.
|
| |
|
std::string | CreateNewTempFilePath () |
| | Creates a new temporary filepath and registers it for cleanup.
|
| |
|
std::string | CreateNewTempFilePathWithSuffix (const std::string &suffix) |
| | Create a temporary filepath with the specified suffix and registers it for cleanup.
|
| |
|
std::string | CreateTempDirectory () |
| | Creates a temporary directory and registers it for cleanup.
|
| |
|
void | WriteContentToFile (const std::string &path, const std::string &content) |
| | Creates a file with the given content at the specified path.
|
| |
|
std::string | CreateTempFileWithContent (const std::string &content) |
| | Creates a new temporary file with the given content.
|
| |
A base class for tests that need to create and manage temporary files. Provides utilities for creating platform-independent temporary files and ensures proper cleanup after tests run.
Usage Example:
class MyTest : public test::TempFileTestBase {
protected:
void SetUp() override {
TempFileTestBase::SetUp();
my_temp_file_ = CreateNewTempFilePath();
}
std::string my_temp_file_;
};
TEST_F(MyTest, ExampleTest) {
}
void WriteContentToFile(const std::string &path, const std::string &content)
Creates a file with the given content at the specified path.
Definition temp_file_test_base.h:167
Notes:
- Always call TempFileTestBase::SetUp() in your derived class's SetUp()
- All files created using the provided methods will be automatically cleaned up
- You don't need to implement TearDown() unless you need additional cleanup