use crate::*;
#[derive(Debug, PartialEq, Clone)]
struct Point {
x: usize,
y: usize,
}
#[test]
fn test_alloc() {
let pool = Pool::new();
let p1 = pool.alloc(Point { x: 1, y: 1 });
assert_eq!(p1, &Point { x: 1, y: 1 });
assert_eq!(pool.total_allocations(), 1);
assert_eq!(pool.len(), 0);
let p2 = pool.alloc(Point { x: 2, y: 2 });
assert_eq!(p2, &Point { x: 2, y: 2 });
assert_eq!(pool.total_allocations(), 2);
assert_eq!(pool.len(), 0);
drop(p1);
assert_eq!(pool.len(), 1);
let p3 = pool.alloc(Point { x: 3, y: 3 });
assert_eq!(p3, &Point { x: 3, y: 3 });
assert_eq!(pool.total_allocations(), 2);
assert_eq!(pool.len(), 0);
let p4 = p3.clone();
assert_eq!(p4, &Point { x: 3, y: 3 });
assert_eq!(pool.total_allocations(), 3);
drop(p4);
assert_eq!(pool.len(), 1);
drop(p2);
assert_eq!(pool.len(), 2);
drop(p3);
assert_eq!(pool.len(), 3);
assert_eq!(pool.total_allocations(), 3);
let factory = pool.factory();
let p5 = factory.alloc(Point { x: 5, y: 5 });
assert_eq!(p5, &Point { x: 5, y: 5 });
}