Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
ChunkTestBase Class Reference

#include </home/runner/work/chunking_cpp/chunking_cpp/tests/test_base.hpp>

+ Inheritance diagram for ChunkTestBase:
+ Collaboration diagram for ChunkTestBase:

Protected Member Functions

template<typename T >
bool is_valid_resource (const T &resource)
 
template<typename T >
void safe_cleanup (T &resource)
 
void SetUp () override
 
void TearDown () override
 

Static Protected Attributes

static std::mutex global_test_mutex_
 
static constexpr auto TEST_COOLDOWN = std::chrono::milliseconds(100)
 
static std::condition_variable test_cv_
 
static bool test_running_ = false
 

Detailed Description

Definition at line 9 of file test_base.hpp.

Member Function Documentation

◆ is_valid_resource()

template<typename T >
bool ChunkTestBase::is_valid_resource ( const T &  resource)
inlineprotected

Definition at line 33 of file test_base.hpp.

33 {
34 return resource != nullptr;
35 }

◆ safe_cleanup()

template<typename T >
void ChunkTestBase::safe_cleanup ( T &  resource)
inlineprotected

Definition at line 21 of file test_base.hpp.

21 {
22 try {
23 if (resource) {
24 resource.reset();
25 }
26 } catch (...) {
27 // Log or handle cleanup errors
28 }
29 }

◆ SetUp()

void ChunkTestBase::SetUp ( )
overrideprotected

Definition at line 8 of file test_base.cpp.

8 {
9 std::unique_lock<std::mutex> lock(global_test_mutex_);
10 // Wait until no other test is running
11 test_cv_.wait(lock, [] { return !test_running_; });
12 test_running_ = true;
13}
static bool test_running_
Definition test_base.hpp:13
static std::mutex global_test_mutex_
Definition test_base.hpp:11
static std::condition_variable test_cv_
Definition test_base.hpp:12

References global_test_mutex_, test_cv_, and test_running_.

Referenced by ParallelChunkProcessorTest::SetUp(), SubChunkStrategiesTest::SetUp(), and ChunkMetricsTest::SetUp().

◆ TearDown()

void ChunkTestBase::TearDown ( )
overrideprotected

Definition at line 15 of file test_base.cpp.

15 {
16 {
17 std::lock_guard<std::mutex> lock(global_test_mutex_);
18 test_running_ = false;
19 }
20 // Notify next test can run
21 test_cv_.notify_one();
22 // Add cooldown period between tests
23 std::this_thread::sleep_for(TEST_COOLDOWN);
24}
static constexpr auto TEST_COOLDOWN
Definition test_base.hpp:14

References global_test_mutex_, TEST_COOLDOWN, test_cv_, and test_running_.

Referenced by ParallelChunkProcessorTest::TearDown(), SubChunkStrategiesTest::TearDown(), and ChunkMetricsTest::TearDown().

Member Data Documentation

◆ global_test_mutex_

std::mutex ChunkTestBase::global_test_mutex_
staticprotected

Definition at line 11 of file test_base.hpp.

Referenced by SetUp(), and TearDown().

◆ TEST_COOLDOWN

constexpr auto ChunkTestBase::TEST_COOLDOWN = std::chrono::milliseconds(100)
staticconstexprprotected

Definition at line 14 of file test_base.hpp.

Referenced by TearDown().

◆ test_cv_

std::condition_variable ChunkTestBase::test_cv_
staticprotected

Definition at line 12 of file test_base.hpp.

Referenced by SetUp(), and TearDown().

◆ test_running_

bool ChunkTestBase::test_running_ = false
staticprotected

Definition at line 13 of file test_base.hpp.

Referenced by SetUp(), and TearDown().


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