Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
test_base.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <condition_variable>
5#include <gtest/gtest.h>
6#include <mutex>
7#include <thread>
8
9class ChunkTestBase : public ::testing::Test {
10protected:
11 static std::mutex global_test_mutex_;
12 static std::condition_variable test_cv_;
13 static bool test_running_;
14 static constexpr auto TEST_COOLDOWN = std::chrono::milliseconds(100);
15
16 void SetUp() override;
17 void TearDown() override;
18
19 // Helper method to safely clean up resources
20 template <typename T>
21 void safe_cleanup(T& resource) {
22 try {
23 if (resource) {
24 resource.reset();
25 }
26 } catch (...) {
27 // Log or handle cleanup errors
28 }
29 }
30
31 // Helper method to verify resource validity
32 template <typename T>
33 bool is_valid_resource(const T& resource) {
34 return resource != nullptr;
35 }
36};
static constexpr auto TEST_COOLDOWN
Definition test_base.hpp:14
void SetUp() override
Definition test_base.cpp:8
static bool test_running_
Definition test_base.hpp:13
bool is_valid_resource(const T &resource)
Definition test_base.hpp:33
void TearDown() override
Definition test_base.cpp:15
void safe_cleanup(T &resource)
Definition test_base.hpp:21
static std::mutex global_test_mutex_
Definition test_base.hpp:11
static std::condition_variable test_cv_
Definition test_base.hpp:12