iceberg-cpp
Loading...
Searching...
No Matches
Protected Member Functions | Protected Attributes | List of all members
iceberg::TempFileTestBase Class Reference

#include <temp_file_test_base.h>

Inheritance diagram for iceberg::TempFileTestBase:
iceberg::FileScanTaskTest iceberg::GZipTest iceberg::LocalFileIOTest iceberg::MetadataIOTest iceberg::avro::AVROStreamTest iceberg::avro::AvroReaderTest iceberg::parquet::ParquetReaderTest iceberg::avro::AvroReaderParameterizedTest

Protected Member Functions

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.
 

Protected Attributes

std::vector< std::string > created_temp_files_
 

Detailed Description

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 {
// Always call base class SetUp first
TempFileTestBase::SetUp();
// Create test resources
my_temp_file_ = CreateNewTempFilePath();
// Additional setup...
}
// Your test-specific members
std::string my_temp_file_;
};
TEST_F(MyTest, ExampleTest) {
// Use temporary files in your test
WriteContentToFile(my_temp_file_, "test content");
// Files will be automatically cleaned up in TearDown
}
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:


The documentation for this class was generated from the following file: