use adze_stack_pool_core::{PoolStats, StackPool, get_thread_local_pool, init_thread_local_pool};
use std::rc::Rc;
#[test]
fn test_contract_lock_types() {
let pool: StackPool<u32> = StackPool::new(4);
let _debug = format!("{pool:?}");
let stats = PoolStats {
total_allocations: 0,
reuse_count: 0,
pool_hits: 0,
pool_misses: 0,
max_pool_depth: 0,
};
assert_eq!(stats.total_allocations, 0);
assert_eq!(stats.reuse_count, 0);
assert_eq!(stats.pool_hits, 0);
assert_eq!(stats.pool_misses, 0);
assert_eq!(stats.max_pool_depth, 0);
let _debug_stats = format!("{stats:?}");
let default_stats = PoolStats::default();
assert_eq!(default_stats.total_allocations, 0);
let _cloned_stats = stats;
let _copied: PoolStats = stats;
assert_eq!(stats, stats);
let other = PoolStats::default();
assert_eq!(stats, other);
use std::collections::HashSet;
let mut set = HashSet::new();
set.insert(stats);
}
#[test]
fn test_contract_lock_stack_pool_methods() {
let pool: StackPool<u32> = StackPool::new(4);
let _pool2: StackPool<i32> = StackPool::new(8);
let stack: Vec<u32> = pool.acquire();
assert!(stack.capacity() >= 256);
pool.release(stack);
let stack_with_cap = pool.acquire_with_capacity(512);
assert!(stack_with_cap.capacity() >= 512);
pool.release(stack_with_cap);
let original = vec![1u32, 2, 3];
let _cloned = pool.clone_stack(&original);
let _stats: PoolStats = pool.stats();
pool.reset_stats();
pool.clear();
}
#[test]
fn test_contract_lock_functions() {
init_thread_local_pool(16);
let pool: Rc<StackPool<u32>> = get_thread_local_pool();
let _stack = pool.acquire();
}